-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEWP: Handle cyclical module dependencies (#65291)
* Add tests for cyclical dependencies * Add the externals and make the test fail * Add cycle detection in dependency path checking Enhanced the dependency resolution logic to detect cycles in the module graph, preventing infinite loops during static dependency path checks. Introduced a Set to track visited blocks and avoid revisiting them. * Revert changes * Propose static WeakSet/WeakMap implementation. * Add CHANGELOG entry * Remove redundant plugin config in test * Revert "Remove redundant plugin config in test" This reverts commit b5e33db. * Remove redundant plugin config in test * Updated the snapshot files --------- Co-authored-by: michalczaplinski <czapla@git.wordpress.org> Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
- Loading branch information
1 parent
cbcc28c
commit f0cd217
Showing
6 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/dependency-extraction-webpack-plugin/test/fixtures/cyclic-external-deps/a.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { someFunction } from '.'; | ||
|
||
someFunction(); | ||
|
||
export const a = 'test'; |
18 changes: 18 additions & 0 deletions
18
packages/dependency-extraction-webpack-plugin/test/fixtures/cyclic-external-deps/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { a } from './a'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { store } from '@wordpress/interactivity'; | ||
|
||
export const someFunction = () => { | ||
store( 'test', { | ||
state: { | ||
a, | ||
}, | ||
} ); | ||
return a; | ||
}; |
8 changes: 8 additions & 0 deletions
8
...dependency-extraction-webpack-plugin/test/fixtures/cyclic-external-deps/webpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
const DependencyExtractionWebpackPlugin = require( '../../..' ); | ||
|
||
module.exports = { | ||
plugins: [ new DependencyExtractionWebpackPlugin() ], | ||
}; |