-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: emit warning for circular dependency (#839)
Co-authored-by: Yunfei <i.heyunfei@gmail.com>
- Loading branch information
1 parent
117d2c4
commit 6d64a64
Showing
17 changed files
with
161 additions
and
7 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
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
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
15 changes: 15 additions & 0 deletions
15
crates/rolldown/tests/fixtures/circular_depency/_config.json
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,15 @@ | ||
{ | ||
"config": { | ||
"input": [ | ||
{ | ||
"name": "entry", | ||
"import": "entry.js" | ||
}, | ||
{ | ||
"name": "main", | ||
"import": "main.js" | ||
} | ||
] | ||
}, | ||
"expectExecuted": false | ||
} |
36 changes: 36 additions & 0 deletions
36
crates/rolldown/tests/fixtures/circular_depency/artifacts.snap
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,36 @@ | ||
--- | ||
source: crates/rolldown/tests/common/case.rs | ||
expression: content | ||
input_file: crates/rolldown/tests/fixtures/circular_depency | ||
--- | ||
# warnings | ||
|
||
## CIRCULAR_DEPENDENCY | ||
|
||
```text | ||
[CIRCULAR_DEPENDENCY] Warning: Circular dependency: tests/fixtures/circular_depency/foo.js -> tests/fixtures/circular_depency/main.js -> tests/fixtures/circular_depency/foo.js. | ||
``` | ||
## CIRCULAR_DEPENDENCY | ||
|
||
```text | ||
[CIRCULAR_DEPENDENCY] Warning: Circular dependency: tests/fixtures/circular_depency/entry.js -> tests/fixtures/circular_depency/foo.js -> tests/fixtures/circular_depency/entry.js. | ||
``` | ||
# Assets | ||
|
||
## entry.mjs | ||
|
||
```js | ||
import "./main_js.mjs"; | ||
``` | ||
## main.mjs | ||
|
||
```js | ||
import "./main_js.mjs"; | ||
``` | ||
## main_js.mjs | ||
|
||
```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 @@ | ||
import './foo' |
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,2 @@ | ||
import './main' | ||
import './entry' |
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 @@ | ||
import './foo' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use sugar_path::SugarPath; | ||
|
||
use super::BuildEvent; | ||
use crate::{event_kind::EventKind, PathExt}; | ||
|
||
#[derive(Debug)] | ||
pub struct CircularDependency { | ||
pub paths: Vec<String>, | ||
} | ||
|
||
impl CircularDependency { | ||
fn relative_paths(&self) -> Vec<String> { | ||
self.paths.iter().map(|p| p.as_path().relative_display().into_owned()).collect::<Vec<_>>() | ||
} | ||
} | ||
|
||
impl BuildEvent for CircularDependency { | ||
fn kind(&self) -> EventKind { | ||
EventKind::CircularDependency | ||
} | ||
fn code(&self) -> &'static str { | ||
"CIRCULAR_DEPENDENCY" | ||
} | ||
|
||
fn message(&self) -> String { | ||
format!("Circular dependency: {}.", self.relative_paths().join(" -> ")) | ||
} | ||
} |
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