Closed hustcc closed 2 years ago
We already supports browser https://github.com/webpack/tapable/blob/master/package.json#L31
We already supports browser https://github.com/webpack/tapable/blob/master/package.json#L31
not valid config for webpack 5.
There is only 1 api which is from nodejs util
. There is absolutely no need to use built-in modules, and then modify the building config for browsers.
The right way is remove the built-in module and directly use the polyfill code.
Now, we solve it by below code, very dirty.
module.exports = {
mode: 'production',
entry: './src/index.ts',
output: {
library: 'Spreadsheet',
libraryTarget: 'umd',
filename: 'spreadsheet.min.js',
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
fallback: {
// use polyfill util code from `tapable`
util: require.resolve('tapable/lib/util-browser.js'),
},
},
plugins: [
],
module: {
rules: [
{ test: /\.tsx?$/, loader: 'ts-loader' }
]
},
externals: {
},
};
The right way is remove the built-in module and directly use the polyfill code.
No, I can't reproduce your problem... Maybe you can provide full example?
The right way is remove the built-in module and directly use the polyfill code.
No, I can't reproduce your problem... Maybe you can provide full example?
I have no time to provide full example. In terms of code rationality, the best way to support the browser is to delete util
, to avoid the dependence of build configure.
I can support browsers directly. Why do I need to rely on building?
way to reproduce:
tapable
, then release it with esm cjs"ts-jest": "^24.3.0",
"ts-loader": "^9.2.6",
"typescript": "^4.4.2",
"webpack": "^5.64.4",
"webpack-cli": "^4.9.1"
Why do your bundle tapable
? Do you use it in your application?
Why do your bundle
tapable
? Do you use it in your application?
antv/g depends on tapable, I am using antv/g to dev an module which should be used in browser by script
.
There is only one problem - tracking depredations on Node.js using CLI, but I think it is not real problem...
util
module, make tapable can be run on browserto avoid error below in webpack 5: