Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 62 additions & 1 deletion crates/rspack_core/src/chunk_graph/chunk_graph_chunk.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! There are methods whose verb is `ChunkGraphChunk`

use std::{borrow::Borrow, fmt, sync::Arc};
use std::{borrow::Borrow, collections::VecDeque, fmt, sync::Arc};

use hashlink::LinkedHashMap;
use indexmap::IndexSet;
Expand Down Expand Up @@ -808,6 +808,67 @@ impl ChunkGraph {
false
}

pub fn get_runtime_chunk_dependent_chunks_iterable(
&self,
chunk_ukey: &ChunkUkey,
chunk_by_ukey: &ChunkByUkey,
chunk_group_by_ukey: &ChunkGroupByUkey,
) -> impl Iterator<Item = ChunkUkey> {
let mut set = IndexSet::new();
let mut entrypoints = IndexSet::new();

let chunk = chunk_by_ukey.expect_get(chunk_ukey);

for chunk_group_key in chunk.get_sorted_groups_iter(chunk_group_by_ukey) {
let chunk_group = chunk_group_by_ukey.expect_get(chunk_group_key);
if chunk_group.kind.is_entrypoint() {
let mut queue = VecDeque::new();
queue.push_back(chunk_group);
while let Some(current) = queue.pop_front() {
entrypoints.insert(current.ukey);
let mut has_children_entrypoint = false;
for child in current.children_iterable() {
let child_chunk_group = chunk_group_by_ukey.expect_get(child);
if child_chunk_group.kind.is_entrypoint() {
has_children_entrypoint = true;
queue.push_back(child_chunk_group);
}
}

if has_children_entrypoint {
let entrypoint_chunk_ukey = current.get_entrypoint_chunk();
let entrypoint_chunk = chunk_by_ukey.expect_get(&entrypoint_chunk_ukey);
if entrypoint_chunk_ukey != *chunk_ukey
&& !entrypoint_chunk.has_runtime(chunk_group_by_ukey)
{
set.insert(entrypoint_chunk_ukey);
}
}
}
}
}

for entrypoint_ukey in entrypoints {
let entrypoint = chunk_group_by_ukey.expect_get(&entrypoint_ukey);
let entrypoint_chunk_ukey = entrypoint.get_entrypoint_chunk();
let chunk_graph_chunk = self.expect_chunk_graph_chunk(&entrypoint_chunk_ukey);
for chunk_group_ukey in chunk_graph_chunk.entry_modules.values() {
let chunk_group = chunk_group_by_ukey.expect_get(chunk_group_ukey);
for c in chunk_group.chunks.iter() {
let chunk = chunk_by_ukey.expect_get(c);
if c != chunk_ukey
&& c != &entrypoint_chunk_ukey
&& !chunk.has_runtime(chunk_group_by_ukey)
{
set.insert(*c);
}
}
}
}

set.into_iter()
}

pub fn get_chunk_entry_dependent_chunks_iterable(
&self,
chunk_ukey: &ChunkUkey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,14 @@ impl RuntimeModule for GetChunkFilenameRuntimeModule {
chunk.get_all_referenced_chunks(&compilation.chunk_group_by_ukey)
} else {
let mut chunks = chunk.get_all_async_chunks(&compilation.chunk_group_by_ukey);

if ChunkGraph::get_tree_runtime_requirements(compilation, &chunk.ukey())
.contains(RuntimeGlobals::ENSURE_CHUNK_INCLUDE_ENTRIES)
{
chunks.extend(
compilation
.chunk_graph
.get_chunk_entry_dependent_chunks_iterable(
.get_runtime_chunk_dependent_chunks_iterable(
&chunk.ukey(),
&compilation.chunk_by_ukey,
&compilation.chunk_group_by_ukey,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import RESOURCE_SVG from "./img.svg";
import RESOURCE_PNG from "./img.png?inline";
import RESOURCE_PNG_2 from "./img.png";

// FIXME: We should align this with target `Node`, currently the `__webpack_require__.p` is not defined for the `Node`.
const RESOURCE_REGEX = /\.(svg|png)/;

it("should use the last matching type if it is matched with multiple module rules", () => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = (options) => {
// We will pre-compile twice, and the module cache will result in no warnings in the stats during the third compilation
return [];
}
return [[/__non_webpack_require__ is only allowed in target node/]];
return [
// DIFF: rspack does not throw warning for __non_webpack_require__
// [/__non_webpack_require__ is only allowed in target node/]
];
};
1 change: 0 additions & 1 deletion tests/rspack-test/configCases/module/parser/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import RESOURCE_PNG from "./logo.png?should-be-externalized";
import INLINE_PNG from "./logo.png?should-be-inlined";

// FIXME: We should align this with target `Node`, currently the `__webpack_require__.p` is not defined for the `Node`.
const RESOURCE_REGEX = /\.png/;

it("should override the `module.parser.assets.dataUrlCondition.maxSize` if `module.rule.parser.dataUrlCondition.maxSize` is configured", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
it("should loader the correctly query", () => {
expect(require("./sub/a")).toBe("?query=a");
// FIXME: should return `query` and `fragment` in rust side
// expect(require('./sub/b')).toBe('?query=alias')
// FIXME: should return `query` and `fragment` in rust side
// expect(require('./sub/c')).toBe('?query=alias')
expect(require('./sub/b')).toBe('?query=alias')
expect(require('./sub/c')).toBe('?query=c')
expect(require("./sub/d")).toBe("?query=d");
expect(require("./sub/e")).toBe("?query=options-e");
expect(require("./sub/f")).toStrictEqual({
Expand Down
1 change: 0 additions & 1 deletion tests/rspack-test/configCases/node/issue-18409-2/common.js

This file was deleted.

8 changes: 0 additions & 8 deletions tests/rspack-test/configCases/node/issue-18409-2/index.js

This file was deleted.

33 changes: 0 additions & 33 deletions tests/rspack-test/configCases/node/issue-18409-2/rspack.config.js

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading