Skip to content

Commit

Permalink
fix: add strict: true to RawModule (#6755)
Browse files Browse the repository at this point in the history
  • Loading branch information
colinaaa committed Jun 7, 2024
1 parent 0d00059 commit 34bb9ea
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/rspack_core/src/raw_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl Module for RawModule {
build_info: BuildInfo {
hash: Some(hasher.digest(&build_context.compiler_options.output.hash_digest)),
cacheable: true,
strict: true,
..Default::default()
},
dependencies: vec![],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "ignored";
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('fs')} */
const fs = __non_webpack_require__("fs");

import ignored from "./ignored-module";

it("should startsWith use strict", function () {
const source = fs.readFileSync(__filename, "utf-8");
expect(source.length).not.toBe(0);
expect(ignored).toEqual({});
expect(
source.startsWith('"use strict"') || source.startsWith("'use strict'")
).toBeTruthy();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
entry: "./index.mjs",
resolve: {
alias: {
"./ignored-module": false
}
},
output: {
iife: false
},
optimization: {
concatenateModules: true
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "ignored";
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @type {import('fs')} */
const fs = __non_webpack_require__("fs");

import ignored from "./ignored-module";

it("should startsWith use strict", function () {
const source = fs.readFileSync(__filename, "utf-8");
expect(source.length).not.toBe(0);
expect(ignored).toEqual({});
expect(
source.startsWith('"use strict"') || source.startsWith("'use strict'")
).toBeTruthy();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import("@rspack/core").Configuration} */
module.exports = {
entry: "./index.mjs",
resolve: {
alias: {
"./ignored-module": false
}
},
output: {
iife: false
}
};

2 comments on commit 34bb9ea

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-06-07 c0c0fd3) Current Change
10000_development-mode + exec 2.24 s ± 15 ms 2.24 s ± 31 ms +0.13 %
10000_development-mode_hmr + exec 739 ms ± 5.1 ms 737 ms ± 8.4 ms -0.19 %
10000_production-mode + exec 2.58 s ± 28 ms 2.59 s ± 34 ms +0.59 %
arco-pro_development-mode + exec 1.94 s ± 84 ms 1.94 s ± 62 ms -0.25 %
arco-pro_development-mode_hmr + exec 441 ms ± 2 ms 442 ms ± 1.6 ms +0.15 %
arco-pro_production-mode + exec 3.51 s ± 72 ms 3.53 s ± 74 ms +0.49 %
threejs_development-mode_10x + exec 1.4 s ± 8.4 ms 1.41 s ± 11 ms +0.73 %
threejs_development-mode_10x_hmr + exec 808 ms ± 7.4 ms 804 ms ± 5.5 ms -0.39 %
threejs_production-mode_10x + exec 4.71 s ± 35 ms 4.73 s ± 26 ms +0.50 %

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ran ecosystem CI: Open

suite result
modernjs ❌ failure
_selftest ✅ success
nx ✅ success
rspress ❌ failure
rsbuild ❌ failure
compat ✅ success
examples ✅ success

Please sign in to comment.