Skip to content

Commit

Permalink
refactor: separate node and browser build commands
Browse files Browse the repository at this point in the history
  • Loading branch information
lsndr committed Sep 29, 2024
1 parent cacbfda commit b2e8b2c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
7 changes: 7 additions & 0 deletions browser.replacer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports.default = ({ orig, file }) => {
if (!file.includes('dist/browser') || orig !== 'require("@lib")') {
return orig;
}

return 'require("@rrule-rust/lib-wasm32-wasi")';
};
7 changes: 7 additions & 0 deletions node.replacer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports.default = ({ orig, file }) => {
if (!file.includes('dist/node') || orig !== 'require("@lib")') {
return 'require("./lib")';
}

return 'require("./lib")';
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@
"prebuild": "rimraf ./dist && npm run build:lib",
"prebuild:node": "rimraf ./dist/node",
"build:node": "tsc -p ./tsconfig.build.json --outDir dist/node",
"postbuild:node": "cpy ./src/lib/* ./dist/node/lib --flat && tsc-alias -p tsconfig.replacer.json --replacer ./node.replacer.js",
"prebuild:browser": "rimraf ./dist/browser",
"build:browser": "tsc -p ./tsconfig.build.json --outDir dist/browser",
"postbuild:browser": "cpy ./src/lib/* ./dist/browser/lib --flat && tsc-alias -p tsconfig.replacer.json --replacer ./browser.replacer.js",
"build": "npm run build:node && npm run build:browser",
"postbuild": "cpy ./src/lib/* ./dist/*/lib --flat && tsc-alias -p tsconfig.replacer.json --replacer ./replacer.js",
"prepublishOnly": "napi prepublish -t npm",
"test": "cross-env TZ=Europe/Moscow jest --testPathIgnorePatterns=\\.e2e\\.spec\\.ts",
"test:e2e": "jest --testMatch='**/*.e2e.spec.ts' --runInBand",
Expand Down
9 changes: 0 additions & 9 deletions replacer.js

This file was deleted.

0 comments on commit b2e8b2c

Please sign in to comment.