Skip to content

Commit c090cfd

Browse files
committed
Merge remote-tracking branch 'origin/canary' into jrl-chunking-refactor-2
2 parents 418debd + 9d150b1 commit c090cfd

File tree

14 files changed

+237
-141
lines changed

14 files changed

+237
-141
lines changed

packages/next-swc/crates/core/src/react_server_components.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ impl<C: Comments> ReactServerComponents<C> {
344344
}
345345

346346
fn assert_server_graph(&self, imports: &[ModuleImports], module: &Module) {
347+
// If the
348+
if self.is_from_node_modules(&self.filepath) {
349+
return;
350+
}
347351
for import in imports {
348352
let source = import.source.0.clone();
349353
if self.invalid_server_imports.contains(&source) {
@@ -391,6 +395,9 @@ impl<C: Comments> ReactServerComponents<C> {
391395
}
392396

393397
fn assert_server_filename(&self, module: &Module) {
398+
if self.is_from_node_modules(&self.filepath) {
399+
return;
400+
}
394401
let is_error_file = Regex::new(r"[\\/]error\.(ts|js)x?$")
395402
.unwrap()
396403
.is_match(&self.filepath);
@@ -416,6 +423,9 @@ impl<C: Comments> ReactServerComponents<C> {
416423
}
417424

418425
fn assert_client_graph(&self, imports: &[ModuleImports]) {
426+
if self.is_from_node_modules(&self.filepath) {
427+
return;
428+
}
419429
for import in imports {
420430
let source = import.source.0.clone();
421431
if self.invalid_client_imports.contains(&source) {
@@ -432,6 +442,9 @@ impl<C: Comments> ReactServerComponents<C> {
432442
}
433443

434444
fn assert_invalid_api(&self, module: &Module, is_client_entry: bool) {
445+
if self.is_from_node_modules(&self.filepath) {
446+
return;
447+
}
435448
let is_layout_or_page = Regex::new(r"[\\/](page|layout)\.(ts|js)x?$")
436449
.unwrap()
437450
.is_match(&self.filepath);
@@ -562,6 +575,12 @@ impl<C: Comments> ReactServerComponents<C> {
562575
},
563576
);
564577
}
578+
579+
fn is_from_node_modules(&self, filepath: &str) -> bool {
580+
Regex::new(r"[\\/]node_modules[\\/]")
581+
.unwrap()
582+
.is_match(filepath)
583+
}
565584
}
566585

567586
pub fn server_components<C: Comments>(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"babel-packages","main":"./packages-bundle.js"}
1+
{"name":"babel-packages","main":"./packages-bundle.js"}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"name":"constants-browserify","main":"./constants.json"}
1+
{"name":"constants-browserify","main":"./constants.json"}

0 commit comments

Comments
 (0)