Compare commits

...

2 Commits

Author SHA1 Message Date
Qingyu Wang 34b7f45a35
Merge 6382a6653b into 9f98d803c0 2025-10-05 11:29:28 +08:00
Qingyu Wang 6382a6653b fix: add `strict: true` to ContextModule 2025-03-14 21:53:45 +08:00
5 changed files with 56 additions and 0 deletions

View File

@ -437,6 +437,7 @@ class ContextModule extends Module {
defaultObject: "redirect-warn"
};
this.buildInfo = {
strict: true,
snapshot: undefined
};
this.dependencies.length = 0;

View File

@ -0,0 +1,41 @@
/** @type {import('fs')} */
const fs = __non_webpack_require__("fs");
it("should import", async () => {
const n = "a.js";
const { default: a1 } = await import(`./sub/${n}`);
expect(a1).toBe("a");
});
it("should startsWith use strict", async () => {
const source = fs.readFileSync(__filename, "utf-8");
expect(source.length).not.toBe(0);
expect(source.startsWith('/******/ "use strict"')).toBeTruthy();
});
it("should have all strict modules", () => {
const source = fs.readFileSync(__filename, "utf-8");
expect(source.length).not.toBe(0);
expect(source).not.toContain(
[
"This",
"entry",
"needs",
"to",
"be",
"wrapped",
"in",
"an",
"IIFE",
"because",
"it",
"needs",
"to",
"be",
"in",
"strict",
"mode."
].join(" ")
);
});

View File

@ -0,0 +1,7 @@
module.exports = options => {
if (options.cache && options.cache.type === "filesystem") {
return [/Pack got invalid because of write to/];
}
return [];
};

View File

@ -0,0 +1 @@
export default "a"

View File

@ -0,0 +1,6 @@
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: "./index.mjs",
output: { iife: false },
optimization: { concatenateModules: true }
};