From 5ea4842fabebb37aaaa48b72170db91a0838521e Mon Sep 17 00:00:00 2001 From: ItamarGronich Date: Mon, 18 Mar 2024 23:20:09 +0200 Subject: [PATCH] ts-node fails to find configs from exports field --- .gitignore | 1 + example.ts | 1 - package-lock.json | 236 +++++++++++++++++++++++ package.json | 21 +- packages/main/package.json | 8 + packages/main/src/index.ts | 1 + packages/main/tsconfig.json | 9 + packages/ts-config/configs/tsconfig.json | 9 + packages/ts-config/package.json | 8 + run.sh | 9 +- 10 files changed, 296 insertions(+), 7 deletions(-) delete mode 100644 example.ts create mode 100644 package-lock.json create mode 100644 packages/main/package.json create mode 100644 packages/main/src/index.ts create mode 100644 packages/main/tsconfig.json create mode 100644 packages/ts-config/configs/tsconfig.json create mode 100644 packages/ts-config/package.json diff --git a/.gitignore b/.gitignore index 3c3629e..f06235c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +dist diff --git a/example.ts b/example.ts deleted file mode 100644 index a201bd7..0000000 --- a/example.ts +++ /dev/null @@ -1 +0,0 @@ -console.log('Some .ts code reproducing a bug'); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..81d0d93 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,236 @@ +{ + "name": "@tsnode-exports/workspace-root", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@tsnode-exports/workspace-root", + "version": "1.0.0", + "license": "ISC", + "workspaces": [ + "packages/*" + ], + "devDependencies": { + "ts-node": "^10.9.2", + "typescript": "^5.4.2" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.15", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", + "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@tsconfig/node10": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", + "integrity": "sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA==", + "dev": true + }, + "node_modules/@tsconfig/node12": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", + "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", + "dev": true + }, + "node_modules/@tsconfig/node14": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", + "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", + "dev": true + }, + "node_modules/@tsconfig/node16": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", + "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", + "dev": true + }, + "node_modules/@tsnode-exports/main": { + "resolved": "packages/main", + "link": true + }, + "node_modules/@tsnode-exports/ts-config": { + "resolved": "packages/ts-config", + "link": true + }, + "node_modules/@types/node": { + "version": "20.11.29", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.29.tgz", + "integrity": "sha512-P99thMkD/1YkCvAtOd6/zGedKNA0p2fj4ZpjCzcNiSCBWgm3cNRTBfa/qjFnsKkkojxu4vVLtWpesnZ9+ap+gA==", + "dev": true, + "peer": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/acorn": { + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-walk": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", + "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/arg": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", + "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", + "dev": true + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true + }, + "node_modules/diff": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", + "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/ts-node": { + "version": "10.9.2", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", + "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", + "dev": true, + "dependencies": { + "@cspotcode/source-map-support": "^0.8.0", + "@tsconfig/node10": "^1.0.7", + "@tsconfig/node12": "^1.0.7", + "@tsconfig/node14": "^1.0.0", + "@tsconfig/node16": "^1.0.2", + "acorn": "^8.4.1", + "acorn-walk": "^8.1.1", + "arg": "^4.1.0", + "create-require": "^1.1.0", + "diff": "^4.0.1", + "make-error": "^1.1.1", + "v8-compile-cache-lib": "^3.0.1", + "yn": "3.1.1" + }, + "bin": { + "ts-node": "dist/bin.js", + "ts-node-cwd": "dist/bin-cwd.js", + "ts-node-esm": "dist/bin-esm.js", + "ts-node-script": "dist/bin-script.js", + "ts-node-transpile-only": "dist/bin-transpile.js", + "ts-script": "dist/bin-script-deprecated.js" + }, + "peerDependencies": { + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", + "@types/node": "*", + "typescript": ">=2.7" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "@swc/wasm": { + "optional": true + } + } + }, + "node_modules/typescript": { + "version": "5.4.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz", + "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "peer": true + }, + "node_modules/v8-compile-cache-lib": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", + "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", + "dev": true + }, + "node_modules/yn": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "packages/main": { + "name": "@tsnode-exports/main", + "version": "1.0.0", + "dependencies": { + "@tsnode-exports/ts-config": "*" + } + }, + "packages/ts-config": { + "name": "@tsnode-exports/ts-config", + "version": "1.0.0" + } + } +} diff --git a/package.json b/package.json index 4d56496..af06285 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,21 @@ { - "dependencies": { - "ts-node": "latest", - "typescript": "latest" + "name": "@tsnode-exports/workspace-root", + "version": "1.0.0", + "description": "", + "private": true, + "workspaces": [ + "packages/*" + ], + "main": "index.js", + "scripts": { + "tsc": "cd packages/main && rm -rf dist && tsc && node dist/index.js", + "ts-node": "cd packages/main && ts-node src/index.ts" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "ts-node": "^10.9.2", + "typescript": "^5.4.2" } } diff --git a/packages/main/package.json b/packages/main/package.json new file mode 100644 index 0000000..3ed4c4b --- /dev/null +++ b/packages/main/package.json @@ -0,0 +1,8 @@ +{ + "name": "@tsnode-exports/main", + "version": "1.0.0", + "description": "", + "dependencies": { + "@tsnode-exports/ts-config": "*" + } +} diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts new file mode 100644 index 0000000..d2d1698 --- /dev/null +++ b/packages/main/src/index.ts @@ -0,0 +1 @@ +console.log("All good! 🎉"); diff --git a/packages/main/tsconfig.json b/packages/main/tsconfig.json new file mode 100644 index 0000000..e513eb8 --- /dev/null +++ b/packages/main/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "@tsnode-exports/ts-config/tsconfig.json", + "include": ["src/**/*.ts"], + "exclude": ["node_modules"], + "compilerOptions": { + "outDir": "./dist", + "rootDir": "./src" + } +} diff --git a/packages/ts-config/configs/tsconfig.json b/packages/ts-config/configs/tsconfig.json new file mode 100644 index 0000000..6e7a69e --- /dev/null +++ b/packages/ts-config/configs/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "target": "es6", + "strict": true, + "moduleResolution": "NodeNext", + "esModuleInterop": true + } +} diff --git a/packages/ts-config/package.json b/packages/ts-config/package.json new file mode 100644 index 0000000..9874f4c --- /dev/null +++ b/packages/ts-config/package.json @@ -0,0 +1,8 @@ +{ + "name": "@tsnode-exports/ts-config", + "version": "1.0.0", + "description": "A shared configuration for TypeScript projects", + "exports": { + "./tsconfig.json": "./configs/tsconfig.json" + } +} diff --git a/run.sh b/run.sh index d553b44..5caf5ea 100644 --- a/run.sh +++ b/run.sh @@ -1,13 +1,16 @@ #!/usr/bin/env bash # Install a specific version of node -n lts +n v20.11.0 # Install package.json dependencies -yarn +npm ci + +# Run tsc +npm run tsc # Run ts-node -yarn ts-node ./example.ts +npm run ts-node echo "Process exited with code: $?" echo