Skip to content
Prev Previous commit
Next Next commit
Attempt to fix interactivity-router
  • Loading branch information
sgomes committed Sep 18, 2024
commit 9a490fc99f743e9b1ab5fd036f4790df2359bf92
10 changes: 10 additions & 0 deletions packages/dependency-extraction-webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ class DependencyExtractionWebpackPlugin {
}

if ( externalRequest ) {
// Special case for modules.
// Since `@wordpress/polyfill` is a script and not a module, we need
// to exclude it from the list of externalised deps.
if (
this.useModules &&
externalRequest.includes( '@wordpress/polyfill' )
) {
return callback( null, '' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this attempting to ignore the module during when externalizing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct! I sneaked this change in today to see if it fixed the tests. If it works, I'll see if I can simplify it later 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like it would be necessary to be included somehow for @wordpress/interactivity-router.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I think this exposed the fact that while @wordpress/interactivity-router doesn't currently depend on the polyfills, it probably should, if we want it to work correctly in older browsers like Chrome 109. Although there isn't really a good mechanism to make that happen, as far as I know 🤔

}

this.externalizedDeps.add( request );

return callback( null, externalRequest );
Expand Down