Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev): support polyfill package imports in deps #7198

Merged
merged 2 commits into from
Aug 22, 2023

Conversation

markdalgleish
Copy link
Member

@markdalgleish markdalgleish commented Aug 20, 2023

Fixes #5521

This error was happening because all Node built-ins were marked as external. This meant that imports for "buffer/" (which is supposed to force the import of the package rather than the Node built-in) would be left as-is in the client bundle.

I added a feature upstream to esbuild-plugins-node-modules-polyfill (imranbarbhuiya/esbuild-plugins-node-modules-polyfill#146) which allows us to inject empty fallbacks instead. This fixes the issue because it only matches on exact import specifiers (i.e. "buffer" matches as a Node built-in, but "buffer/" doesn't).

@markdalgleish markdalgleish added bug Something isn't working package:dev v2 Issues related to v2 apis labels Aug 20, 2023
@markdalgleish markdalgleish self-assigned this Aug 20, 2023
@changeset-bot
Copy link

changeset-bot bot commented Aug 20, 2023

🦋 Changeset detected

Latest commit: 05364f8

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

This PR includes changesets to release 16 packages
Name Type
@remix-run/dev Patch
create-remix Patch
remix Patch
@remix-run/architect Patch
@remix-run/cloudflare Patch
@remix-run/cloudflare-pages Patch
@remix-run/cloudflare-workers Patch
@remix-run/css-bundle Patch
@remix-run/deno Patch
@remix-run/eslint-config Patch
@remix-run/express Patch
@remix-run/node Patch
@remix-run/react Patch
@remix-run/serve Patch
@remix-run/server-runtime Patch
@remix-run/testing 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

)} before continuing.`
);
}
return nodeBuiltins.filter((mod) => !dependencies.includes(mod));
Copy link
Member Author

Choose a reason for hiding this comment

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

This filter was redundant because an error would have already been thrown if this was the case. This is because this filter is the inverse of fakeBuiltins.

@@ -36,7 +36,7 @@
"chokidar": "^3.5.1",
"dotenv": "^16.0.0",
"esbuild": "0.17.6",
"esbuild-plugins-node-modules-polyfill": "^1.3.0",
"esbuild-plugins-node-modules-polyfill": "^1.4.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

This introduces the new fallback: "empty" option: imranbarbhuiya/esbuild-plugins-node-modules-polyfill#146

@markdalgleish markdalgleish merged commit bd289fa into dev Aug 22, 2023
9 checks passed
@markdalgleish markdalgleish deleted the markdalgleish/polyfill-package-imports-in-deps branch August 22, 2023 03:12
@github-actions github-actions bot added the awaiting release This issue has been fixed and will be released soon label Aug 22, 2023
@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version v0.0.0-nightly-bd289fa-20230822 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@github-actions
Copy link
Contributor

🤖 Hello there,

We just published version 2.0.0-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting release This issue has been fixed and will be released soon bug Something isn't working CLA Signed package:dev v2 Issues related to v2 apis
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

2 participants