esbuild-loader
esbuild-loader copied to clipboard
cannot support webpack require.ensure
Bug description

succeed to build but fail to open the page
Reproduction
just use require.ensure to support dynamic import
Node.js package manager
yarn
Environment
esbuild-loader version: 2.15.1
Webpack version: 4.36.0
Operating System: macOS 10.15.7
Node version: 16.2.0
Package manager (yarn) and version: yarn 1.23.0
Can you contribute a fix?
- [ ] I’m interested in opening a pull request for this issue.
I will look into this but FYI require.ensure()
has been superseded by import()
so this is low priority.
I will look into this but FYI
require.ensure()
has been superseded byimport()
so this is low priority.
thx 👍
I'm still getting this issue when using await import(...)
I assume it's related?
This seems to be related to https://esbuild.github.io/api/#splitting
Without code splitting enabled, an import() expression becomes Promise.resolve().then(() => require()) instead. This still preserves the asynchronous semantics of the expression but it means the imported code is included in the same bundle instead of being split off into a separate file.
I would assume the transform
function is doing this.
I don't think so. It only has "Supported by: Build" underneath. The features in the transform
function has "Supported by: Transform".
Supporting require.ensure()
is low priority, but import()
is very high priority. If you think there's a bug, please open a new issue with a minimal reproduction.
Yeah, I've checked this and transform is definitely leaving the await imports
intact. Seems to be a webpack problem but nothing to do with this plugin :)
Decided not to support require.ensure
since it's deprecated in favor of import()