esbuild minify unexpect transform
See original GitHub issueDescribe the bug
when I use config for vite
export default {
build: {
target: 'chrome60'
}
}
esbuild transform dynamic import
to require
.
like this:
import('./workerImport-a2c311d3.js')
to
require('./workerImport-a2c311d3.js')
may be chrome63 support dynamic import
. chrome60 no support. But I don’t think this conversion meets the expectations.
I think need to polyfill import
in chrome63
Reproduction
https://stackblitz.com/edit/node-qfc2yz?devtoolsheight=33&file=index.js
System Info
any
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
minify unexpect transform #2089 - evanw/esbuild - GitHub
Describe the bug run for this config // run `node index.js` in the terminal const esbuild = require('esbuild'); const code = ` const...
Read more >API - ESBuild
The transform API can take the following options: Simple options: Define; Format; Loader; Minify; Platform; Sourcemap; Target. Advanced options:.
Read more >Introduction to esbuild - Telerik
Let's see how we can increase performance using a modern and extremely fast JavaScript bundler: esbuild.
Read more >Newest 'esbuild' Questions - Stack Overflow
I need a function or API which convert React Js code into plain Js code ... My esbuild build script is supposed to...
Read more >Shared Options | Vite
minifyWhitespace options to false . Note the esbuild.minify option can't be used to override build.minify . Set to false to disable esbuild transforms....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah I think the error would be more obvious if we preserve it. And this also helps to make sure that the modern bundle can be used by modern browsers too. If we downlevel to
require
it’ll break even onchrome100
.I tried to auto issue a warning too but I’m not sure if there’s a neat way of doing so with esbuild.
I think
import
needs to be preserved by esbuild, but it needs renamed in the final output.import
is a keyword in js and to polyfill dynamic import, it needs to be a different name. https://github.com/GoogleChromeLabs/dynamic-import-polyfill#:~:text=The name of the dynamic import polyfill function added to the global scope.Note that
renderDynamicImport
/dynamicImportFunction
cannot be used because Vite usesimport
inrenderChunk
bybuild-import-analysis
which runs after them (#8588).