adapt webpack 1.x or 2.x?
See original GitHub issuein my old project , using webpack 1.x. And I use esbuild-loader replace babel-loader will print error
` building for production…/Users/wanglihui/WebstoreProject/onionfph5/project/node_modules/esbuild-loader/dist/plugin.js:12 compiler.hooks.thisCompilation.tap(‘esbuild’, compilation => { ^
TypeError: Cannot read property ‘thisCompilation’ of undefined at ESBuildPlugin.apply (/Users/wanglihui/WebstoreProject/onionfph5/project/node_modules/esbuild-loader/dist/plugin.js:12:24) at Compiler.apply (/Users/wanglihui/WebstoreProject/onionfph5/project/node_modules/tapable/lib/Tapable.js:164:16) at WebpackOptionsApply.process (/Users/wanglihui/WebstoreProject/onionfph5/project/node_modules/webpack/lib/WebpackOptionsApply.js:62:18) at webpack (/Users/wanglihui/WebstoreProject/onionfph5/project/node_modules/webpack/lib/webpack.js:22:48) at /Users/wanglihui/WebstoreProject/onionfph5/project/build/build.js:52:3 at Array.map (<anonymous>) at Object.<anonymous> (/Users/wanglihui/WebstoreProject/onionfph5/project/build/build.js:51:14) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions…js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32)`
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:7 (4 by maintainers)
I agree @wanglihui should update Webpack 😃
The problem above was happening due to the ESBuildPlugin, but since the new esbuild-loader has removed it, you might be able to use
esbuild-loader
with Webpack v1 now if the loader API hasn’t changed. The minification plugin won’t work though.Again, I don’t plan on supporting it so I won’t be adding tests to guarantee the behavior.
Webpack loaders + plugins declare the version of Webpack they support as a peer dependency, like this: https://github.com/privatenumber/esbuild-loader/blob/be292fa98478590ad71ca01194866f720d3cf648/package.json#L40
That way, npm will warn during installation on unmet peer dependencies.