diff --git a/packages/core/webpack.config.js b/packages/core/webpack.config.cjs similarity index 100% rename from packages/core/webpack.config.js rename to packages/core/webpack.config.cjs diff --git a/packages/di/webpack.config.js b/packages/di/webpack.config.cjs similarity index 100% rename from packages/di/webpack.config.js rename to packages/di/webpack.config.cjs diff --git a/packages/specs/json-mapper/webpack.config.js b/packages/specs/json-mapper/webpack.config.cjs similarity index 100% rename from packages/specs/json-mapper/webpack.config.js rename to packages/specs/json-mapper/webpack.config.cjs diff --git a/packages/specs/schema/webpack.config.js b/packages/specs/schema/webpack.config.cjs similarity index 100% rename from packages/specs/schema/webpack.config.js rename to packages/specs/schema/webpack.config.cjs diff --git a/packages/third-parties/schema-formio/webpack.config.js b/packages/third-parties/schema-formio/webpack.config.cjs similarity index 100% rename from packages/third-parties/schema-formio/webpack.config.js rename to packages/third-parties/schema-formio/webpack.config.cjs diff --git a/tools/typescript/index.js b/tools/typescript/index.js index 6ac00276635..86d0af8d7ea 100644 --- a/tools/typescript/index.js +++ b/tools/typescript/index.js @@ -2,6 +2,7 @@ import {findPackages, MonoRepo} from "@tsed/monorepo-utils"; import {dirname, join, relative} from "node:path"; import cloneDeep from "lodash/cloneDeep.js"; import omit from "lodash/omit.js"; +import get from "lodash/get.js"; import fs from "fs-extra"; import globby from "globby"; @@ -18,7 +19,6 @@ async function main() { const tsConfigRootPath = join(monoRepo.rootDir, "tsconfig.json"); const tsConfigTemplate = await fs.readJson(join(scriptDir, "./tsconfig.template.json")); - const tsConfigTemplateCjsPath = join(scriptDir, "./tsconfig.template.cjs.json"); const tsConfigTemplateEsmPath = join(scriptDir, "./tsconfig.template.esm.json"); const tsConfigTemplateSpecPath = join(scriptDir, "./tsconfig.template.spec.json"); const tsConfigTemplateSpec = await fs.readJson(tsConfigTemplateSpecPath); @@ -44,7 +44,6 @@ async function main() { const tsConfig = cloneDeep(tsConfigTemplate); const tsConfigPath = join(path, "tsconfig.json"); const tsConfigBuildEsmPath = join(path, "tsconfig.esm.json"); - const tsConfigBuildCjsPath = join(path, "tsconfig.cjs.json"); const tsConfigBuildSpecPath = join(path, "tsconfig.spec.json"); const npmignore = join(path, ".npmignore"); const vitestPath = join(path, "vitest.config.mts"); @@ -73,14 +72,9 @@ async function main() { }); }); - tsConfig.references.push( - { - path: "./tsconfig.cjs.json" - }, - { - path: "./tsconfig.esm.json" - } - ); + tsConfig.references.push({ + path: "./tsconfig.esm.json" + }); if (hasFiles.length) { tsConfig.references.push({ @@ -121,7 +115,6 @@ async function main() { await fs.writeJson(tsConfigPath, tsConfig, {spaces: 2}); await fs.copy(tsConfigTemplateEsmPath, tsConfigBuildEsmPath); - await fs.copy(tsConfigTemplateCjsPath, tsConfigBuildCjsPath); await fs.copy(npmIgnoreTemplatePath, npmignore); tsConfigRoot.references.push({ @@ -173,22 +166,24 @@ async function main() { // pkg.pkg.main = pkg.pkg.main.replace("cjs/", "esm/"); - if (pkg.pkg.exports && !pkg.pkg.exports["."]) { - pkg.pkg.exports = { - ".": { - ...pkg.pkg.exports - } - }; - } + pkg.pkg.type = "module"; + pkg.pkg.source = "./src/index.ts"; + pkg.pkg.main = "./lib/esm/index.js"; + pkg.pkg.module = "./lib/esm/index.js"; + pkg.pkg.typings = "./lib/types/index.d.ts"; + pkg.pkg.exports = { + ".": { + ...omit(get(pkg, 'pkg.exports["."]', {}), ["require"]) + // typings: "./lib/types/index.d.ts", + // default: "./lib/esm/index.js", + // import: "./lib/esm/index.js" + } + }; await fs.writeJson(pkg.path, pkg.pkg, {spaces: 2}); - // try { - // fs.removeSync(join(path, "tsconfig.compile.esm.json")); - // fs.removeSync(join(path, "tsconfig.compile.json")); - // fs.removeSync(join(path, "tsconfig.cjs.json")); - // // fs.removeSync(join(path, "tsconfig.esm.json")); - // } catch { - // } + try { + fs.removeSync(join(path, "tsconfig.cjs.json")); + } catch {} } } diff --git a/tools/typescript/swc.node.json b/tools/typescript/swc.node.json index 1321bf01037..09209e497d6 100644 --- a/tools/typescript/swc.node.json +++ b/tools/typescript/swc.node.json @@ -1,7 +1,7 @@ { "sourceMaps": "inline", "jsc": { - "target": "es2021", + "target": "es2023", "externalHelpers": true, "keepClassNames": true, "parser": { @@ -23,7 +23,7 @@ } }, "module": { - "type": "commonjs", + "type": "es6", "strict": false, "strictMode": true, "lazy": false, diff --git a/tools/typescript/tsconfig.template.cjs.json b/tools/typescript/tsconfig.template.cjs.json deleted file mode 100644 index 7f23b116d2b..00000000000 --- a/tools/typescript/tsconfig.template.cjs.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "extends": "@tsed/typescript/tsconfig.node.json", - "compilerOptions": { - "baseUrl": ".", - "module": "commonjs", - "moduleResolution": "Node16", - "rootDir": "src", - "outDir": "./lib/cjs", - "declaration": true, - "declarationDir": "./lib/types", - "composite": true, - "noEmit": false - }, - "include": ["src", "src/**/*.json"], - "exclude": [ - "node_modules", - "test", - "lib", - "benchmark", - "coverage", - "spec", - "**/*.benchmark.ts", - "**/*.spec.ts", - "keys", - "**/__mock__/**", - "webpack.config.js" - ] -} diff --git a/tools/typescript/tsconfig.template.esm.json b/tools/typescript/tsconfig.template.esm.json index ce32a9e0718..e3b07081667 100644 --- a/tools/typescript/tsconfig.template.esm.json +++ b/tools/typescript/tsconfig.template.esm.json @@ -6,7 +6,7 @@ "moduleResolution": "nodenext", "rootDir": "src", "outDir": "./lib/esm", - "declarationDir": "./lib/types-esm", + "declarationDir": "./lib/types", "declaration": true, "composite": true, "noEmit": false