modify-source-webpack-plugin
modify-source-webpack-plugin copied to clipboard
crash when build again
version: 3.0.0-rc.0
webpack version: 4.46.0
When i use this plugin, the first time build is successful, but if i modify some source code and run build again (with node_modules/.cache), it will throw error. Here is output:
error in ./src/views/Home.vue?vue&type=script&lang=ts&
Syntax Error: Thread Loader (Worker 0)
Modify function at index 0 is not defined in global space.
@ ./src/views/Home.vue?vue&type=script&lang=ts& 1:0-560 1:576-579 1:581-1138 1:581-1138
@ ./src/views/Home.vue
@ ./src/views lazy ^\.\/.*$ namespace object
@ ./src/router/index.ts
@ ./src/main.ts
@ multi ./src/main.ts
I think it's caused by cache. If i remove node_modules/.cache, it can build successfully again.
I am using a new template project (Vue 2) created buy vue-cli. Here is my vue.config.js:
const { ModifySourcePlugin } = require('modify-source-webpack-plugin');
module.exports = {
configureWebpack: {
plugins: [
new ModifySourcePlugin({
debug: true,
rules: [
{
test: /\.vue\?vue&type=script.*/,
modify: (src, path) => {
console.log('modify');
var s = '\n\n';
return src + s;
},
},
],
}),
],
},
};
I'm preparing changes which should help you with this bug. Keep updated
Also thank you for reporting this, after investigating I understand that it's a serious bug which can cause to be plugin fully useless. Found and other smaller bug...
This issue was fixed in the last plugin version (v4). Please look at migration guide because it has a new breaking API