Skip to content

Commit

Permalink
feat: update the codes of getting Compiler's rspack
Browse files Browse the repository at this point in the history
  • Loading branch information
xfsnowind committed Sep 15, 2024
1 parent 1f99c02 commit c2911af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 5 additions & 1 deletion dist/CypressCTRspackPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ class CypressCTRspackPlugin {
*/
this.addCompilationHooks = (compilation) => {
this.compilation = compilation;
const loader = this.compilation.compiler.rspack.NormalModule.getCompilationHooks(compilation).loader;
// still use legacy `webpack` here since in version 0.x.x does not have rspack
const compiler = ('rspack' in this.compilation.compiler
? this.compilation.compiler.rspack
: this.compilation.compiler.webpack);
const loader = compiler.NormalModule.getCompilationHooks(compilation).loader;
loader.tap('CypressCTPlugin', this.addLoaderContext);
};
this.files = options.files;
Expand Down
10 changes: 8 additions & 2 deletions src/CypressCTRspackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,14 @@ export class CypressCTRspackPlugin {
private addCompilationHooks = (compilation: RspackCompilation) => {
this.compilation = compilation

const loader =
this.compilation.compiler.rspack.NormalModule.getCompilationHooks(compilation).loader
// still use legacy `webpack` here since in version 0.x.x does not have rspack
const compiler = (
'rspack' in this.compilation.compiler
? this.compilation.compiler.rspack
: (this.compilation.compiler as Compiler).webpack
) as Compiler['webpack']

const loader = compiler.NormalModule.getCompilationHooks(compilation).loader

loader.tap('CypressCTPlugin', this.addLoaderContext)
}
Expand Down

0 comments on commit c2911af

Please sign in to comment.