diff --git a/packages/core/package.json b/packages/core/package.json index 8e765dd0f..e2530ad37 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,17 +9,20 @@ "require": "./lib/cjs/index.js" }, "./*": { - "types": "./lib/types/*" + "types": "./lib/types/*", + "import": "./lib/esm/*", + "require": "./lib/cjs/*" } }, "files": [ - "./lib" + "./lib", + "package.json" ], "scripts": { "prebuild": "rimraf lib", - "build": "pnpm lmdk-build --entryPoints index.ts --tsconfig tsconfig.prod.json", + "build": "pnpm lmdk-build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"", - "watch:builds": "pnpm lmdk-watch --entryPoints index.ts --tsconfig tsconfig.prod.json", + "watch:builds": "pnpm lmdk-watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"", "lint": "eslint", "lint:fix": "pnpm lint --fix", diff --git a/packages/signer/context-module/package.json b/packages/signer/context-module/package.json index 4bc2b4b05..fafa1d5a1 100644 --- a/packages/signer/context-module/package.json +++ b/packages/signer/context-module/package.json @@ -9,7 +9,9 @@ "require": "./lib/cjs/index.js" }, "./*": { - "types": "./lib/types/*" + "types": "./lib/types/*", + "import": "./lib/esm/*", + "require": "./lib/cjs/*" } }, "files": [ @@ -17,9 +19,9 @@ ], "scripts": { "prebuild": "rimraf lib", - "build": "pnpm lmdk-build --entryPoints index.ts --tsconfig tsconfig.prod.json", + "build": "pnpm lmdk-build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"", - "watch:builds": "pnpm lmdk-watch --entryPoints index.ts --tsconfig tsconfig.prod.json", + "watch:builds": "pnpm lmdk-watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"", "lint": "eslint", "lint:fix": "pnpm lint --fix", diff --git a/packages/signer/keyring-btc/package.json b/packages/signer/keyring-btc/package.json index 96096e061..445ab859a 100644 --- a/packages/signer/keyring-btc/package.json +++ b/packages/signer/keyring-btc/package.json @@ -12,7 +12,9 @@ "require": "./lib/cjs/index.js" }, "./*": { - "types": "./lib/types/*" + "types": "./lib/types/*", + "import": "./lib/esm/*", + "require": "./lib/cjs/*" } }, "files": [ @@ -20,9 +22,9 @@ ], "scripts": { "prebuild": "rimraf lib", - "build": "pnpm lmdk-build --entryPoints src/index.ts --tsconfig tsconfig.prod.json", + "build": "pnpm lmdk-build --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"", - "watch:builds": "pnpm lmdk-watch --entryPoints src/index.ts --tsconfig tsconfig.prod.json", + "watch:builds": "pnpm lmdk-watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"", "lint": "eslint", "lint:fix": "pnpm lint --fix", diff --git a/packages/signer/keyring-eth/package.json b/packages/signer/keyring-eth/package.json index dba0987e7..06b59f248 100644 --- a/packages/signer/keyring-eth/package.json +++ b/packages/signer/keyring-eth/package.json @@ -10,7 +10,9 @@ "require": "./lib/cjs/index.js" }, "./*": { - "types": "./lib/types/*" + "types": "./lib/types/*", + "import": "./lib/esm/*", + "require": "./lib/cjs/*" } }, "files": [ @@ -18,9 +20,9 @@ ], "scripts": { "prebuild": "rimraf lib", - "build": "pnpm lmdk-build --entryPoints src/index.ts --tsconfig tsconfig.prod.json", + "build": "pnpm lmdk-build --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"", - "watch:builds": "pnpm lmdk-watch --entryPoints src/index.ts --tsconfig tsconfig.prod.json", + "watch:builds": "pnpm lmdk-watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"", "lint": "eslint", "lint:fix": "pnpm lint --fix", diff --git a/packages/tools/esbuild-tools/build.mjs b/packages/tools/esbuild-tools/build.mjs index 0e6248892..59d900f2a 100755 --- a/packages/tools/esbuild-tools/build.mjs +++ b/packages/tools/esbuild-tools/build.mjs @@ -3,10 +3,11 @@ import "zx/globals"; import esbuild from "esbuild"; import { nodeExternalsPlugin } from "esbuild-node-externals"; +import { replaceTscAliasPaths } from "tsc-alias"; const config = { - minify: false, - bundle: true, + minify: true, + bundle: false, treeShaking: true, sourcemap: true, color: true, @@ -26,24 +27,33 @@ if (!tsconfig) { console.error(chalk.red("TSConfig file is required")); process.exit(1); } + const entryPointsArray = entryPoints.includes(",") ? entryPoints.split(",") : [entryPoints]; const buildBrowser = async () => { console.log(chalk.blue("Building browser bundle...")); - return esbuild.build({ + await esbuild.build({ ...config, entryPoints: entryPointsArray, outdir: "lib/esm", format: "esm", platform: "browser", }); + + await $`cp package.json lib/esm/package.json`; + + await replaceTscAliasPaths({ + configFile: tsconfig, + outDir: "lib/esm", + watch: false, + }); }; const buildNode = async () => { console.log(chalk.blue("Building node bundle...")); - return esbuild.build({ + await esbuild.build({ ...config, entryPoints: entryPointsArray, outdir: "lib/cjs", @@ -51,6 +61,14 @@ const buildNode = async () => { platform: "node", plugins: [nodeExternalsPlugin()], }); + + await $`cp package.json lib/cjs/package.json`; + + await replaceTscAliasPaths({ + configFile: tsconfig, + outDir: "lib/cjs", + watch: false, + }); }; const buildTypes = async () => { diff --git a/packages/tools/esbuild-tools/watch.mjs b/packages/tools/esbuild-tools/watch.mjs index 3cf79de96..8b05d9c1a 100755 --- a/packages/tools/esbuild-tools/watch.mjs +++ b/packages/tools/esbuild-tools/watch.mjs @@ -1,11 +1,12 @@ #!/usr/bin/env zx import esbuild from "esbuild"; +import { replaceTscAliasPaths } from "tsc-alias"; const config = { entryPoints: ["index.ts"], minify: true, - bundle: true, + bundle: false, treeShaking: true, sourcemap: true, color: true, @@ -25,30 +26,51 @@ if (!tsconfig) { console.error(chalk.red("TSConfig file is required")); process.exit(1); } + const entryPointsArray = entryPoints.includes(",") ? entryPoints.split(",") : [entryPoints]; const getBrowserContext = async () => { console.log(chalk.blue("Watching browser bundle...")); - return esbuild.context({ + const result = await esbuild.context({ ...config, entryPoints: entryPointsArray, outdir: "lib/esm", format: "esm", platform: "browser", }); + + await $`cp package.json lib/esm/package.json`; + + await replaceTscAliasPaths({ + configFile: tsconfig, + outDir: "lib/esm", + watch: false, + }); + + return result; }; const getNodeContext = async () => { console.log(chalk.blue("Watching node bundle...")); - return esbuild.context({ + const res = await esbuild.context({ ...config, entryPoints: entryPointsArray, outdir: "lib/cjs", format: "cjs", platform: "node", }); + + await $`cp package.json lib/cjs/package.json`; + + await replaceTscAliasPaths({ + configFile: tsconfig, + outDir: "lib/cjs", + watch: false, + }); + + return res; }; const watch = async () => { diff --git a/packages/transport-mock/package.json b/packages/transport-mock/package.json index 6fadfe4ae..1e36bfca1 100644 --- a/packages/transport-mock/package.json +++ b/packages/transport-mock/package.json @@ -11,7 +11,9 @@ "require": "./lib/cjs/index.js" }, "./*": { - "types": "./lib/types/*" + "types": "./lib/types/*", + "import": "./lib/esm/*", + "require": "./lib/cjs/*" } }, "files": [ @@ -19,9 +21,9 @@ ], "scripts": { "prebuild": "rimraf lib", - "build": "pnpm lmdk-build --entryPoints index.ts --tsconfig tsconfig.prod.json", + "build": "pnpm lmdk-build --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"", - "watch:builds": "pnpm lmdk-watch --entryPoints index.ts --tsconfig tsconfig.prod.json", + "watch:builds": "pnpm lmdk-watch --entryPoints index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"", "lint": "eslint", "lint:fix": "pnpm lint --fix", diff --git a/packages/trusted-apps/package.json b/packages/trusted-apps/package.json index 16e835c3b..d60f9070f 100644 --- a/packages/trusted-apps/package.json +++ b/packages/trusted-apps/package.json @@ -10,7 +10,9 @@ "require": "./lib/cjs/index.js" }, "./*": { - "types": "./lib/types/*" + "types": "./lib/types/*", + "import": "./lib/esm/*", + "require": "./lib/cjs/*" } }, "files": [ @@ -18,9 +20,9 @@ ], "scripts": { "prebuild": "rimraf lib", - "build": "pnpm lmdk-build --entryPoints src/index.ts --tsconfig tsconfig.prod.json", + "build": "pnpm lmdk-build --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"", - "watch:builds": "pnpm lmdk-watch --entryPoints src/index.ts --tsconfig tsconfig.prod.json", + "watch:builds": "pnpm lmdk-watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"", "lint": "eslint", "lint:fix": "pnpm lint --fix", diff --git a/packages/ui/package.json b/packages/ui/package.json index 2375cb531..9de41266b 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -10,7 +10,9 @@ "require": "./lib/cjs/index.js" }, "./*": { - "types": "./lib/types/*" + "types": "./lib/types/*", + "import": "./lib/esm/*", + "require": "./lib/cjs/*" } }, "files": [ @@ -18,9 +20,9 @@ ], "scripts": { "prebuild": "rimraf lib", - "build": "pnpm lmdk-build --entryPoints src/index.ts --tsconfig tsconfig.prod.json", + "build": "pnpm lmdk-build --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "dev": "concurrently \"pnpm watch:builds\" \"pnpm watch:types\"", - "watch:builds": "pnpm lmdk-watch --entryPoints src/index.ts --tsconfig tsconfig.prod.json", + "watch:builds": "pnpm lmdk-watch --entryPoints src/index.ts,src/**/*.ts --tsconfig tsconfig.prod.json", "watch:types": "concurrently \"tsc --watch -p tsconfig.prod.json\" \"tsc-alias --watch -p tsconfig.prod.json\"", "lint": "eslint", "lint:fix": "pnpm lint --fix",