Skip to content

fix: add support for node-like module resolution#4748

Merged
petebacondarwin merged 5 commits intocloudflare:mainfrom
Cherry:feat/node-module-resolution
Jan 16, 2024
Merged

fix: add support for node-like module resolution#4748
petebacondarwin merged 5 commits intocloudflare:mainfrom
Cherry:feat/node-module-resolution

Conversation

@Cherry
Copy link
Contributor

@Cherry Cherry commented Jan 14, 2024

Fixes #4726

What this PR solves / how to test:

Similar to #4135, this extends the module collection plugin to support standard node-like resolution of file paths.

This allows you to do things like:

import JPEG_DEC_WASM from '@jsquash/jpeg/codec/dec/mozjpeg_dec.wasm';

even when the package doesn't explicitly export that file in its exports map.

This uses resolve, a package that was already in the dependency tree, and used throughout the JS ecosystem everywhere such as in vite, jest, eslint-plugin-import, etc.

Author has addressed the following:

  • Tests
    • Included
    • Not necessary because:
  • Changeset (Changeset guidelines)
    • Included
    • Not necessary because:
  • Associated docs
    • Issue(s)/PR(s):
    • Not necessary because:

Note for PR author:

We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label highlight pr review so future reviewers can take inspiration and learn from it.

@Cherry Cherry requested a review from a team as a code owner January 14, 2024 17:00
@changeset-bot
Copy link

changeset-bot bot commented Jan 14, 2024

🦋 Changeset detected

Latest commit: 36a833b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2024

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7533584307/npm-package-wrangler-4748

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/7533584307/npm-package-wrangler-4748

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7533584307/npm-package-wrangler-4748 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7533584307/npm-package-miniflare-4748
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7533584307/npm-package-cloudflare-pages-shared-4748
npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7533584307/npm-package-create-cloudflare-4748 --no-auto-update

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@3.22.4 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 3.20231218.1
workerd 1.20231218.0 1.20231218.0
workerd --version 1.20231218.0 2023-12-18

|

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@codecov
Copy link

codecov bot commented Jan 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (8d6b3ee) 75.63% compared to head (36a833b) 75.74%.
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4748      +/-   ##
==========================================
+ Coverage   75.63%   75.74%   +0.10%     
==========================================
  Files         243      243              
  Lines       13210    13226      +16     
  Branches     3393     3396       +3     
==========================================
+ Hits         9992    10018      +26     
+ Misses       3218     3208      -10     
Files Coverage Δ
...rangler/src/deployment-bundle/module-collection.ts 87.69% <100.00%> (+0.39%) ⬆️

... and 8 files with indirect coverage changes

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for the fix.
Would you mind adjusting the changeset?

Cherry and others added 2 commits January 15, 2024 15:06
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
@Cherry
Copy link
Contributor Author

Cherry commented Jan 15, 2024

Thanks @petebacondarwin, updated as suggested.

@petebacondarwin petebacondarwin changed the title feat: add support for node-like module resolution fix: add support for node-like module resolution Jan 15, 2024
@petebacondarwin petebacondarwin merged commit 3603a60 into cloudflare:main Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 BUG: onResolve error from bundling module resultion when importing wasm modules from npm packages

2 participants