Closed heath-freenome closed 5 months ago
Hey @heath-freenome,
I'm not sure how to give you a reproducible example
And unfortunately I am unable to reproduce on my end. I am also not sure it is related to wretch at all since the latest update was pretty innocuous.
// index.js
import wretch from "wretch";
const api = wretch("https://jsonplaceholder.typicode.com");
api.get("/posts").json().then(console.log);
const headers1 = new Headers({ hello: "world" });
const headers2 = new Headers({ bonjour: "le monde" });
const headers3 = { hola: "mundo " };
const headers4 = [["hallo", "welt"]];
let w = wretch().headers(headers1);
console.log(w._options.headers);
// Object { hello: "world" }
w = w.headers(headers2);
console.log(w._options.headers);
// Object { hello: "world", bonjour: "le monde" }
w = w.headers(headers3);
console.log(w._options.headers);
// Object { hello: "world", bonjour: "le monde", hola: "mundo " }
w = w.headers(headers4);
console.log(w._options.headers);
// Object { hello: "world", bonjour: "le monde", hola: "mundo ", hallo: "welt" }
{
"scripts": {
"start": "webpack --mode development",
"build": "webpack --mode production --config webpack.config.js"
},
"dependencies": {
"wretch": "^2.7.1"
},
"devDependencies": {
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
}
}
// webpack.config.js
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
};
npm run build
> build
> webpack --mode production --config webpack.config.js
asset main.js 4.82 KiB [emitted] [minimized] (name: main)
orphan modules 14.1 KiB [orphan] 7 modules
./src/index.js + 7 modules 14.8 KiB [built] [code generated]
webpack 5.89.0 compiled successfully in 209 ms
@elbywan I noticed that this PR related to the babel traverse upgrade failed one of your build pipelines... Did that somehow indicate this issue?
@heath-freenome No it was just a timeout during the build - nothing related to a terser error.
Nothing to add here other than to say we are experiencing the same thing (webpack 4 build failure with same message)after adding wretch@2.8.0, after reading this thread and rolling back to 2.7.0 we are able to build again.
Build error resurfaces when we bump to wretch@2.7.1 🤔
I tested a bit and AFAIK the bug arises when using an outdated version of terser-webpack-plugin
which is unable to parse modern code.
If you are using webpack 4, you can install V4 of the plugin (npm i -D terser-webpack-plugin@4
) and use it explicitely in the config file:
const path = require('path');
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
entry: './src/index.mjs',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
};
I can confirm that upgrading to terser-webpack-plugin@4
worked for me too
When I bumped my applications to use
2.7.1
I started having my webpack builds fail with the following error:I'm not sure whether it was your bug fix or the two library updates. I'm not sure how to give you a reproducible example