Skip to content

Commit

Permalink
ts-node fails to find configs from exports field
Browse files Browse the repository at this point in the history
  • Loading branch information
ItamarGronich committed Mar 18, 2024
1 parent 78efeb7 commit 5ea4842
Show file tree
Hide file tree
Showing 10 changed files with 296 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist
1 change: 0 additions & 1 deletion example.ts

This file was deleted.

236 changes: 236 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
8 changes: 8 additions & 0 deletions packages/main/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@tsnode-exports/main",
"version": "1.0.0",
"description": "",
"dependencies": {
"@tsnode-exports/ts-config": "*"
}
}
1 change: 1 addition & 0 deletions packages/main/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("All good! 🎉");
9 changes: 9 additions & 0 deletions packages/main/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@tsnode-exports/ts-config/tsconfig.json",
"include": ["src/**/*.ts"],
"exclude": ["node_modules"],
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
}
}
9 changes: 9 additions & 0 deletions packages/ts-config/configs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"module": "NodeNext",
"target": "es6",
"strict": true,
"moduleResolution": "NodeNext",
"esModuleInterop": true
}
}
8 changes: 8 additions & 0 deletions packages/ts-config/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
9 changes: 6 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5ea4842

Please sign in to comment.