Skip to content

Commit

Permalink
Improved finding asset modules
Browse files Browse the repository at this point in the history
  • Loading branch information
webdeveric committed Dec 28, 2020
1 parent 32a8d06 commit 6b28320
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/WebpackAssetsManifest.js
Expand Up @@ -488,7 +488,6 @@ class WebpackAssetsManifest
const info = Object.assign(
{
sourceFilename: path.relative( compilation.compiler.context, module.userRequest ),
userRequest: module.userRequest,
},
assetInfo,
);
Expand Down Expand Up @@ -730,6 +729,14 @@ class WebpackAssetsManifest
PLUGIN_NAME,
this.handleNormalModuleLoader.bind(this, compilation),
);

compilation.hooks.processAssets.tap(
{
name: PLUGIN_NAME,
stage: Compilation.PROCESS_ASSETS_STAGE_REPORT,
},
this.handleProcessAssetsAnalyse.bind(this, compilation),
);
}

/**
Expand All @@ -739,14 +746,6 @@ class WebpackAssetsManifest
*/
handleThisCompilation(compilation)
{
compilation.hooks.processAssets.tap(
{
name: PLUGIN_NAME,
stage: Compilation.PROCESS_ASSETS_STAGE_ANALYSE,
},
this.handleProcessAssetsAnalyse.bind(this, compilation),
);

if ( this.options.integrity ) {
compilation.hooks.afterProcessAssets.tap(
PLUGIN_NAME,
Expand Down
2 changes: 2 additions & 0 deletions test/WebpackAssetsManifest-test.js
Expand Up @@ -1217,6 +1217,8 @@ describe('WebpackAssetsManifest', function() {
it('asset names point to the same file due to module.rules config', () => {
const { assets } = manifest.toJSON();

expect( assets[ 'images/Ginger.asset.jpg' ], 'assets: images/Ginger.asset.jpg is undefined' ).to.not.be.undefined;
expect( assets[ 'images/Ginger.loader.jpg' ], 'assets: images/Ginger.loader.jpg is undefined' ).to.not.be.undefined;
expect( assets[ 'images/Ginger.asset.jpg' ] ).to.deep.equal( assets[ 'images/Ginger.loader.jpg' ] );
});

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/complex.mjs
@@ -1,5 +1,5 @@
import('./hello.js').then( module => console.log( module ) );
import(/* webpackChunkName: "load-styles" */ './load-styles.js').then( module => console.log( module ) );
import(/* webpackChunkName: "load-styles" */ './load-styles.mjs').then( module => console.log( module ) );
import(/* webpackPrefetch: true */ './prefetch.js').then( module => console.log( module ) );
import(/* webpackPreload: true */ './preload.js').then( module => console.log( module ) );

Expand Down

0 comments on commit 6b28320

Please sign in to comment.