Skip to content

Commit

Permalink
Dependency Extraction Webpack Plugin: Fix script module import field (#…
Browse files Browse the repository at this point in the history
…58770)

Script modules shipped with the "import" field instead of "type." Update accordingly.

Co-authored-by: sirreal <[email protected]>
Co-authored-by: c4rl0sbr4v0 <[email protected]>
Co-authored-by: luisherranz <[email protected]>
  • Loading branch information
4 people authored Feb 7, 2024
1 parent 27dc690 commit de2a8a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/dependency-extraction-webpack-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Bug fixes

- Fix import type field in script module asset files ([#58770](https://github.com/WordPress/gutenberg/pull/58770)).

## 5.1.0 (2024-01-24)

## 5.0.0 (2024-01-10)
Expand Down
2 changes: 1 addition & 1 deletion packages/dependency-extraction-webpack-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ function requestToExternalModule( request ) {
return 'myModule';
}

// If the script module ID in source is the same as the external script module, `true` can be returned.
// If the script module ID in source is the same as the external script module, `true` can be returned.
return request === 'external-module-id-no-change-required';
}

Expand Down
2 changes: 1 addition & 1 deletion packages/dependency-extraction-webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class DependencyExtractionWebpackPlugin {
...Array.from( chunkStaticDeps ).sort(),
...Array.from( chunkDynamicDeps )
.sort()
.map( ( id ) => ( { id, type: 'dynamic' } ) ),
.map( ( id ) => ( { id, import: 'dynamic' } ) ),
],
version: contentHash,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dependency-g
`;

exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dynamic-dependency-graph\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
"<?php return array('dependencies' => array(array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => '293aebad4ca761cf396f', 'type' => 'module');
"<?php return array('dependencies' => array(array('id' => '@wordpress/interactivity', 'import' => 'dynamic')), 'version' => '293aebad4ca761cf396f', 'type' => 'module');
"
`;

Expand All @@ -56,7 +56,7 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dynamic-depe
`;

exports[`DependencyExtractionWebpackPlugin modules Webpack \`dynamic-import\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
"<?php return array('dependencies' => array(array('id' => '@wordpress/blob', 'type' => 'dynamic')), 'version' => '4f59b7847b70a07b2710', 'type' => 'module');
"<?php return array('dependencies' => array(array('id' => '@wordpress/blob', 'import' => 'dynamic')), 'version' => '4f59b7847b70a07b2710', 'type' => 'module');
"
`;

Expand Down Expand Up @@ -306,7 +306,7 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress\` should
`;

exports[`DependencyExtractionWebpackPlugin modules Webpack \`wordpress-interactivity\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
"<?php return array('dependencies' => array('lodash', array('id' => '@wordpress/interactivity', 'type' => 'dynamic')), 'version' => 'fcc07ce68574cdc2a6a5', 'type' => 'module');
"<?php return array('dependencies' => array('lodash', array('id' => '@wordpress/interactivity', 'import' => 'dynamic')), 'version' => 'fcc07ce68574cdc2a6a5', 'type' => 'module');
"
`;

Expand Down

0 comments on commit de2a8a7

Please sign in to comment.