diff --git a/.changeset/common-berries-hope.md b/.changeset/common-berries-hope.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/common-berries-hope.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/.changeset/famous-dryers-play.md b/.changeset/famous-dryers-play.md deleted file mode 100644 index bc76eb2b3d..0000000000 --- a/.changeset/famous-dryers-play.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@lynx-js/template-webpack-plugin": patch ---- - -Fix source-maps (`.js.map` files) were not accessible in the `compiler.hooks.afterEmit` hook. diff --git a/packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts b/packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts index 9a0225d384..4bf5650d60 100644 --- a/packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts +++ b/packages/webpack/template-webpack-plugin/src/LynxEncodePlugin.ts @@ -130,7 +130,7 @@ export class LynxEncodePluginImpl { const { manifest } = encodeData; if (!isDebug() && !isDev && !isRsdoctor()) { - compiler.hooks.afterEmit.tap(this.name, () => { + compiler.hooks.emit.tap(this.name, () => { this.deleteDebuggingAssets(compilation, [ encodeData.lepusCode.root, ...encodeData.lepusCode.chunks, diff --git a/packages/webpack/template-webpack-plugin/test/cases/assets/production/rspack.config.js b/packages/webpack/template-webpack-plugin/test/cases/assets/production/rspack.config.js index d46fc9af76..6ce0d7b9c3 100644 --- a/packages/webpack/template-webpack-plugin/test/cases/assets/production/rspack.config.js +++ b/packages/webpack/template-webpack-plugin/test/cases/assets/production/rspack.config.js @@ -38,7 +38,7 @@ export default { }); // Reset - compiler.hooks.done.tap('test', () => { + compiler.hooks.emit.tap('test', () => { process.env['DEBUG'] = DEBUG; process.env['NODE_ENV'] = NODE_ENV; }); @@ -75,7 +75,7 @@ export default { stage: -128, }, () => { const files = fs.readdirSync(compiler.outputPath); - expect(files).toContain('main.bundle.js'); + expect(files).not.toContain('main.bundle.js'); }); compiler.hooks.thisCompilation.tap('test', (compilation) => { diff --git a/packages/webpack/web-webpack-plugin/src/index.ts b/packages/webpack/web-webpack-plugin/src/index.ts index 4e5bcb957c..9493f3bf59 100644 --- a/packages/webpack/web-webpack-plugin/src/index.ts +++ b/packages/webpack/web-webpack-plugin/src/index.ts @@ -34,14 +34,13 @@ export class WebWebpackPlugin { const [name, content] = last(Object.entries(encodeData.manifest))!; if (!isDebug() && !isDev && !isRsdoctor()) { - hooks.beforeEmit.tap({ name: WebWebpackPlugin.name }, (args) => { + compiler.hooks.emit.tap({ name: WebWebpackPlugin.name }, () => { this.deleteDebuggingAssets(compilation, [ { name }, encodeData.lepusCode.root, ...encodeData.lepusCode.chunks, ...encodeData.css.chunks, ]); - return args; }); }