From 2356b32115d3e241db6d350c4a81929f150f341f Mon Sep 17 00:00:00 2001 From: Stephan Schreiber Date: Sun, 18 Aug 2024 04:54:37 +0200 Subject: [PATCH] Use conditional imports in package.json --- package.json | 5 ++++- source/index.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 09533cd..493196d 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,9 @@ "type": "module", "exports": "./dist/index.js", "types": "./dist/index.d.ts", + "imports": { + "#package.json": "./package.json" + }, "scripts": { "build": "tsc -p tsconfig.build.json", "build:dts": "tsc -p tsconfig.build.json --declaration --emitDeclarationOnly --removeComments false", @@ -85,7 +88,7 @@ "ts": "module" }, "nodeArguments": [ - "--import=@septh/ts-run/register" + "--import=@septh/ts-run" ] } } diff --git a/source/index.ts b/source/index.ts index 5970cb6..4dd907c 100644 --- a/source/index.ts +++ b/source/index.ts @@ -92,7 +92,7 @@ interface PackageJson { } // Get our own name and version -const { name, version } = createRequire(import.meta.url)('../package.json') as PackageJson +const { name, version } = createRequire(import.meta.url)('#package.json') as PackageJson // Files that mark the root of a monorepo const workspaceRootFiles = new Set([