Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEWP: Handle cyclical module dependencies #65291

Merged
merged 11 commits into from
Sep 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-dependency-g
]
`;

exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-deps\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
"<?php return array('dependencies' => array(), 'version' => '659ee86bae9fb389a844', 'type' => 'module');
"
`;

exports[`DependencyExtractionWebpackPlugin modules Webpack \`cyclic-deps\` should produce expected output: External modules should match snapshot 1`] = `[]`;

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', 'import' => 'dynamic')), 'version' => '293aebad4ca761cf396f', 'type' => 'module');
"
Expand Down Expand Up @@ -394,6 +401,13 @@ exports[`DependencyExtractionWebpackPlugin scripts Webpack \`cyclic-dependency-g
]
`;

exports[`DependencyExtractionWebpackPlugin scripts Webpack \`cyclic-deps\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
"<?php return array('dependencies' => array(), 'version' => '174bed1cc91890a295ff');
"
`;

exports[`DependencyExtractionWebpackPlugin scripts Webpack \`cyclic-deps\` should produce expected output: External modules should match snapshot 1`] = `[]`;

exports[`DependencyExtractionWebpackPlugin scripts Webpack \`cyclic-dynamic-dependency-graph\` should produce expected output: Asset file 'main.asset.php' should match snapshot 1`] = `
"<?php return array('dependencies' => array('wp-interactivity'), 'version' => 'ac0e2f1bcd3a6a0e7aff');
"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Internal dependencies
*/
import { someFunction } from '.';

someFunction();

export const a = 'test';
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Internal dependencies
*/
import { a } from './a';

export const someFunction = () => {
return a;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Internal dependencies
*/
const DependencyExtractionWebpackPlugin = require( '../../..' );

module.exports = {
plugins: [ new DependencyExtractionWebpackPlugin() ],
Copy link
Member

Choose a reason for hiding this comment

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

I think there will need to be an external module listed here that's used in one or both of the file and we can probably disable defaults as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Jon! Yeah, I've added it now!

I think I didn't realize this before: The problem that I found only affects the externalized modules. Do you think that's correct?

};
Loading