diff --git a/packages/alias/package.json b/packages/alias/package.json index 30aec8b1e..11449daaf 100755 --- a/packages/alias/package.json +++ b/packages/alias/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -68,7 +67,6 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/auto-install/package.json b/packages/auto-install/package.json index 8d2346268..a54979d5b 100755 --- a/packages/auto-install/package.json +++ b/packages/auto-install/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -68,7 +67,6 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/babel/package.json b/packages/babel/package.json index f4668c20f..74d04477f 100644 --- a/packages/babel/package.json +++ b/packages/babel/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -82,7 +81,6 @@ "rollup": "^4.0.0-24", "source-map": "^0.7.4" }, - "types": "./types/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/buble/package.json b/packages/buble/package.json index 54f5cfb29..9470b0634 100644 --- a/packages/buble/package.json +++ b/packages/buble/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -72,7 +71,6 @@ "source-map": "^0.7.4", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/commonjs/package.json b/packages/commonjs/package.json index aaa8eef48..221dc52b2 100644 --- a/packages/commonjs/package.json +++ b/packages/commonjs/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -80,7 +79,6 @@ "source-map-support": "^0.5.21", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/data-uri/package.json b/packages/data-uri/package.json index d74646536..3e1fd62f1 100644 --- a/packages/data-uri/package.json +++ b/packages/data-uri/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -69,7 +68,6 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/dsv/package.json b/packages/dsv/package.json index 86b826d19..575a638aa 100755 --- a/packages/dsv/package.json +++ b/packages/dsv/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -58,7 +57,6 @@ "del-cli": "^5.0.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/dynamic-import-vars/package.json b/packages/dynamic-import-vars/package.json index bfe2c9398..2a6358341 100644 --- a/packages/dynamic-import-vars/package.json +++ b/packages/dynamic-import-vars/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -74,7 +73,6 @@ "prettier": "^2.7.1", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/eslint/package.json b/packages/eslint/package.json index 7681a688c..0a367bf9c 100755 --- a/packages/eslint/package.json +++ b/packages/eslint/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -72,7 +71,6 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/esm-shim/package.json b/packages/esm-shim/package.json index 04ccc15e6..a1089a3f9 100644 --- a/packages/esm-shim/package.json +++ b/packages/esm-shim/package.json @@ -16,7 +16,6 @@ "main": "dist/cjs/index.js", "module": "dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -65,6 +64,5 @@ "devDependencies": { "rollup": "^4.0.0-24", "typescript": "^4.8.3" - }, - "types": "./types/index.d.ts" + } } diff --git a/packages/graphql/package.json b/packages/graphql/package.json index 6280a1b7a..5cbbacd84 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -71,7 +70,6 @@ "graphql": "^16.6.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/html/package.json b/packages/html/package.json index 4bfdf7371..6e962c297 100644 --- a/packages/html/package.json +++ b/packages/html/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -65,7 +64,6 @@ "rollup-plugin-postcss": "^4.0.2", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/image/package.json b/packages/image/package.json index 17eac8963..a5f20f69e 100644 --- a/packages/image/package.json +++ b/packages/image/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -65,7 +64,6 @@ "@rollup/plugin-buble": "^1.0.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/inject/package.json b/packages/inject/package.json index 7ecabd25f..8b6569c5c 100644 --- a/packages/inject/package.json +++ b/packages/inject/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -73,7 +72,6 @@ "source-map": "^0.7.4", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/json/package.json b/packages/json/package.json index 47b04a896..883b4960b 100755 --- a/packages/json/package.json +++ b/packages/json/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -69,7 +68,6 @@ "rollup": "^4.0.0-24", "source-map-support": "^0.5.21" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/legacy/package.json b/packages/legacy/package.json index 04b027ecd..ba5ce47b3 100644 --- a/packages/legacy/package.json +++ b/packages/legacy/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -63,7 +62,6 @@ "del-cli": "^5.0.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/multi-entry/package.json b/packages/multi-entry/package.json index 699a0eac1..f6208349b 100755 --- a/packages/multi-entry/package.json +++ b/packages/multi-entry/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -66,7 +65,6 @@ "devDependencies": { "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/node-resolve/package.json b/packages/node-resolve/package.json index 78b7c922d..30522183e 100644 --- a/packages/node-resolve/package.json +++ b/packages/node-resolve/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -79,7 +78,6 @@ "source-map": "^0.7.4", "string-capitalize": "^1.0.1" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/pluginutils/package.json b/packages/pluginutils/package.json index e86973629..1351bcb2c 100644 --- a/packages/pluginutils/package.json +++ b/packages/pluginutils/package.json @@ -19,7 +19,6 @@ "module": "./dist/es/index.js", "type": "commonjs", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -75,7 +74,6 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "extensions": [ "ts" diff --git a/packages/replace/package.json b/packages/replace/package.json index e6d351846..c26145596 100644 --- a/packages/replace/package.json +++ b/packages/replace/package.json @@ -16,7 +16,6 @@ "main": "dist/cjs/index.js", "module": "dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -72,7 +71,6 @@ "source-map": "^0.7.4", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/run/package.json b/packages/run/package.json index c6e1dffa2..ad082eab8 100644 --- a/packages/run/package.json +++ b/packages/run/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -66,7 +65,6 @@ "sinon": "^14.0.0", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/strip/package.json b/packages/strip/package.json index b3272cede..c4d3bdffb 100644 --- a/packages/strip/package.json +++ b/packages/strip/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -63,7 +62,6 @@ "acorn": "^8.8.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/sucrase/package.json b/packages/sucrase/package.json index 986376ab6..37a134fd0 100644 --- a/packages/sucrase/package.json +++ b/packages/sucrase/package.json @@ -17,7 +17,6 @@ "module": "./dist/es/index.js", "type": "commonjs", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -69,7 +68,6 @@ "@rollup/plugin-alias": "^4.0.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/swc/package.json b/packages/swc/package.json index 23cfbaf10..f96d8d48d 100644 --- a/packages/swc/package.json +++ b/packages/swc/package.json @@ -16,7 +16,6 @@ "main": "dist/cjs/index.js", "module": "dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -69,6 +68,5 @@ "@swc/core": "^1.3.78", "rollup": "^4.0.0-24", "typescript": "^4.8.3" - }, - "types": "./types/index.d.ts" + } } diff --git a/packages/terser/package.json b/packages/terser/package.json index 24f9a35a6..f93ea16c0 100644 --- a/packages/terser/package.json +++ b/packages/terser/package.json @@ -16,7 +16,6 @@ "main": "dist/cjs/index.js", "module": "dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -69,6 +68,5 @@ "@types/serialize-javascript": "^5.0.2", "rollup": "^4.0.0-24", "typescript": "^4.8.3" - }, - "types": "./types/index.d.ts" + } } diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 0f0c23abf..fa3750a02 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -75,6 +74,5 @@ "buble": "^0.20.0", "rollup": "^4.0.0-24", "typescript": "^4.8.3" - }, - "types": "./types/index.d.ts" + } } diff --git a/packages/url/package.json b/packages/url/package.json index 6883535d5..8a1854623 100644 --- a/packages/url/package.json +++ b/packages/url/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -66,7 +65,6 @@ "globby": "^11.1.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/virtual/package.json b/packages/virtual/package.json index a396595dc..115a8acf4 100755 --- a/packages/virtual/package.json +++ b/packages/virtual/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -66,7 +65,6 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/wasm/package.json b/packages/wasm/package.json index c4723c27b..601fa9e6b 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -72,7 +71,6 @@ "source-map": "^0.7.4", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/yaml/package.json b/packages/yaml/package.json index cd7c102ab..bf0689426 100755 --- a/packages/yaml/package.json +++ b/packages/yaml/package.json @@ -16,7 +16,6 @@ "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", "exports": { - "types": "./types/index.d.ts", "import": "./dist/es/index.js", "default": "./dist/cjs/index.js" }, @@ -67,7 +66,6 @@ "rollup": "^4.0.0-24", "source-map-support": "^0.5.21" }, - "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/shared/rollup.config.mjs b/shared/rollup.config.mjs index 377390a95..a2652cf17 100644 --- a/shared/rollup.config.mjs +++ b/shared/rollup.config.mjs @@ -1,4 +1,5 @@ import { builtinModules } from 'module'; +import { promises as fs } from 'fs'; // eslint-disable-next-line import/no-extraneous-dependencies import typescript from '@rollup/plugin-typescript'; @@ -26,12 +27,13 @@ export function createConfig({ pkg, external = [] }) { file: pkg.main, exports: 'named', footer: 'module.exports = Object.assign(exports.default, exports);', + plugins: [emitDeclarationFile()], sourcemap: true }, { format: 'es', file: pkg.module, - plugins: [emitModulePackageFile()], + plugins: [emitModulePackageFile(), emitDeclarationFile()], sourcemap: true } ], @@ -51,3 +53,16 @@ export function emitModulePackageFile() { } }; } + +export function emitDeclarationFile() { + return { + name: 'emit-declaration-file', + async generateBundle() { + this.emitFile({ + type: 'asset', + fileName: 'index.d.ts', + source: await fs.readFile('./types/index.d.ts') + }); + } + }; +}