diff --git a/test/helpers/CopyPluginWithAssetInfo.js b/test/helpers/CopyPluginWithAssetInfo.js index 7a4f84e..ebe4847 100644 --- a/test/helpers/CopyPluginWithAssetInfo.js +++ b/test/helpers/CopyPluginWithAssetInfo.js @@ -1,8 +1,7 @@ -import { RawSource } from "webpack-sources"; - export default class CopyPluginWithAssetInfo { apply(compiler) { const plugin = { name: this.constructor.name }; + const { RawSource } = compiler.webpack.sources; compiler.hooks.thisCompilation.tap(plugin, (compilation) => { compilation.hooks.additionalAssets.tap(plugin, () => { diff --git a/test/helpers/ModifyExistingAsset.js b/test/helpers/ModifyExistingAsset.js index d17339c..08104ed 100644 --- a/test/helpers/ModifyExistingAsset.js +++ b/test/helpers/ModifyExistingAsset.js @@ -1,10 +1,3 @@ -import webpack from "webpack"; - -// webpack 5 exposes the sources property to ensure the right version of webpack-sources is used -const { ConcatSource } = - // eslint-disable-next-line global-require - webpack.sources || require("webpack-sources"); - export default class ExistingCommentsFile { constructor(options = {}) { this.options = options; @@ -12,6 +5,7 @@ export default class ExistingCommentsFile { apply(compiler) { const plugin = { name: this.constructor.name }; + const { ConcatSource } = compiler.webpack.sources; compiler.hooks.thisCompilation.tap(plugin, (compilation) => { compilation.hooks.additionalAssets.tap(plugin, () => {