diff --git a/.eslintignore b/.eslintignore index f720d894..c94a8848 100644 --- a/.eslintignore +++ b/.eslintignore @@ -14,4 +14,5 @@ plugin/*/test/fixtures/**/run plugin/*/test/fixtures/**/oneapi plugin/*/test/fixtures/**/logs benchmark +scripts !plugin/tegg-compatible/typings/index.d.ts diff --git a/.gitignore b/.gitignore index f25cbffd..1487f3c3 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ yarn.lock *clinic-doctor* .nyc_output/ dist +esm **/*.js **/*.d.ts @@ -44,4 +45,5 @@ plugin/tegg/test/fixtures/apps/**/*.js !standalone/standalone/test/fixtures/**/node_modules/**/*.js !plugin/tegg/test/fixtures/**/node_modules !plugin/config/test/fixtures/**/node_modules +!scripts/**/*.js .node diff --git a/core/ajv-decorator/package.json b/core/ajv-decorator/package.json index 157a5924..27690426 100644 --- a/core/ajv-decorator/package.json +++ b/core/ajv-decorator/package.json @@ -12,14 +12,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "license": "MIT", @@ -50,4 +54,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/ajv-decorator/tsconfig.esm.json b/core/ajv-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/ajv-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/ajv-decorator/tsconfig.json b/core/ajv-decorator/tsconfig.json index 64b22405..360cb192 100644 --- a/core/ajv-decorator/tsconfig.json +++ b/core/ajv-decorator/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/ajv-decorator/tsconfig.pub.json b/core/ajv-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/ajv-decorator/tsconfig.pub.json +++ b/core/ajv-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/aop-decorator/package.json b/core/aop-decorator/package.json index 2fd23a4b..e17bfabd 100644 --- a/core/aop-decorator/package.json +++ b/core/aop-decorator/package.json @@ -23,9 +23,11 @@ }, "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "publishConfig": { @@ -38,7 +40,9 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "bugs": { "url": "https://github.com/eggjs/tegg/issues" @@ -51,4 +55,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/aop-decorator/tsconfig.esm.json b/core/aop-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/aop-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/aop-decorator/tsconfig.json b/core/aop-decorator/tsconfig.json index 64b22405..360cb192 100644 --- a/core/aop-decorator/tsconfig.json +++ b/core/aop-decorator/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/aop-decorator/tsconfig.pub.json b/core/aop-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/aop-decorator/tsconfig.pub.json +++ b/core/aop-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/aop-runtime/package.json b/core/aop-runtime/package.json index 4a563572..27190852 100644 --- a/core/aop-runtime/package.json +++ b/core/aop-runtime/package.json @@ -8,7 +8,9 @@ }, "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "keywords": [ @@ -20,9 +22,11 @@ ], "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean && rm -rf dist", + "clean": "tsc -b --clean && rm -rf dist && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -63,4 +67,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/aop-runtime/tsconfig.esm.json b/core/aop-runtime/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/aop-runtime/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/aop-runtime/tsconfig.json b/core/aop-runtime/tsconfig.json index 64b22405..360cb192 100644 --- a/core/aop-runtime/tsconfig.json +++ b/core/aop-runtime/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/aop-runtime/tsconfig.pub.json b/core/aop-runtime/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/aop-runtime/tsconfig.pub.json +++ b/core/aop-runtime/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/background-task/package.json b/core/background-task/package.json index e4737387..18ca9ec5 100644 --- a/core/background-task/package.json +++ b/core/background-task/package.json @@ -12,14 +12,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "homepage": "https://github.com/eggjs/tegg", @@ -55,4 +59,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/core/background-task/tsconfig.esm.json b/core/background-task/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/background-task/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/background-task/tsconfig.json b/core/background-task/tsconfig.json index 64b22405..360cb192 100644 --- a/core/background-task/tsconfig.json +++ b/core/background-task/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/background-task/tsconfig.pub.json b/core/background-task/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/background-task/tsconfig.pub.json +++ b/core/background-task/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/common-util/package.json b/core/common-util/package.json index 4849d1e4..164d7290 100644 --- a/core/common-util/package.json +++ b/core/common-util/package.json @@ -11,14 +11,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -52,4 +56,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/common-util/tsconfig.esm.json b/core/common-util/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/common-util/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/common-util/tsconfig.json b/core/common-util/tsconfig.json index 64b22405..360cb192 100644 --- a/core/common-util/tsconfig.json +++ b/core/common-util/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/common-util/tsconfig.pub.json b/core/common-util/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/common-util/tsconfig.pub.json +++ b/core/common-util/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/controller-decorator/package.json b/core/controller-decorator/package.json index 05840be0..bdc51c38 100644 --- a/core/controller-decorator/package.json +++ b/core/controller-decorator/package.json @@ -12,14 +12,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -57,4 +61,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/core/controller-decorator/tsconfig.esm.json b/core/controller-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/controller-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/controller-decorator/tsconfig.json b/core/controller-decorator/tsconfig.json index 64b22405..360cb192 100644 --- a/core/controller-decorator/tsconfig.json +++ b/core/controller-decorator/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/controller-decorator/tsconfig.pub.json b/core/controller-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/controller-decorator/tsconfig.pub.json +++ b/core/controller-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/core-decorator/package.json b/core/core-decorator/package.json index c26213b6..c6ded5b5 100644 --- a/core/core-decorator/package.json +++ b/core/core-decorator/package.json @@ -11,14 +11,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -51,4 +55,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/core-decorator/tsconfig.esm.json b/core/core-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/core-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/core-decorator/tsconfig.json b/core/core-decorator/tsconfig.json index 64b22405..360cb192 100644 --- a/core/core-decorator/tsconfig.json +++ b/core/core-decorator/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/core-decorator/tsconfig.pub.json b/core/core-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/core-decorator/tsconfig.pub.json +++ b/core/core-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/dal-decorator/package.json b/core/dal-decorator/package.json index 0a3dc5db..229bfdff 100644 --- a/core/dal-decorator/package.json +++ b/core/dal-decorator/package.json @@ -12,14 +12,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -54,4 +58,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/dal-decorator/tsconfig.esm.json b/core/dal-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/dal-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/dal-decorator/tsconfig.json b/core/dal-decorator/tsconfig.json index 64b22405..360cb192 100644 --- a/core/dal-decorator/tsconfig.json +++ b/core/dal-decorator/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/dal-decorator/tsconfig.pub.json b/core/dal-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/dal-decorator/tsconfig.pub.json +++ b/core/dal-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/dal-runtime/package.json b/core/dal-runtime/package.json index 74714abc..c509c1fb 100644 --- a/core/dal-runtime/package.json +++ b/core/dal-runtime/package.json @@ -13,15 +13,20 @@ "files": [ "dist/**/*.js", "dist/**/*.d.ts", - "dist/**/*.njk" + "dist/**/*.njk", + "esm/**/*.js", + "esm/**/*.d.ts", + "esm/**/*.njk" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run cp:template", - "cp:template": "rm -rf dist/src/templates && cp -r src/templates dist/src/templates", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm && npm run cp:template", + "cp:template": "rm -rf dist/src/templates && cp -r src/templates dist/src/templates && rm -rf esm/src/templates && cp -r src/templates esm/src/templates", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -61,4 +66,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/Foo.json b/core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/Foo.json index 69b3b69c..88bb7997 100644 --- a/core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/Foo.json +++ b/core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/Foo.json @@ -1,6 +1,5 @@ { "name": "egg_foo", - "dataSourceName": "default", "columns": [ { "columnName": "id", @@ -415,6 +414,7 @@ "comment": "index comment\n" } ], + "dataSourceName": "default", "comment": "foo table", "characterSet": "utf8mb4", "collate": "utf8mb4_unicode_ci" diff --git a/core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/MultiPrimaryKey.json b/core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/MultiPrimaryKey.json index 17c32eef..647f734e 100644 --- a/core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/MultiPrimaryKey.json +++ b/core/dal-runtime/test/fixtures/modules/generate_codes/dal/structure/MultiPrimaryKey.json @@ -1,6 +1,5 @@ { "name": "multi_primary_key_table", - "dataSourceName": "default", "columns": [ { "columnName": "id_1", @@ -36,5 +35,6 @@ } ], "indices": [], + "dataSourceName": "default", "comment": "multi primary key table" } \ No newline at end of file diff --git a/core/dal-runtime/tsconfig.esm.json b/core/dal-runtime/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/dal-runtime/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/dal-runtime/tsconfig.json b/core/dal-runtime/tsconfig.json index 00f8bd8e..ad984214 100644 --- a/core/dal-runtime/tsconfig.json +++ b/core/dal-runtime/tsconfig.json @@ -8,6 +8,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/dal-runtime/tsconfig.pub.json b/core/dal-runtime/tsconfig.pub.json index 00f8bd8e..ad984214 100644 --- a/core/dal-runtime/tsconfig.pub.json +++ b/core/dal-runtime/tsconfig.pub.json @@ -8,6 +8,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/dynamic-inject-runtime/package.json b/core/dynamic-inject-runtime/package.json index d91d752f..8ace1889 100644 --- a/core/dynamic-inject-runtime/package.json +++ b/core/dynamic-inject-runtime/package.json @@ -8,7 +8,9 @@ }, "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "keywords": [ @@ -19,9 +21,11 @@ ], "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean && rm -rf dist", + "clean": "tsc -b --clean && rm -rf dist && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -60,4 +64,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/dynamic-inject-runtime/tsconfig.esm.json b/core/dynamic-inject-runtime/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/dynamic-inject-runtime/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/dynamic-inject-runtime/tsconfig.json b/core/dynamic-inject-runtime/tsconfig.json index 64b22405..360cb192 100644 --- a/core/dynamic-inject-runtime/tsconfig.json +++ b/core/dynamic-inject-runtime/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/dynamic-inject-runtime/tsconfig.pub.json b/core/dynamic-inject-runtime/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/dynamic-inject-runtime/tsconfig.pub.json +++ b/core/dynamic-inject-runtime/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/dynamic-inject/package.json b/core/dynamic-inject/package.json index 07d67219..cc2a1362 100644 --- a/core/dynamic-inject/package.json +++ b/core/dynamic-inject/package.json @@ -5,7 +5,9 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "keywords": [ @@ -16,9 +18,11 @@ ], "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -51,4 +55,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/dynamic-inject/tsconfig.esm.json b/core/dynamic-inject/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/dynamic-inject/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/dynamic-inject/tsconfig.json b/core/dynamic-inject/tsconfig.json index 64b22405..360cb192 100644 --- a/core/dynamic-inject/tsconfig.json +++ b/core/dynamic-inject/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/dynamic-inject/tsconfig.pub.json b/core/dynamic-inject/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/dynamic-inject/tsconfig.pub.json +++ b/core/dynamic-inject/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/eventbus-decorator/package.json b/core/eventbus-decorator/package.json index cfb3bed4..b4dfcc72 100644 --- a/core/eventbus-decorator/package.json +++ b/core/eventbus-decorator/package.json @@ -12,14 +12,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -54,4 +58,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/core/eventbus-decorator/tsconfig.esm.json b/core/eventbus-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/eventbus-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/eventbus-decorator/tsconfig.json b/core/eventbus-decorator/tsconfig.json index 64b22405..360cb192 100644 --- a/core/eventbus-decorator/tsconfig.json +++ b/core/eventbus-decorator/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/eventbus-decorator/tsconfig.pub.json b/core/eventbus-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/eventbus-decorator/tsconfig.pub.json +++ b/core/eventbus-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/eventbus-runtime/package.json b/core/eventbus-runtime/package.json index a4bab88c..c3f08abd 100644 --- a/core/eventbus-runtime/package.json +++ b/core/eventbus-runtime/package.json @@ -15,14 +15,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean && rm -rf dist", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -64,4 +68,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/core/eventbus-runtime/tsconfig.esm.json b/core/eventbus-runtime/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/eventbus-runtime/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/eventbus-runtime/tsconfig.json b/core/eventbus-runtime/tsconfig.json index 64b22405..360cb192 100644 --- a/core/eventbus-runtime/tsconfig.json +++ b/core/eventbus-runtime/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/eventbus-runtime/tsconfig.pub.json b/core/eventbus-runtime/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/eventbus-runtime/tsconfig.pub.json +++ b/core/eventbus-runtime/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/lifecycle/package.json b/core/lifecycle/package.json index 62bcba96..e338ece0 100644 --- a/core/lifecycle/package.json +++ b/core/lifecycle/package.json @@ -11,14 +11,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -52,4 +56,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/lifecycle/tsconfig.esm.json b/core/lifecycle/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/lifecycle/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/lifecycle/tsconfig.json b/core/lifecycle/tsconfig.json index ed206ac6..360cb192 100644 --- a/core/lifecycle/tsconfig.json +++ b/core/lifecycle/tsconfig.json @@ -6,6 +6,8 @@ }, "exclude": [ "dist", - "node_modules" + "node_modules", + "test", + "esm" ] } diff --git a/core/lifecycle/tsconfig.pub.json b/core/lifecycle/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/lifecycle/tsconfig.pub.json +++ b/core/lifecycle/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/loader/package.json b/core/loader/package.json index 1e963354..347111c3 100644 --- a/core/loader/package.json +++ b/core/loader/package.json @@ -11,14 +11,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -54,4 +58,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/loader/src/LoaderUtil.ts b/core/loader/src/LoaderUtil.ts index 8cfcf0a6..dfd45137 100644 --- a/core/loader/src/LoaderUtil.ts +++ b/core/loader/src/LoaderUtil.ts @@ -44,6 +44,7 @@ export class LoaderUtil { '!**/coverage', // extra file pattern ...(this.config.extraFilePattern || []), + ...(typeof require === 'undefined' ? [ '!**/dist' ] : [ '!**/esm' ]), ]; return filePattern; diff --git a/core/loader/tsconfig.esm.json b/core/loader/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/loader/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/loader/tsconfig.json b/core/loader/tsconfig.json index 64b22405..360cb192 100644 --- a/core/loader/tsconfig.json +++ b/core/loader/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/loader/tsconfig.pub.json b/core/loader/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/loader/tsconfig.pub.json +++ b/core/loader/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/metadata/package.json b/core/metadata/package.json index 7d1d4077..845a9bd0 100644 --- a/core/metadata/package.json +++ b/core/metadata/package.json @@ -11,13 +11,17 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -54,4 +58,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/core/metadata/tsconfig.esm.json b/core/metadata/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/metadata/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/metadata/tsconfig.json b/core/metadata/tsconfig.json index 64b22405..360cb192 100644 --- a/core/metadata/tsconfig.json +++ b/core/metadata/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/metadata/tsconfig.pub.json b/core/metadata/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/metadata/tsconfig.pub.json +++ b/core/metadata/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/orm-decorator/package.json b/core/orm-decorator/package.json index c7482460..59c9cc26 100644 --- a/core/orm-decorator/package.json +++ b/core/orm-decorator/package.json @@ -5,7 +5,9 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "keywords": [ @@ -16,9 +18,11 @@ ], "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -57,4 +61,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/orm-decorator/tsconfig.esm.json b/core/orm-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/orm-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/orm-decorator/tsconfig.json b/core/orm-decorator/tsconfig.json index 64b22405..360cb192 100644 --- a/core/orm-decorator/tsconfig.json +++ b/core/orm-decorator/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/orm-decorator/tsconfig.pub.json b/core/orm-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/orm-decorator/tsconfig.pub.json +++ b/core/orm-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/runtime/package.json b/core/runtime/package.json index 324644a4..3d38eae0 100644 --- a/core/runtime/package.json +++ b/core/runtime/package.json @@ -5,7 +5,9 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "keywords": [ @@ -16,9 +18,11 @@ ], "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -55,4 +59,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/core/runtime/tsconfig.esm.json b/core/runtime/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/runtime/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/runtime/tsconfig.json b/core/runtime/tsconfig.json index 64b22405..360cb192 100644 --- a/core/runtime/tsconfig.json +++ b/core/runtime/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/runtime/tsconfig.pub.json b/core/runtime/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/runtime/tsconfig.pub.json +++ b/core/runtime/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/schedule-decorator/package.json b/core/schedule-decorator/package.json index 196db030..e0768190 100644 --- a/core/schedule-decorator/package.json +++ b/core/schedule-decorator/package.json @@ -5,7 +5,9 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "keywords": [ @@ -15,9 +17,11 @@ "tegg" ], "scripts": { - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -53,4 +57,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/core/schedule-decorator/tsconfig.esm.json b/core/schedule-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/schedule-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/schedule-decorator/tsconfig.json b/core/schedule-decorator/tsconfig.json index 64b22405..360cb192 100644 --- a/core/schedule-decorator/tsconfig.json +++ b/core/schedule-decorator/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/schedule-decorator/tsconfig.pub.json b/core/schedule-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/schedule-decorator/tsconfig.pub.json +++ b/core/schedule-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/standalone-decorator/package.json b/core/standalone-decorator/package.json index 8d9466ad..7f010335 100644 --- a/core/standalone-decorator/package.json +++ b/core/standalone-decorator/package.json @@ -12,13 +12,17 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -50,4 +54,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/standalone-decorator/tsconfig.esm.json b/core/standalone-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/standalone-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/standalone-decorator/tsconfig.json b/core/standalone-decorator/tsconfig.json index 64b22405..360cb192 100644 --- a/core/standalone-decorator/tsconfig.json +++ b/core/standalone-decorator/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/standalone-decorator/tsconfig.pub.json b/core/standalone-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/standalone-decorator/tsconfig.pub.json +++ b/core/standalone-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/tegg/package.json b/core/tegg/package.json index 800e441d..d30d8159 100644 --- a/core/tegg/package.json +++ b/core/tegg/package.json @@ -11,13 +11,17 @@ "main": "./index.js", "files": [ "*.js", - "*.d.ts" + "*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "author": "killagu ", @@ -65,4 +69,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/tegg/tsconfig.esm.json b/core/tegg/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/tegg/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/tegg/tsconfig.json b/core/tegg/tsconfig.json index 49122286..0f12f4fe 100644 --- a/core/tegg/tsconfig.json +++ b/core/tegg/tsconfig.json @@ -6,6 +6,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/tegg/tsconfig.pub.json b/core/tegg/tsconfig.pub.json index 49122286..0f12f4fe 100644 --- a/core/tegg/tsconfig.pub.json +++ b/core/tegg/tsconfig.pub.json @@ -6,6 +6,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/core/transaction-decorator/package.json b/core/transaction-decorator/package.json index c03d5997..640860cd 100644 --- a/core/transaction-decorator/package.json +++ b/core/transaction-decorator/package.json @@ -24,9 +24,11 @@ }, "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "publishConfig": { @@ -39,7 +41,9 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "bugs": { "url": "https://github.com/eggjs/tegg/issues" @@ -52,4 +56,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/core/transaction-decorator/tsconfig.esm.json b/core/transaction-decorator/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/core/transaction-decorator/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/core/transaction-decorator/tsconfig.json b/core/transaction-decorator/tsconfig.json index ed206ac6..360cb192 100644 --- a/core/transaction-decorator/tsconfig.json +++ b/core/transaction-decorator/tsconfig.json @@ -6,6 +6,8 @@ }, "exclude": [ "dist", - "node_modules" + "node_modules", + "test", + "esm" ] } diff --git a/core/transaction-decorator/tsconfig.pub.json b/core/transaction-decorator/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/core/transaction-decorator/tsconfig.pub.json +++ b/core/transaction-decorator/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/plugin/dal/package.json b/plugin/dal/package.json index b24d03f0..08c8f9fc 100644 --- a/plugin/dal/package.json +++ b/plugin/dal/package.json @@ -27,7 +27,9 @@ "lib/**/*.d.ts", "app/**/*.js", "app/**/*.d.ts", - "typings/*.d.ts" + "typings/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "types": "typings/index.d.ts", "scripts": { diff --git a/plugin/dal/tsconfig.esm.json b/plugin/dal/tsconfig.esm.json new file mode 100644 index 00000000..df38ec8c --- /dev/null +++ b/plugin/dal/tsconfig.esm.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "node_modules", + "test", + "esm" + ] +} diff --git a/plugin/dal/tsconfig.json b/plugin/dal/tsconfig.json index 74935f4b..210dc2ad 100644 --- a/plugin/dal/tsconfig.json +++ b/plugin/dal/tsconfig.json @@ -4,6 +4,7 @@ "baseUrl": "./" }, "exclude": [ - "node_modules" + "node_modules", + "esm" ] } diff --git a/plugin/dal/tsconfig.pub.json b/plugin/dal/tsconfig.pub.json index 8205bd19..74018e7f 100644 --- a/plugin/dal/tsconfig.pub.json +++ b/plugin/dal/tsconfig.pub.json @@ -5,6 +5,7 @@ }, "exclude": [ "node_modules", - "test" + "test", + "esm" ] } diff --git a/scripts/build-esm.js b/scripts/build-esm.js new file mode 100644 index 00000000..0bc02ec3 --- /dev/null +++ b/scripts/build-esm.js @@ -0,0 +1,81 @@ +const path = require("path"); +const fs = require("fs/promises"); +const { + ROOT_EXPORTS_VALUE, + DIST_EXPORTS_VALUE, + ROOT_PACKAGE_NAMES, + IGNORE_DIR, +} = require("./constant"); + +// 创建需要插入的 exports +const getExports = (paths, isRoot) => { + const res = isRoot ? ROOT_EXPORTS_VALUE : DIST_EXPORTS_VALUE; + + // 每个子目录都需要 + for (const p of paths) { + res.exports[isRoot ? `./${p}/*` : `./src/${p}/*`] = { + import: { + types: isRoot ?`./esm/${p}/*.d.ts` : `./esm/src/${p}/*.d.ts`, + default: isRoot ? `./esm/${p}/*.js` : `./esm/src/${p}/*.js`, + }, + require: { + types: isRoot ? `./${p}/*.d.ts` : `./lib/${p}/*.d.ts`, + default: isRoot ? `./${p}/*.js` : `./lib/${p}/*.js`, + }, + }; + } + + return res; +}; + +// get all sub dir +const traverseFolder = async (directory, arr) => { + const res = arr ?? []; + const files = await fs.readdir(directory); + + for (const file of files) { + if (IGNORE_DIR.includes(file)) { + continue; + } + const filePath = path.join(directory, file); + + const isDirectory = (await fs.stat(filePath)).isDirectory(); + + if (isDirectory) { + res.push(path.relative(directory, filePath)); + + await traverseFolder(filePath, res); + } + } + + return res; +}; + +(async () => { + const dir = path.join(process.cwd(), "esm"); + + await fs.mkdir(dir, { recursive: true }); + + const esmPackageJSON = path.join(dir, "package.json"); + + await fs.writeFile(esmPackageJSON, '{ "type": "module" }'); + + const pkgPath = path.join(process.cwd(), "package.json"); + + const pkg = await fs.readFile(pkgPath, "utf-8"); + + let pkgJSON = JSON.parse(pkg); + + const isRoot = ROOT_PACKAGE_NAMES.includes(pkgJSON.name); + + const paths = await traverseFolder( + isRoot ? process.cwd() : path.join(process.cwd(), "src") + ); + + pkgJSON = { + ...pkgJSON, + ...getExports(paths), + }; + + await fs.writeFile(pkgPath, JSON.stringify(pkgJSON, null, 2)); +})(); diff --git a/scripts/clean-esm.js b/scripts/clean-esm.js new file mode 100644 index 00000000..d0db6393 --- /dev/null +++ b/scripts/clean-esm.js @@ -0,0 +1,20 @@ +const path = require("path"); +const fs = require("fs/promises"); + +(async () => { + const dir = path.join(process.cwd(), "esm"); + + await fs.rm(dir, { recursive: true, force: true }); + + const pkgPath = path.join(process.cwd(), "package.json"); + + const pkg = await fs.readFile(pkgPath, "utf-8"); + + let pkgJSON = JSON.parse(pkg); + + delete pkgJSON["exports"]; + + delete pkgJSON["module"]; + + await fs.writeFile(pkgPath, JSON.stringify(pkgJSON, null, 2)); +})(); diff --git a/scripts/constant.js b/scripts/constant.js new file mode 100644 index 00000000..fe95d56b --- /dev/null +++ b/scripts/constant.js @@ -0,0 +1,62 @@ +const ROOT_EXPORTS_VALUE = { + module: "esm/index.js", + exports: { + ".": { + import: { + types: "./esm/index.d.ts", + default: "./esm/index.js", + }, + require: { + types: "./index.d.ts", + default: "./index.js", + }, + }, + "./*": { + import: { + types: "./esm/*.d.ts", + default: "./esm/*.js", + }, + require: { + types: "./*.d.ts", + default: "./*.js", + }, + }, + }, +}; + +const DIST_EXPORTS_VALUE = { + module: "esm/index.js", + exports: { + ".": { + import: { + types: "./esm/index.d.ts", + default: "./esm/index.js", + }, + require: { + types: "./dist/index.d.ts", + default: "./dist/index.js", + }, + }, + "./*": { + import: { + types: "./esm/*.d.ts", + default: "./esm/*.js", + }, + require: { + types: "./dist/*.d.ts", + default: "./dist/*.js", + }, + }, + }, +}; + +const ROOT_PACKAGE_NAMES = ["@eggjs/tegg"]; + +const IGNORE_DIR = ["dist", "node_modules", "test", "esm"]; + +module.exports = { + ROOT_EXPORTS_VALUE, + DIST_EXPORTS_VALUE, + ROOT_PACKAGE_NAMES, + IGNORE_DIR, +}; diff --git a/standalone/standalone/package.json b/standalone/standalone/package.json index 65fffe73..6700dec4 100644 --- a/standalone/standalone/package.json +++ b/standalone/standalone/package.json @@ -13,14 +13,18 @@ "main": "dist/index.js", "files": [ "dist/**/*.js", - "dist/**/*.d.ts" + "dist/**/*.d.ts", + "esm/**/*.js", + "esm/**/*.d.ts" ], "typings": "dist/index.d.ts", "scripts": { "test": "cross-env NODE_ENV=test NODE_OPTIONS='--no-deprecation' mocha", - "clean": "tsc -b --clean", + "clean": "tsc -b --clean && npm run clean:esm", + "clean:esm": "node ../../scripts/clean-esm.js", "tsc": "npm run clean && tsc -p ./tsconfig.json", - "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json", + "tsc:esm": "npm run clean:esm && node ../../scripts/build-esm.js &&tsc -p ./tsconfig.esm.json", + "tsc:pub": "npm run clean && tsc -p ./tsconfig.pub.json && npm run tsc:esm", "prepublishOnly": "npm run tsc:pub" }, "homepage": "https://github.com/eggjs/tegg", @@ -62,4 +66,4 @@ "ts-node": "^10.9.1", "typescript": "^5.0.4" } -} +} \ No newline at end of file diff --git a/standalone/standalone/tsconfig.esm.json b/standalone/standalone/tsconfig.esm.json new file mode 100644 index 00000000..97a01768 --- /dev/null +++ b/standalone/standalone/tsconfig.esm.json @@ -0,0 +1,16 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "moduleResolution": "node", + "module": "ES2020", + "target": "ESNext", + "outDir": "esm", + "baseUrl": "./" + }, + "exclude": [ + "dist", + "node_modules", + "test", + "esm" + ] +} diff --git a/standalone/standalone/tsconfig.json b/standalone/standalone/tsconfig.json index 64b22405..360cb192 100644 --- a/standalone/standalone/tsconfig.json +++ b/standalone/standalone/tsconfig.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/standalone/standalone/tsconfig.pub.json b/standalone/standalone/tsconfig.pub.json index 64b22405..360cb192 100644 --- a/standalone/standalone/tsconfig.pub.json +++ b/standalone/standalone/tsconfig.pub.json @@ -7,6 +7,7 @@ "exclude": [ "dist", "node_modules", - "test" + "test", + "esm" ] } diff --git a/tsconfig.json b/tsconfig.json index 0f9ad714..c0962c42 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,9 @@ { "compileOnSave": true, "compilerOptions": { - "target": "ES2019", + "target": "ESNext", "module": "CommonJS", + "moduleResolution": "node", "strict": true, "noImplicitAny": false, "esModuleInterop": true,