ice-lab / swc-webpack-plugin Goto Github PK
View Code? Open in Web Editor NEWMinify bundle with swc in webpack
License: MIT License
Minify bundle with swc in webpack
License: MIT License
Hi! I tried out swc-webpack-plugin on my project and ran into a problem where swc interprets a non-strict third-party module as if it were in strict mode, leading to incorrect errors. This might be an swc bug but I figured Iโd ask you first.
Minimal reproduction:
package.json
{
"dependencies": {
"@swc/core": "^1.2.57",
"sorttable": "^1.0.2",
"swc-webpack-plugin": "^1.0.0",
"webpack": "^5.37.1",
"webpack-cli": "^4.7.0"
}
}
webpack.config.js
const { SWCMinifyPlugin } = require("swc-webpack-plugin");
module.exports = {
optimization: {
minimize: true,
minimizer: [new SWCMinifyPlugin()],
},
};
src.js
require("sorttable");
Output
$ npx webpack
error: 'delete' cannot be called on an identifier in strict mode
--> <anon>:80:14
|
80 | delete sortbottomrows;
| ^^^^^^^^^^^^^^
error: 'delete' cannot be called on an identifier in strict mode
--> <anon>:166:17
|
166 | delete row_array;
| ^^^^^^^^^
error: 'delete' cannot be called on an identifier in strict mode
--> <anon>:261:12
|
261 | delete newrows;
| ^^^^^^^
[webpack-cli] HookWebpackError: failed to process js file
Caused by:
failed to parse module: error was recoverable, but proceeding would result in wrong codegen
at makeWebpackError (/home/anders/zulip/test/swc-test/node_modules/webpack/lib/HookWebpackError.js:49:9)
at /home/anders/zulip/test/swc-test/node_modules/webpack/lib/Compilation.js:2495:12
at eval (eval at create (/home/anders/zulip/test/swc-test/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:33:1)
-- inner error --
Error: failed to process js file
Caused by:
failed to parse module: error was recoverable, but proceeding would result in wrong codegen
caused by plugins in Compilation.hooks.processAssets
Error: failed to process js file
Caused by:
failed to parse module: error was recoverable, but proceeding would result in wrong codegen
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.