Skip to content

Commit

Permalink
fix: dll manifest zod validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed Jan 24, 2025
1 parent 494aaa1 commit b56c8dd
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = [];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = typeof module.id;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import t from "dll/lib";

it("module id should be number type", () => {
expect(t).toBe("number");
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const rspack = require("@rspack/core");
const path = require("path");

const dllManifest = path.resolve(__dirname, "../../../js/config/dll/numeric-module-id/manifest.json");

/** @type {import("@rspack/core").Configuration[]} */
module.exports = [
{
name: "create-dll",
entry: "./lib.js",
output: {
filename: "lib-dll.js",
library: {
type: "commonjs2",
},
},
optimization: {
moduleIds: 'deterministic',
chunkIds: 'deterministic',
},
plugins: [
new rspack.DllPlugin({
path: dllManifest,
entryOnly: false,
}),
]
},
{
name: "use-dll",
dependencies: ["create-dll"],
entry: "./main.js",
plugins: [
function (compiler) {
compiler.hooks.beforeRun.tap('test', () => {
new rspack.DllReferencePlugin({
manifest: require(dllManifest),
sourceType: "commonjs2",
scope: "dll",
name: "./lib-dll.js",
}).apply(compiler)
})
}
]
}
]
2 changes: 1 addition & 1 deletion packages/rspack/etc/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@ export interface DllReferencePluginOptionsContent {
[k: string]: {
buildMeta?: JsBuildMeta;
exports?: string[] | true;
id?: string;
id?: string | number;
};
}

Expand Down
4 changes: 2 additions & 2 deletions packages/rspack/src/lib/DllReferencePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,14 @@ export interface DllReferencePluginOptionsContent {
/**
* Module ID.
*/
id?: string;
id?: string | number;
};
}

const dllReferencePluginOptionsContentItem = z.object({
buildMeta: z.custom<JsBuildMeta>().optional(),
exports: z.array(z.string()).or(z.literal(true)).optional(),
id: z.string().optional()
id: z.string().or(z.number()).optional()
});

const dllReferencePluginOptionsContent = z.record(
Expand Down

0 comments on commit b56c8dd

Please sign in to comment.