esbuild-loader icon indicating copy to clipboard operation
esbuild-loader copied to clipboard

adapt webpack 1.x or 2.x?

Open wanglihui opened this issue 4 years ago • 6 comments

in 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 () at Object. (/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)`

wanglihui avatar Dec 31 '20 09:12 wanglihui

The supported Webpack versions are currently ^4.40.0 || ^5.0.0.

I don't plan on supporting it but I'm open to accepting PRs if support can be added un-intrusively.

privatenumber avatar Dec 31 '20 18:12 privatenumber

thanks your answer

wanglihui avatar Jan 04 '21 06:01 wanglihui

Is it even desired @privatenumber ? At this point webpack 2 is over 4 years old with no updates ever since, webpack has changed fundamentally since then, OP should really update his stack as it is awfully outdated and likely has security holes :(

ranisalt avatar Apr 27 '21 14:04 ranisalt

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.

privatenumber avatar Apr 27 '21 17:04 privatenumber

The supported Webpack versions are currently ^4.40.0 || ^5.0.0.

I don't plan on supporting it but I'm open to accepting PRs if support can be added un-intrusively.

I think to avoid this issue in the future, i think we should mention what version of webpack that we use. If it's ok, i can make a PR for it. I'm planning to add it in F.A.Q section. What do you think?

ahmad-reza619 avatar Feb 07 '22 02:02 ahmad-reza619

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.

privatenumber avatar Feb 07 '22 15:02 privatenumber

Closing as Webpack 1 or 2 will not be supported

privatenumber avatar Dec 01 '22 13:12 privatenumber