diff --git a/packages/cross-import/package.json b/packages/cross-import/package.json index db82ffb..c54673d 100644 --- a/packages/cross-import/package.json +++ b/packages/cross-import/package.json @@ -1,7 +1,7 @@ { "name": "cross-import", "scripts": { - "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node", + "build:cjs": "esbuild src/index.ts --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run build:cjs && pnpm run build:type", "dev": "pnpm run \"/^build:.*/\" --watch", @@ -44,18 +44,12 @@ }, "main": "./dist/index.js", "types": "./dist/index.d.ts", - "exports": { - ".": { - "require": "./dist/index.js", - "import": "./dist/index.js", - "types": "./dist/index.d.ts" - } - }, + "exports": "./dist/index.js", "files": [ "dist" ], - "devDependencies": { - "sucrase": "^3.32.0", - "jiti": "^1.18.2" + "dependencies": { + "jiti": "^1.21.0", + "sucrase": "^3.34.0" } } \ No newline at end of file diff --git a/packages/cross-import/src/index.ts b/packages/cross-import/src/index.ts index 2d55386..3156d66 100644 --- a/packages/cross-import/src/index.ts +++ b/packages/cross-import/src/index.ts @@ -3,45 +3,38 @@ import { transform } from 'sucrase' export default function crossImport(modulePath: string): any { if (!modulePath) return - if (process.env.DEBUG) { - console.log('[DEBUG] [Cross Import] modulePath:', modulePath) - } /** try to delete cache first */ try { if (require.cache[modulePath]) { delete require.cache[modulePath] if (process.env.DEBUG) { - console.log('[DEBUG] [Cross Import] delete cache') + console.log('[cross-import] cache deleted') } } } catch { /* empty */ } try { if (process.env.DEBUG) { - console.log('[DEBUG] [Cross Import] require') + console.log('[cross-import] require:', modulePath) } return require(modulePath) } catch (error) { if (process.env.DEBUG) { - console.log('[DEBUG] [Cross Import] JITI') console.error(error) + console.log('[cross-import] fall back to jiti:', modulePath) } - try { - return jiti(__filename, { - interopDefault: true, - cache: false, - debug: !!process.env.DEBUG, - transform: (options) => { - if (process.env.DEBUG) { - console.log('[DEBUG] [Cross Import] JITI transform') - } - return transform(options.source, { - transforms: ['imports', 'typescript'], - }) + return jiti(__filename, { + interopDefault: true, + cache: false, + debug: !!process.env.DEBUG, + transform: (options) => { + if (process.env.DEBUG) { + console.log('[cross-import] jiti transform') } - })(modulePath) - } catch (error) { - throw new Error(error) - } + return transform(options.source, { + transforms: ['imports', 'typescript'], + }) + } + })(modulePath) } } \ No newline at end of file diff --git a/packages/explore-config/package.json b/packages/explore-config/package.json index 62a1182..9f8fe7d 100644 --- a/packages/explore-config/package.json +++ b/packages/explore-config/package.json @@ -1,8 +1,8 @@ { "name": "explore-config", "scripts": { - "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node --external:esbuild --external:@techor/glob --external:@techor/log --external:@techor/extend --external:cross-import --external:upath", - "build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node --external:esbuild --external:@techor/glob --external:@techor/log --external:@techor/extend --external:cross-import --external:upath", + "build:cjs": "esbuild src/index.ts --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node", + "build:esm": "esbuild src/index.ts --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run build:cjs && pnpm run build:esm && pnpm run build:type", "dev": "pnpm run \"/^build:.*/\" --watch", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 28c1aa9..ec5ba33 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,13 +104,13 @@ importers: packages/conventional-commits: {} packages/cross-import: - devDependencies: + dependencies: jiti: - specifier: ^1.18.2 - version: 1.18.2 + specifier: ^1.21.0 + version: 1.21.0 sucrase: - specifier: ^3.32.0 - version: 3.32.0 + specifier: ^3.34.0 + version: 3.34.0 packages/eslint-config: dependencies: @@ -2490,7 +2490,6 @@ packages: /any-promise@1.3.0: resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} - dev: true /anymatch@3.1.3: resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==} @@ -2865,7 +2864,6 @@ packages: /commander@4.1.1: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} - dev: true /commander@5.1.0: resolution: {integrity: sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==} @@ -3862,7 +3860,6 @@ packages: minimatch: 3.1.2 once: 1.4.0 path-is-absolute: 1.0.1 - dev: true /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} @@ -4862,10 +4859,10 @@ packages: - ts-node dev: false - /jiti@1.18.2: - resolution: {integrity: sha512-QAdOptna2NYiSSpv0O/BwoHBSmz4YhpzJHyi+fnMRTXFjp7B8i/YG5Z8IfusxB1ufjcD2Sre1F3R+nX3fvy7gg==} + /jiti@1.21.0: + resolution: {integrity: sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==} hasBin: true - dev: true + dev: false /joi@17.9.2: resolution: {integrity: sha512-Itk/r+V4Dx0V3c7RLFdRh12IOjySm2/WGPMubBT92cQvRfYZhPM2W0hZlctjj72iES8jsRCwp7S/cRmWBnJ4nw==} @@ -5332,7 +5329,6 @@ packages: any-promise: 1.3.0 object-assign: 4.1.1 thenify-all: 1.6.0 - dev: true /natural-compare-lite@1.4.0: resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} @@ -5508,7 +5504,6 @@ packages: /object-assign@4.1.1: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} - dev: true /object-treeify@3.3.1: resolution: {integrity: sha512-oGCWfO3GEvv5foAuiLR64W02Xj/lWGLY7tuY35L2JBaOasaBxI0184PQzdhWHhib8guarXig3LMTL+MTI6cdSQ==} @@ -6467,6 +6462,20 @@ packages: ts-interface-checker: 0.1.13 dev: true + /sucrase@3.34.0: + resolution: {integrity: sha512-70/LQEZ07TEcxiU2dz51FKaE6hCTWC6vr7FOk3Gr0U60C3shtAN+H+BFr9XlYe5xqf3RA8nrc+VIwzCfnxuXJw==} + engines: {node: '>=8'} + hasBin: true + dependencies: + '@jridgewell/gen-mapping': 0.3.3 + commander: 4.1.1 + glob: 7.1.6 + lines-and-columns: 1.2.4 + mz: 2.7.0 + pirates: 4.0.6 + ts-interface-checker: 0.1.13 + dev: false + /supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} engines: {node: '>=4'} @@ -6553,13 +6562,11 @@ packages: engines: {node: '>=0.8'} dependencies: thenify: 3.3.1 - dev: true /thenify@3.3.1: resolution: {integrity: sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==} dependencies: any-promise: 1.3.0 - dev: true /through2@2.0.5: resolution: {integrity: sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==} @@ -6645,7 +6652,6 @@ packages: /ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} - dev: true /ts-node@10.9.1(@types/node@18.17.3)(typescript@5.1.6): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==}