Skip to content

Commit

Permalink
fix: avoid unnamed module ids
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed Dec 5, 2024
1 parent 29b77a1 commit 4656d68
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/rspack_ids/src/named_module_ids_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use rustc_hash::{FxHashMap, FxHashSet};

use crate::id_helpers::{get_long_module_name, get_short_module_name};

pub fn assign_named_module_ids(
#[tracing::instrument(skip_all)]
fn assign_named_module_ids(
modules: IdentifierSet,
context: &str,
module_graph: &ModuleGraph,
Expand All @@ -34,6 +35,7 @@ pub fn assign_named_module_ids(
.collect();
let mut name_to_items: HashMap<String, IdentifierIndexSet> = HashMap::default();
let mut invalid_and_repeat_names: FxHashSet<String> = Default::default();
invalid_and_repeat_names.insert(String::from(""));
for (item, name) in item_name_pair {
let items = name_to_items.entry(name.clone()).or_default();
items.insert(item);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import fs from "fs/promises";
import path from "path";

it("should compile", () => {
expect(true).toBe(true);
});

it("should have correct log when incremental enabled", async () => {
const statsString = await fs.readFile(path.resolve(__dirname, `stats.${WATCH_STEP}.txt`), 'utf-8');
const incrementalLog = /LOG from rspack\.incremental\.moduleIds[\s\S]*?LOG/.exec(statsString);
if (incrementalLog) {
const content = incrementalLog[0];
expect(content.includes("with 0 unnamed modules")).toBe(true);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import fs from "fs/promises";
import path from "path";

it("should have correct ignored value", () => {
const ignored = require("ignored");
expect(ignored).toEqual({});
});

it("should have correct log when incremental enabled", async () => {
const statsString = await fs.readFile(path.resolve(__dirname, `stats.${WATCH_STEP}.txt`), 'utf-8');
const incrementalLog = /LOG from rspack\.incremental\.moduleIds[\s\S]*?LOG/.exec(statsString);
if (incrementalLog) {
const content = incrementalLog[0];
expect(content.includes("with 0 unnamed modules")).toBe(true);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('@rspack/core').Configuration} */
module.exports = {
resolve: {
alias: {
"ignored": false,
},
}
};

0 comments on commit 4656d68

Please sign in to comment.