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(esbuild): always support dynamic import and import meta #9105

Merged
merged 3 commits into from Jul 15, 2022

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jul 14, 2022

Description

Close #7179

Set dynamic-import and import-meta supported for esbuild. If they are down-levelled as require() or ({}).url, it would break modern code even if browsers support them. Instead users should be using plugin-legacy, which it would also check for these two features before loading legacy bundle.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@bluwy bluwy added the p3-minor-bug 🔨 An edge case that only affects very specific usage (priority) label Jul 14, 2022
@netlify
Copy link

netlify bot commented Jul 14, 2022

Deploy Preview for vite-docs-main canceled.

Name Link
🔨 Latest commit a658fe2
🔍 Latest deploy log https://app.netlify.com/sites/vite-docs-main/deploys/62cfdd47aa56930009f0bbe5

supported: {
'dynamic-import': true,
'import-meta': true,
...esbuildOptions.supported
}
Copy link
Member

@poyoho poyoho Jul 14, 2022

Choose a reason for hiding this comment

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

As comment said, if they need to be polyfilled, plugin-legacy should be used.. I think the internal config should had high priority. 🤔

And the minimum node version supported by vite also supports dynamic import. I think we don't need esbuild polyfilled.

Copy link
Member Author

@bluwy bluwy Jul 14, 2022

Choose a reason for hiding this comment

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

This part is the same as in the optimizer where the user can set optimizeDeps.esbuildOptions.supported to override too, even if it doesn't make sense. I think it might still be helpful if someone wants to override it for some reason. Though I don't have a hard opinion on this, if we want to change this to be stricter, we should change it for the optimizer too.

@patak-dev patak-dev merged commit 57a7936 into main Jul 15, 2022
12 checks passed
@patak-dev patak-dev deleted the fix-build-syntax branch Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug 🔨 An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

esbuild minify unexpect transform
3 participants