Skip to content

Commit 2356b32

Browse files
committed
Use conditional imports in package.json
1 parent d768094 commit 2356b32

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
"type": "module",
5252
"exports": "./dist/index.js",
5353
"types": "./dist/index.d.ts",
54+
"imports": {
55+
"#package.json": "./package.json"
56+
},
5457
"scripts": {
5558
"build": "tsc -p tsconfig.build.json",
5659
"build:dts": "tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --removeComments false",
@@ -85,7 +88,7 @@
8588
"ts": "module"
8689
},
8790
"nodeArguments": [
88-
"--import=@septh/ts-run/register"
91+
"--import=@septh/ts-run"
8992
]
9093
}
9194
}

source/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ interface PackageJson {
9292
}
9393

9494
// Get our own name and version
95-
const { name, version } = createRequire(import.meta.url)('../package.json') as PackageJson
95+
const { name, version } = createRequire(import.meta.url)('#package.json') as PackageJson
9696

9797
// Files that mark the root of a monorepo
9898
const workspaceRootFiles = new Set([

0 commit comments

Comments
 (0)