Skip to content

Commit

Permalink
chore(packages/rspack): add version check for binding
Browse files Browse the repository at this point in the history
  • Loading branch information
lippzhang committed Jul 11, 2023
1 parent 73c5e58 commit b3a3c33
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/rspack/src/rspack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { Callback } from "tapable";
import MultiStats from "./multiStats";
import assert from "assert";
import { asArray, isNil } from "./util";
import { bindingVersionCheck } from "./util/bindingVersionCheck";
import IgnoreWarningsPlugin from "./lib/ignoreWarningsPlugin";

function createMultiCompiler(options: MultiRspackOptions): MultiCompiler {
Expand Down Expand Up @@ -113,6 +114,7 @@ function rspack(
options: MultiRspackOptions | RspackOptions,
callback?: Callback<Error, MultiStats> | Callback<Error, Stats>
) {
bindingVersionCheck();
asArray(options).every(opts => {
validateConfig(opts);
});
Expand Down
18 changes: 18 additions & 0 deletions packages/rspack/src/util/bindingVersionCheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function getBindingVersion() {
return require("@rspack/binding/package.json").version;
}
function getRspackVersion() {
return require("../../package.json").version;
}
export const bindingVersionCheck = () => {
const coreVersion = getRspackVersion();
const bindingVersion = getBindingVersion();
let acoraaa = null;
if (coreVersion !== bindingVersion) {
throw new Error(
`The rspack core version ${JSON.stringify(
coreVersion
)} is not match to binding version ${JSON.stringify(bindingVersion)}`
);
}
};

0 comments on commit b3a3c33

Please sign in to comment.