Skip to content
Next Next commit
Add tests for cyclical dependencies
  • Loading branch information
michalczaplinski committed Sep 12, 2024
commit edb8889dce54e31e8aadd9259bd39031bd1c493b
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?

};