-
Notifications
You must be signed in to change notification settings - Fork 115
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: custom plugin to fix esbuild esm imports #2269
Conversation
🦋 Changeset detectedLatest commit: f3116e0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 78 packages
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 |
✔️ Deploy Preview for paste-theme-designer ready! 🔨 Explore the source changes: f3116e0 🔍 Inspect the deploy log: https://app.netlify.com/sites/paste-theme-designer/deploys/62265f38e5fc550007a81d92 😎 Browse the preview: https://deploy-preview-2269--paste-theme-designer.netlify.app |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit f3116e0:
|
✔️ Deploy Preview for paste-docs ready! 🔨 Explore the source changes: f3116e0 🔍 Inspect the deploy log: https://app.netlify.com/sites/paste-docs/deploys/62265f38148ced00077cfcf5 😎 Browse the preview: https://deploy-preview-2269--paste-docs.netlify.app |
Size Change: -499 B (0%) Total Size: 508 kB
ℹ️ View Unchanged
|
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const NAME = 'esm-externals'; | ||
const NAMESPACE = NAME; | ||
|
||
// this is a modified version of https://github.com/remorses/esbuild-plugins/tree/master/esm-externals |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: nice commenting, much appreciated
tools/build/esbuild.js
Outdated
}, | ||
}; | ||
const {EsmExternalsPlugin} = require('./build-plugins/EsmExternals'); | ||
const {PasteCJSResolverPlugin} = require('./build-plugins/PasteCJSResolver'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: nice code organization
80ba818
to
53c6a53
Compare
Praise: Great additions, and look at all those green checks! ✅ |
The plugin we used to fix the esbuild issue with require statements in esm compiled packages reintroduced an issue with incorrectly importing defaults from json files, using
import * as x from 'x'
.This is because it blanketly transformed all import statements, even though the bug we were trying to fix was just require statements.
This customized version of the plugin only modifies imports that are require statements and leaves already correct import statements alone.