From 86e3bb2a945f79620bc886b3450a113965786ca4 Mon Sep 17 00:00:00 2001 From: Revone Date: Fri, 13 Oct 2023 10:29:08 +0800 Subject: [PATCH] [core] To standardize tsconfig.prod.json and tsconfig.json, .d.ts declaration files are also provided in the dist directory. To ensure compatibility with different versions of Node.js, you should modify the "exports" and "type" fields in package.json --- package.json | 7 ++++++- tsconfig.json | 4 ++-- tsconfig.prod.json | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 25c0487..9327568 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,11 @@ "types": "lib/index.d.ts", "source": "src/index.ts", "umd:main": "umd/bundle.min.js", + "type": "module", + "exports": { + "import": "./lib/index.js", + "require": "./dist/index.js" + }, "scripts": { "build": "npm run build:es6 && npm run build:commonjs && npm run build:umd && npm run build:docs", "build:es6": "rm -rf lib && tsc", @@ -34,7 +39,7 @@ "type": "git", "url": "git+https://github.com/zrwusa/data-structure-typed.git" }, - "author": "Tyler Zeng zrwusa@gmail.com", + "author": "Tyler Zeng ", "license": "MIT", "publishConfig": { "@zrwusa:registry": "https://npm.pkg.github.com" diff --git a/tsconfig.json b/tsconfig.json index 500c3ba..4b9d87a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,9 @@ { "compilerOptions": { + "target": "ES6", + "module": "ES6", "outDir": "./lib", "declaration": true, - "module": "ES6", - "target": "ES6", "lib": [ "ESNext" ], diff --git a/tsconfig.prod.json b/tsconfig.prod.json index f0b1573..1776ab6 100644 --- a/tsconfig.prod.json +++ b/tsconfig.prod.json @@ -3,10 +3,11 @@ "target": "ES6", "module": "CommonJS", "outDir": "./dist", - "sourceMap": true, + "declaration": true, "lib": [ "ESNext" ], + "sourceMap": true, "strict": true, "downlevelIteration": true, "removeComments": true,