diff --git a/.gitignore b/.gitignore index d84ced3cc..ed1c9101d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ coverage.lcov !packages/commonjs/test/**/node_modules !packages/typescript/test/fixtures/**/node_modules !packages/typescript/test/fixtures/**/dist + +!packages/*/test-typings/node_modules diff --git a/packages/alias/package.json b/packages/alias/package.json index 9051cad88..a25af62b3 100755 --- a/packages/alias/package.json +++ b/packages/alias/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc --noEmit" }, "files": [ @@ -65,7 +72,7 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/alias/test-typings/cjs-node16/index.ts b/packages/alias/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/alias/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/alias/test-typings/cjs-node16/package.json b/packages/alias/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/alias/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/alias/test-typings/cjs-node16/tsconfig.json b/packages/alias/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/alias/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/alias/test-typings/esm-node16/index.ts b/packages/alias/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/alias/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/alias/test-typings/esm-node16/package.json b/packages/alias/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/alias/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/alias/test-typings/esm-node16/tsconfig.json b/packages/alias/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/alias/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/alias/test-typings/node10-commonjs/index.ts b/packages/alias/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/alias/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/alias/test-typings/node10-commonjs/tsconfig.json b/packages/alias/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/alias/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/alias/test-typings/node10-esnext/index.ts b/packages/alias/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/alias/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/alias/test-typings/node10-esnext/tsconfig.json b/packages/alias/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/alias/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/alias/test-typings/node_modules/current-package b/packages/alias/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/alias/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/alias/test-typings/tsconfig.json b/packages/alias/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/alias/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/auto-install/package.json b/packages/auto-install/package.json index 8d2346268..0c7d016ef 100755 --- a/packages/auto-install/package.json +++ b/packages/auto-install/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc --noEmit" }, "files": [ @@ -68,7 +75,7 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/auto-install/test-typings/cjs-node16/index.ts b/packages/auto-install/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/auto-install/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/auto-install/test-typings/cjs-node16/package.json b/packages/auto-install/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/auto-install/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/auto-install/test-typings/cjs-node16/tsconfig.json b/packages/auto-install/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/auto-install/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/auto-install/test-typings/esm-node16/index.ts b/packages/auto-install/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/auto-install/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/auto-install/test-typings/esm-node16/package.json b/packages/auto-install/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/auto-install/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/auto-install/test-typings/esm-node16/tsconfig.json b/packages/auto-install/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/auto-install/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/auto-install/test-typings/node10-commonjs/index.ts b/packages/auto-install/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/auto-install/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/auto-install/test-typings/node10-commonjs/tsconfig.json b/packages/auto-install/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/auto-install/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/auto-install/test-typings/node10-esnext/index.ts b/packages/auto-install/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/auto-install/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/auto-install/test-typings/node10-esnext/tsconfig.json b/packages/auto-install/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/auto-install/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/auto-install/test-typings/node_modules/current-package b/packages/auto-install/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/auto-install/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/auto-install/test-typings/tsconfig.json b/packages/auto-install/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/auto-install/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/babel/package.json b/packages/babel/package.json index f4668c20f..257a5febd 100644 --- a/packages/babel/package.json +++ b/packages/babel/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -82,7 +89,7 @@ "rollup": "^4.0.0-24", "source-map": "^0.7.4" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/babel/test-typings/cjs-node16/index.ts b/packages/babel/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/babel/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/babel/test-typings/cjs-node16/package.json b/packages/babel/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/babel/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/babel/test-typings/cjs-node16/tsconfig.json b/packages/babel/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/babel/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/babel/test-typings/esm-node16/index.ts b/packages/babel/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/babel/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/babel/test-typings/esm-node16/package.json b/packages/babel/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/babel/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/babel/test-typings/esm-node16/tsconfig.json b/packages/babel/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/babel/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/babel/test-typings/node10-commonjs/index.ts b/packages/babel/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/babel/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/babel/test-typings/node10-commonjs/tsconfig.json b/packages/babel/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/babel/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/babel/test-typings/node10-esnext/index.ts b/packages/babel/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/babel/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/babel/test-typings/node10-esnext/tsconfig.json b/packages/babel/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/babel/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/babel/test-typings/node_modules/current-package b/packages/babel/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/babel/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/babel/test-typings/tsconfig.json b/packages/babel/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/babel/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/beep/test-typings/cjs-node16/index.ts b/packages/beep/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/beep/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/beep/test-typings/cjs-node16/package.json b/packages/beep/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/beep/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/beep/test-typings/cjs-node16/tsconfig.json b/packages/beep/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/beep/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/beep/test-typings/esm-node16/index.ts b/packages/beep/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/beep/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/beep/test-typings/esm-node16/package.json b/packages/beep/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/beep/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/beep/test-typings/esm-node16/tsconfig.json b/packages/beep/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/beep/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/beep/test-typings/node10-commonjs/index.ts b/packages/beep/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/beep/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/beep/test-typings/node10-commonjs/tsconfig.json b/packages/beep/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/beep/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/beep/test-typings/node10-esnext/index.ts b/packages/beep/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/beep/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/beep/test-typings/node10-esnext/tsconfig.json b/packages/beep/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/beep/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/beep/test-typings/node_modules/current-package b/packages/beep/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/beep/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/beep/test-typings/tsconfig.json b/packages/beep/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/beep/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/buble/package.json b/packages/buble/package.json index 54f5cfb29..2891a5334 100644 --- a/packages/buble/package.json +++ b/packages/buble/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,8 +40,9 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", - "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", + "test:ts": "tsc --noEmit" }, "files": [ "dist", @@ -72,7 +79,7 @@ "source-map": "^0.7.4", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/buble/test-typings/cjs-node16/index.ts b/packages/buble/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/buble/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/buble/test-typings/cjs-node16/package.json b/packages/buble/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/buble/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/buble/test-typings/cjs-node16/tsconfig.json b/packages/buble/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/buble/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/buble/test-typings/esm-node16/index.ts b/packages/buble/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/buble/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/buble/test-typings/esm-node16/package.json b/packages/buble/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/buble/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/buble/test-typings/esm-node16/tsconfig.json b/packages/buble/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/buble/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/buble/test-typings/node10-commonjs/index.ts b/packages/buble/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/buble/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/buble/test-typings/node10-commonjs/tsconfig.json b/packages/buble/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/buble/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/buble/test-typings/node10-esnext/index.ts b/packages/buble/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/buble/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/buble/test-typings/node10-esnext/tsconfig.json b/packages/buble/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/buble/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/buble/test-typings/node_modules/current-package b/packages/buble/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/buble/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/buble/test-typings/tsconfig.json b/packages/buble/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/buble/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/commonjs/package.json b/packages/commonjs/package.json index f2b352869..6a2d29369 100644 --- a/packages/commonjs/package.json +++ b/packages/commonjs/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=16.0.0 || 14 >= 14.17" @@ -35,7 +41,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -80,7 +87,7 @@ "source-map-support": "^0.5.21", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/commonjs/test-typings/cjs-node16/index.ts b/packages/commonjs/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/commonjs/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/commonjs/test-typings/cjs-node16/package.json b/packages/commonjs/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/commonjs/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/commonjs/test-typings/cjs-node16/tsconfig.json b/packages/commonjs/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/commonjs/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/commonjs/test-typings/esm-node16/index.ts b/packages/commonjs/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/commonjs/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/commonjs/test-typings/esm-node16/package.json b/packages/commonjs/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/commonjs/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/commonjs/test-typings/esm-node16/tsconfig.json b/packages/commonjs/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/commonjs/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/commonjs/test-typings/node10-commonjs/index.ts b/packages/commonjs/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/commonjs/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/commonjs/test-typings/node10-commonjs/tsconfig.json b/packages/commonjs/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/commonjs/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/commonjs/test-typings/node10-esnext/index.ts b/packages/commonjs/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/commonjs/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/commonjs/test-typings/node10-esnext/tsconfig.json b/packages/commonjs/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/commonjs/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/commonjs/test-typings/node_modules/current-package b/packages/commonjs/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/commonjs/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/commonjs/test-typings/tsconfig.json b/packages/commonjs/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/commonjs/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/data-uri/package.json b/packages/data-uri/package.json index d74646536..be935e30b 100644 --- a/packages/data-uri/package.json +++ b/packages/data-uri/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build --sourcemap", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc --noEmit" }, "files": [ @@ -69,7 +76,7 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/data-uri/test-typings/cjs-node16/index.ts b/packages/data-uri/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/data-uri/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/data-uri/test-typings/cjs-node16/package.json b/packages/data-uri/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/data-uri/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/data-uri/test-typings/cjs-node16/tsconfig.json b/packages/data-uri/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/data-uri/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/data-uri/test-typings/esm-node16/index.ts b/packages/data-uri/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/data-uri/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/data-uri/test-typings/esm-node16/package.json b/packages/data-uri/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/data-uri/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/data-uri/test-typings/esm-node16/tsconfig.json b/packages/data-uri/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/data-uri/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/data-uri/test-typings/node10-commonjs/index.ts b/packages/data-uri/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/data-uri/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/data-uri/test-typings/node10-commonjs/tsconfig.json b/packages/data-uri/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/data-uri/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/data-uri/test-typings/node10-esnext/index.ts b/packages/data-uri/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/data-uri/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/data-uri/test-typings/node10-esnext/tsconfig.json b/packages/data-uri/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/data-uri/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/data-uri/test-typings/node_modules/current-package b/packages/data-uri/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/data-uri/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/data-uri/test-typings/tsconfig.json b/packages/data-uri/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/data-uri/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/dsv/package.json b/packages/dsv/package.json index 5dc0d5006..c0b8ebbe7 100755 --- a/packages/dsv/package.json +++ b/packages/dsv/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "scripts": { "build": "rollup -c", @@ -31,7 +37,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava" + "test": "pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean" }, "files": [ "dist", @@ -59,7 +66,7 @@ "del-cli": "^5.0.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/dsv/test-typings/cjs-node16/index.ts b/packages/dsv/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/dsv/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/dsv/test-typings/cjs-node16/package.json b/packages/dsv/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/dsv/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/dsv/test-typings/cjs-node16/tsconfig.json b/packages/dsv/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/dsv/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/dsv/test-typings/esm-node16/index.ts b/packages/dsv/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/dsv/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/dsv/test-typings/esm-node16/package.json b/packages/dsv/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/dsv/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/dsv/test-typings/esm-node16/tsconfig.json b/packages/dsv/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/dsv/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/dsv/test-typings/node10-commonjs/index.ts b/packages/dsv/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/dsv/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/dsv/test-typings/node10-commonjs/tsconfig.json b/packages/dsv/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/dsv/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/dsv/test-typings/node10-esnext/index.ts b/packages/dsv/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/dsv/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/dsv/test-typings/node10-esnext/tsconfig.json b/packages/dsv/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/dsv/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/dsv/test-typings/node_modules/current-package b/packages/dsv/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/dsv/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/dsv/test-typings/tsconfig.json b/packages/dsv/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/dsv/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/dynamic-import-vars/package.json b/packages/dynamic-import-vars/package.json index a3e6b46b2..359a55212 100644 --- a/packages/dynamic-import-vars/package.json +++ b/packages/dynamic-import-vars/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build --sourcemap", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava" + "test": "pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean" }, "files": [ "dist", @@ -74,7 +81,7 @@ "prettier": "^2.7.1", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/dynamic-import-vars/test-typings/cjs-node16/index.ts b/packages/dynamic-import-vars/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/dynamic-import-vars/test-typings/cjs-node16/package.json b/packages/dynamic-import-vars/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/dynamic-import-vars/test-typings/cjs-node16/tsconfig.json b/packages/dynamic-import-vars/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/dynamic-import-vars/test-typings/esm-node16/index.ts b/packages/dynamic-import-vars/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/dynamic-import-vars/test-typings/esm-node16/package.json b/packages/dynamic-import-vars/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/dynamic-import-vars/test-typings/esm-node16/tsconfig.json b/packages/dynamic-import-vars/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/dynamic-import-vars/test-typings/node10-commonjs/index.ts b/packages/dynamic-import-vars/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/dynamic-import-vars/test-typings/node10-commonjs/tsconfig.json b/packages/dynamic-import-vars/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/dynamic-import-vars/test-typings/node10-esnext/index.ts b/packages/dynamic-import-vars/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/dynamic-import-vars/test-typings/node10-esnext/tsconfig.json b/packages/dynamic-import-vars/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/dynamic-import-vars/test-typings/node_modules/current-package b/packages/dynamic-import-vars/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/dynamic-import-vars/test-typings/tsconfig.json b/packages/dynamic-import-vars/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/dynamic-import-vars/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/eslint/package.json b/packages/eslint/package.json index 7681a688c..8be85ff40 100755 --- a/packages/eslint/package.json +++ b/packages/eslint/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -72,7 +79,7 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/eslint/test-typings/cjs-node16/index.ts b/packages/eslint/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/eslint/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/eslint/test-typings/cjs-node16/package.json b/packages/eslint/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/eslint/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/eslint/test-typings/cjs-node16/tsconfig.json b/packages/eslint/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/eslint/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/eslint/test-typings/esm-node16/index.ts b/packages/eslint/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/eslint/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/eslint/test-typings/esm-node16/package.json b/packages/eslint/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/eslint/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/eslint/test-typings/esm-node16/tsconfig.json b/packages/eslint/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/eslint/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/eslint/test-typings/node10-commonjs/index.ts b/packages/eslint/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/eslint/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/eslint/test-typings/node10-commonjs/tsconfig.json b/packages/eslint/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/eslint/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/eslint/test-typings/node10-esnext/index.ts b/packages/eslint/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/eslint/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/eslint/test-typings/node10-esnext/tsconfig.json b/packages/eslint/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/eslint/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/eslint/test-typings/node_modules/current-package b/packages/eslint/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/eslint/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/eslint/test-typings/tsconfig.json b/packages/eslint/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/eslint/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/esm-shim/package.json b/packages/esm-shim/package.json index e9ba2c84a..c5842c43f 100644 --- a/packages/esm-shim/package.json +++ b/packages/esm-shim/package.json @@ -13,12 +13,18 @@ "author": "Peter Placzek ", "homepage": "https://github.com/rollup/plugins/tree/master/packages/esm-shim#readme", "bugs": "https://github.com/rollup/plugins/issues", - "main": "dist/cjs/index.js", - "module": "dist/es/index.js", + "main": "./dist/cjs/index.js", + "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -66,5 +73,5 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts" + "types": "./dist/cjs/index.d.ts" } diff --git a/packages/esm-shim/test-typings/cjs-node16/index.ts b/packages/esm-shim/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/esm-shim/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/esm-shim/test-typings/cjs-node16/package.json b/packages/esm-shim/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/esm-shim/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/esm-shim/test-typings/cjs-node16/tsconfig.json b/packages/esm-shim/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/esm-shim/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/esm-shim/test-typings/esm-node16/index.ts b/packages/esm-shim/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/esm-shim/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/esm-shim/test-typings/esm-node16/package.json b/packages/esm-shim/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/esm-shim/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/esm-shim/test-typings/esm-node16/tsconfig.json b/packages/esm-shim/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/esm-shim/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/esm-shim/test-typings/node10-commonjs/index.ts b/packages/esm-shim/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/esm-shim/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/esm-shim/test-typings/node10-commonjs/tsconfig.json b/packages/esm-shim/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/esm-shim/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/esm-shim/test-typings/node10-esnext/index.ts b/packages/esm-shim/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/esm-shim/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/esm-shim/test-typings/node10-esnext/tsconfig.json b/packages/esm-shim/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/esm-shim/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/esm-shim/test-typings/node_modules/current-package b/packages/esm-shim/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/esm-shim/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/esm-shim/test-typings/tsconfig.json b/packages/esm-shim/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/esm-shim/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/graphql/package.json b/packages/graphql/package.json index dc3565952..97b438d4c 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -35,7 +41,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -71,7 +78,7 @@ "graphql": "^16.6.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/graphql/test-typings/cjs-node16/index.ts b/packages/graphql/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/graphql/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/graphql/test-typings/cjs-node16/package.json b/packages/graphql/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/graphql/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/graphql/test-typings/cjs-node16/tsconfig.json b/packages/graphql/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/graphql/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/graphql/test-typings/esm-node16/index.ts b/packages/graphql/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/graphql/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/graphql/test-typings/esm-node16/package.json b/packages/graphql/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/graphql/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/graphql/test-typings/esm-node16/tsconfig.json b/packages/graphql/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/graphql/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/graphql/test-typings/node10-commonjs/index.ts b/packages/graphql/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/graphql/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/graphql/test-typings/node10-commonjs/tsconfig.json b/packages/graphql/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/graphql/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/graphql/test-typings/node10-esnext/index.ts b/packages/graphql/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/graphql/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/graphql/test-typings/node10-esnext/tsconfig.json b/packages/graphql/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/graphql/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/graphql/test-typings/node_modules/current-package b/packages/graphql/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/graphql/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/graphql/test-typings/tsconfig.json b/packages/graphql/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/graphql/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/html/package.json b/packages/html/package.json index 2f53e9062..2a08a96d1 100644 --- a/packages/html/package.json +++ b/packages/html/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc --noEmit" }, "files": [ @@ -65,7 +72,7 @@ "rollup-plugin-postcss": "^4.0.2", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/html/test-typings/cjs-node16/index.ts b/packages/html/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/html/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/html/test-typings/cjs-node16/package.json b/packages/html/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/html/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/html/test-typings/cjs-node16/tsconfig.json b/packages/html/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/html/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/html/test-typings/esm-node16/index.ts b/packages/html/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/html/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/html/test-typings/esm-node16/package.json b/packages/html/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/html/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/html/test-typings/esm-node16/tsconfig.json b/packages/html/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/html/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/html/test-typings/node10-commonjs/index.ts b/packages/html/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/html/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/html/test-typings/node10-commonjs/tsconfig.json b/packages/html/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/html/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/html/test-typings/node10-esnext/index.ts b/packages/html/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/html/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/html/test-typings/node10-esnext/tsconfig.json b/packages/html/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/html/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/html/test-typings/node_modules/current-package b/packages/html/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/html/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/html/test-typings/tsconfig.json b/packages/html/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/html/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/image/package.json b/packages/image/package.json index 17eac8963..ca421477f 100644 --- a/packages/image/package.json +++ b/packages/image/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava" + "test": "pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean" }, "files": [ "dist", @@ -65,7 +72,7 @@ "@rollup/plugin-buble": "^1.0.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/image/test-typings/cjs-node16/index.ts b/packages/image/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/image/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/image/test-typings/cjs-node16/package.json b/packages/image/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/image/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/image/test-typings/cjs-node16/tsconfig.json b/packages/image/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/image/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/image/test-typings/esm-node16/index.ts b/packages/image/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/image/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/image/test-typings/esm-node16/package.json b/packages/image/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/image/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/image/test-typings/esm-node16/tsconfig.json b/packages/image/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/image/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/image/test-typings/node10-commonjs/index.ts b/packages/image/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/image/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/image/test-typings/node10-commonjs/tsconfig.json b/packages/image/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/image/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/image/test-typings/node10-esnext/index.ts b/packages/image/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/image/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/image/test-typings/node10-esnext/tsconfig.json b/packages/image/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/image/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/image/test-typings/node_modules/current-package b/packages/image/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/image/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/image/test-typings/tsconfig.json b/packages/image/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/image/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/inject/package.json b/packages/inject/package.json index 7ecabd25f..ccc3dd95b 100644 --- a/packages/inject/package.json +++ b/packages/inject/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -73,7 +80,7 @@ "source-map": "^0.7.4", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/inject/test-typings/cjs-node16/index.ts b/packages/inject/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/inject/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/inject/test-typings/cjs-node16/package.json b/packages/inject/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/inject/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/inject/test-typings/cjs-node16/tsconfig.json b/packages/inject/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/inject/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/inject/test-typings/esm-node16/index.ts b/packages/inject/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/inject/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/inject/test-typings/esm-node16/package.json b/packages/inject/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/inject/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/inject/test-typings/esm-node16/tsconfig.json b/packages/inject/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/inject/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/inject/test-typings/node10-commonjs/index.ts b/packages/inject/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/inject/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/inject/test-typings/node10-commonjs/tsconfig.json b/packages/inject/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/inject/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/inject/test-typings/node10-esnext/index.ts b/packages/inject/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/inject/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/inject/test-typings/node10-esnext/tsconfig.json b/packages/inject/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/inject/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/inject/test-typings/node_modules/current-package b/packages/inject/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/inject/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/inject/test-typings/tsconfig.json b/packages/inject/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/inject/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/json/package.json b/packages/json/package.json index 5851ef6ed..3db56da5e 100755 --- a/packages/json/package.json +++ b/packages/json/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -69,7 +76,7 @@ "rollup": "^4.0.0-24", "source-map-support": "^0.5.21" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/json/test-typings/cjs-node16/index.ts b/packages/json/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/json/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/json/test-typings/cjs-node16/package.json b/packages/json/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/json/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/json/test-typings/cjs-node16/tsconfig.json b/packages/json/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/json/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/json/test-typings/esm-node16/index.ts b/packages/json/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/json/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/json/test-typings/esm-node16/package.json b/packages/json/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/json/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/json/test-typings/esm-node16/tsconfig.json b/packages/json/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/json/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/json/test-typings/node10-commonjs/index.ts b/packages/json/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/json/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/json/test-typings/node10-commonjs/tsconfig.json b/packages/json/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/json/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/json/test-typings/node10-esnext/index.ts b/packages/json/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/json/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/json/test-typings/node10-esnext/tsconfig.json b/packages/json/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/json/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/json/test-typings/node_modules/current-package b/packages/json/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/json/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/json/test-typings/tsconfig.json b/packages/json/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/json/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/legacy/package.json b/packages/legacy/package.json index 04b027ecd..f6e86c29c 100644 --- a/packages/legacy/package.json +++ b/packages/legacy/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava" + "test": "pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean" }, "files": [ "dist", @@ -63,7 +70,7 @@ "del-cli": "^5.0.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/legacy/test-typings/cjs-node16/index.ts b/packages/legacy/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..8e8f1f748 --- /dev/null +++ b/packages/legacy/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage({}); diff --git a/packages/legacy/test-typings/cjs-node16/package.json b/packages/legacy/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/legacy/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/legacy/test-typings/cjs-node16/tsconfig.json b/packages/legacy/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/legacy/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/legacy/test-typings/esm-node16/index.ts b/packages/legacy/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..8e8f1f748 --- /dev/null +++ b/packages/legacy/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage({}); diff --git a/packages/legacy/test-typings/esm-node16/package.json b/packages/legacy/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/legacy/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/legacy/test-typings/esm-node16/tsconfig.json b/packages/legacy/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/legacy/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/legacy/test-typings/node10-commonjs/index.ts b/packages/legacy/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..8e8f1f748 --- /dev/null +++ b/packages/legacy/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage({}); diff --git a/packages/legacy/test-typings/node10-commonjs/tsconfig.json b/packages/legacy/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/legacy/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/legacy/test-typings/node10-esnext/index.ts b/packages/legacy/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..8e8f1f748 --- /dev/null +++ b/packages/legacy/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage({}); diff --git a/packages/legacy/test-typings/node10-esnext/tsconfig.json b/packages/legacy/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/legacy/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/legacy/test-typings/node_modules/current-package b/packages/legacy/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/legacy/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/legacy/test-typings/tsconfig.json b/packages/legacy/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/legacy/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/multi-entry/package.json b/packages/multi-entry/package.json index 699a0eac1..aa7d7e56e 100755 --- a/packages/multi-entry/package.json +++ b/packages/multi-entry/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava" + "test": "pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean" }, "files": [ "dist", @@ -66,7 +73,7 @@ "devDependencies": { "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/multi-entry/test-typings/cjs-node16/index.ts b/packages/multi-entry/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/multi-entry/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/multi-entry/test-typings/cjs-node16/package.json b/packages/multi-entry/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/multi-entry/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/multi-entry/test-typings/cjs-node16/tsconfig.json b/packages/multi-entry/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/multi-entry/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/multi-entry/test-typings/esm-node16/index.ts b/packages/multi-entry/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/multi-entry/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/multi-entry/test-typings/esm-node16/package.json b/packages/multi-entry/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/multi-entry/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/multi-entry/test-typings/esm-node16/tsconfig.json b/packages/multi-entry/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/multi-entry/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/multi-entry/test-typings/node10-commonjs/index.ts b/packages/multi-entry/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/multi-entry/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/multi-entry/test-typings/node10-commonjs/tsconfig.json b/packages/multi-entry/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/multi-entry/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/multi-entry/test-typings/node10-esnext/index.ts b/packages/multi-entry/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/multi-entry/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/multi-entry/test-typings/node10-esnext/tsconfig.json b/packages/multi-entry/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/multi-entry/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/multi-entry/test-typings/node_modules/current-package b/packages/multi-entry/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/multi-entry/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/multi-entry/test-typings/tsconfig.json b/packages/multi-entry/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/multi-entry/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/node-resolve/package.json b/packages/node-resolve/package.json index 77ea2a20b..2aa385e08 100644 --- a/packages/node-resolve/package.json +++ b/packages/node-resolve/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -35,7 +41,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "pnpm test:ts && ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -78,7 +85,7 @@ "source-map": "^0.7.4", "string-capitalize": "^1.0.1" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/node-resolve/test-typings/cjs-node16/index.ts b/packages/node-resolve/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/node-resolve/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/node-resolve/test-typings/cjs-node16/package.json b/packages/node-resolve/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/node-resolve/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/node-resolve/test-typings/cjs-node16/tsconfig.json b/packages/node-resolve/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/node-resolve/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/node-resolve/test-typings/esm-node16/index.ts b/packages/node-resolve/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/node-resolve/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/node-resolve/test-typings/esm-node16/package.json b/packages/node-resolve/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/node-resolve/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/node-resolve/test-typings/esm-node16/tsconfig.json b/packages/node-resolve/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/node-resolve/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/node-resolve/test-typings/node10-commonjs/index.ts b/packages/node-resolve/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/node-resolve/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/node-resolve/test-typings/node10-commonjs/tsconfig.json b/packages/node-resolve/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/node-resolve/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/node-resolve/test-typings/node10-esnext/index.ts b/packages/node-resolve/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/node-resolve/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/node-resolve/test-typings/node10-esnext/tsconfig.json b/packages/node-resolve/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/node-resolve/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/node-resolve/test-typings/node_modules/current-package b/packages/node-resolve/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/node-resolve/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/node-resolve/test-typings/tsconfig.json b/packages/node-resolve/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/node-resolve/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/pluginutils/package.json b/packages/pluginutils/package.json index 2745ddcce..5207a0b15 100644 --- a/packages/pluginutils/package.json +++ b/packages/pluginutils/package.json @@ -19,9 +19,14 @@ "module": "./dist/es/index.js", "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -38,6 +43,7 @@ "pretest": "pnpm build --sourcemap", "release": "pnpm --workspace-root package:release $(pwd)", "test": "ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc --noEmit" }, "files": [ @@ -75,7 +81,7 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "extensions": [ "ts" diff --git a/packages/replace/package.json b/packages/replace/package.json index 0a07d5abe..d9578db29 100644 --- a/packages/replace/package.json +++ b/packages/replace/package.json @@ -13,12 +13,18 @@ "author": "Rich Harris ", "homepage": "https://github.com/rollup/plugins/tree/master/packages/replace#readme", "bugs": "https://github.com/rollup/plugins/issues", - "main": "dist/cjs/index.js", - "module": "dist/es/index.js", + "main": "./dist/cjs/index.js", + "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -72,7 +79,7 @@ "source-map": "^0.7.4", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/replace/test-typings/cjs-node16/index.ts b/packages/replace/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/replace/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/replace/test-typings/cjs-node16/package.json b/packages/replace/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/replace/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/replace/test-typings/cjs-node16/tsconfig.json b/packages/replace/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/replace/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/replace/test-typings/esm-node16/index.ts b/packages/replace/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/replace/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/replace/test-typings/esm-node16/package.json b/packages/replace/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/replace/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/replace/test-typings/esm-node16/tsconfig.json b/packages/replace/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/replace/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/replace/test-typings/node10-commonjs/index.ts b/packages/replace/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/replace/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/replace/test-typings/node10-commonjs/tsconfig.json b/packages/replace/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/replace/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/replace/test-typings/node10-esnext/index.ts b/packages/replace/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/replace/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/replace/test-typings/node10-esnext/tsconfig.json b/packages/replace/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/replace/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/replace/test-typings/node_modules/current-package b/packages/replace/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/replace/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/replace/test-typings/tsconfig.json b/packages/replace/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/replace/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/run/package.json b/packages/run/package.json index e13c22be4..cf42c958b 100644 --- a/packages/run/package.json +++ b/packages/run/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava" + "test": "pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean" }, "files": [ "dist", @@ -66,7 +73,7 @@ "sinon": "^14.0.0", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/run/test-typings/cjs-node16/index.ts b/packages/run/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/run/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/run/test-typings/cjs-node16/package.json b/packages/run/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/run/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/run/test-typings/cjs-node16/tsconfig.json b/packages/run/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/run/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/run/test-typings/esm-node16/index.ts b/packages/run/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/run/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/run/test-typings/esm-node16/package.json b/packages/run/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/run/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/run/test-typings/esm-node16/tsconfig.json b/packages/run/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/run/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/run/test-typings/node10-commonjs/index.ts b/packages/run/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/run/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/run/test-typings/node10-commonjs/tsconfig.json b/packages/run/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/run/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/run/test-typings/node10-esnext/index.ts b/packages/run/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/run/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/run/test-typings/node10-esnext/tsconfig.json b/packages/run/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/run/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/run/test-typings/node_modules/current-package b/packages/run/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/run/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/run/test-typings/tsconfig.json b/packages/run/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/run/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/strip/package.json b/packages/strip/package.json index b3272cede..2c335b49a 100644 --- a/packages/strip/package.json +++ b/packages/strip/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -33,7 +39,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava" + "test": "pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean" }, "files": [ "dist", @@ -63,7 +70,7 @@ "acorn": "^8.8.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/strip/test-typings/cjs-node16/index.ts b/packages/strip/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/strip/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/strip/test-typings/cjs-node16/package.json b/packages/strip/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/strip/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/strip/test-typings/cjs-node16/tsconfig.json b/packages/strip/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/strip/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/strip/test-typings/esm-node16/index.ts b/packages/strip/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/strip/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/strip/test-typings/esm-node16/package.json b/packages/strip/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/strip/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/strip/test-typings/esm-node16/tsconfig.json b/packages/strip/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/strip/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/strip/test-typings/node10-commonjs/index.ts b/packages/strip/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/strip/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/strip/test-typings/node10-commonjs/tsconfig.json b/packages/strip/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/strip/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/strip/test-typings/node10-esnext/index.ts b/packages/strip/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/strip/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/strip/test-typings/node10-esnext/tsconfig.json b/packages/strip/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/strip/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/strip/test-typings/node_modules/current-package b/packages/strip/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/strip/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/strip/test-typings/tsconfig.json b/packages/strip/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/strip/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/sucrase/package.json b/packages/sucrase/package.json index 986376ab6..1ff1186fd 100644 --- a/packages/sucrase/package.json +++ b/packages/sucrase/package.json @@ -17,9 +17,14 @@ "module": "./dist/es/index.js", "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -35,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -69,7 +75,7 @@ "@rollup/plugin-alias": "^4.0.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/sucrase/test-typings/cjs-node16/index.ts b/packages/sucrase/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/sucrase/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/sucrase/test-typings/cjs-node16/package.json b/packages/sucrase/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/sucrase/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/sucrase/test-typings/cjs-node16/tsconfig.json b/packages/sucrase/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/sucrase/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/sucrase/test-typings/esm-node16/index.ts b/packages/sucrase/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/sucrase/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/sucrase/test-typings/esm-node16/package.json b/packages/sucrase/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/sucrase/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/sucrase/test-typings/esm-node16/tsconfig.json b/packages/sucrase/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/sucrase/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/sucrase/test-typings/node10-commonjs/index.ts b/packages/sucrase/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/sucrase/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/sucrase/test-typings/node10-commonjs/tsconfig.json b/packages/sucrase/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/sucrase/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/sucrase/test-typings/node10-esnext/index.ts b/packages/sucrase/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/sucrase/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/sucrase/test-typings/node10-esnext/tsconfig.json b/packages/sucrase/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/sucrase/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/sucrase/test-typings/node_modules/current-package b/packages/sucrase/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/sucrase/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/sucrase/test-typings/tsconfig.json b/packages/sucrase/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/sucrase/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/swc/package.json b/packages/swc/package.json index 3dee9d25e..9ce6c7cc1 100644 --- a/packages/swc/package.json +++ b/packages/swc/package.json @@ -13,12 +13,18 @@ "author": "Peter Placzek ", "homepage": "https://github.com/rollup/plugins/tree/master/packages/swc#readme", "bugs": "https://github.com/rollup/plugins/issues", - "main": "dist/cjs/index.js", - "module": "dist/es/index.js", + "main": "./dist/cjs/index.js", + "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -70,5 +77,5 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts" + "types": "./dist/cjs/index.d.ts" } diff --git a/packages/swc/test-typings/cjs-node16/index.ts b/packages/swc/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/swc/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/swc/test-typings/cjs-node16/package.json b/packages/swc/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/swc/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/swc/test-typings/cjs-node16/tsconfig.json b/packages/swc/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/swc/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/swc/test-typings/esm-node16/index.ts b/packages/swc/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/swc/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/swc/test-typings/esm-node16/package.json b/packages/swc/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/swc/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/swc/test-typings/esm-node16/tsconfig.json b/packages/swc/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/swc/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/swc/test-typings/node10-commonjs/index.ts b/packages/swc/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/swc/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/swc/test-typings/node10-commonjs/tsconfig.json b/packages/swc/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/swc/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/swc/test-typings/node10-esnext/index.ts b/packages/swc/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/swc/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/swc/test-typings/node10-esnext/tsconfig.json b/packages/swc/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/swc/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/swc/test-typings/node_modules/current-package b/packages/swc/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/swc/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/swc/test-typings/tsconfig.json b/packages/swc/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/swc/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/terser/package.json b/packages/terser/package.json index 24f9a35a6..73d68dea3 100644 --- a/packages/terser/package.json +++ b/packages/terser/package.json @@ -13,12 +13,18 @@ "author": "Peter Placzek ", "homepage": "https://github.com/rollup/plugins/tree/master/packages/terser#readme", "bugs": "https://github.com/rollup/plugins/issues", - "main": "dist/cjs/index.js", - "module": "dist/es/index.js", + "main": "./dist/cjs/index.js", + "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc types/index.d.ts test/types.ts --noEmit" }, "files": [ @@ -70,5 +77,5 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts" + "types": "./dist/cjs/index.d.ts" } diff --git a/packages/terser/test-typings/cjs-node16/index.ts b/packages/terser/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/terser/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/terser/test-typings/cjs-node16/package.json b/packages/terser/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/terser/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/terser/test-typings/cjs-node16/tsconfig.json b/packages/terser/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/terser/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/terser/test-typings/esm-node16/index.ts b/packages/terser/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/terser/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/terser/test-typings/esm-node16/package.json b/packages/terser/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/terser/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/terser/test-typings/esm-node16/tsconfig.json b/packages/terser/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/terser/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/terser/test-typings/node10-commonjs/index.ts b/packages/terser/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/terser/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/terser/test-typings/node10-commonjs/tsconfig.json b/packages/terser/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/terser/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/terser/test-typings/node10-esnext/index.ts b/packages/terser/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/terser/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/terser/test-typings/node10-esnext/tsconfig.json b/packages/terser/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/terser/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/terser/test-typings/node_modules/current-package b/packages/terser/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/terser/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/terser/test-typings/tsconfig.json b/packages/terser/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/terser/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/typescript/package.json b/packages/typescript/package.json index d1ac060ed..cb6e3aeb0 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc --noEmit" }, "files": [ @@ -76,5 +83,5 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts" + "types": "./dist/cjs/index.d.ts" } diff --git a/packages/typescript/test-typings/cjs-node16/index.ts b/packages/typescript/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/typescript/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/typescript/test-typings/cjs-node16/package.json b/packages/typescript/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/typescript/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/typescript/test-typings/cjs-node16/tsconfig.json b/packages/typescript/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/typescript/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/typescript/test-typings/esm-node16/index.ts b/packages/typescript/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/typescript/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/typescript/test-typings/esm-node16/package.json b/packages/typescript/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/typescript/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/typescript/test-typings/esm-node16/tsconfig.json b/packages/typescript/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/typescript/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/typescript/test-typings/node10-commonjs/index.ts b/packages/typescript/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/typescript/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/typescript/test-typings/node10-commonjs/tsconfig.json b/packages/typescript/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/typescript/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/typescript/test-typings/node10-esnext/index.ts b/packages/typescript/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/typescript/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/typescript/test-typings/node10-esnext/tsconfig.json b/packages/typescript/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/typescript/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/typescript/test-typings/node_modules/current-package b/packages/typescript/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/typescript/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/typescript/test-typings/tsconfig.json b/packages/typescript/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/typescript/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/url/package.json b/packages/url/package.json index 6883535d5..31cfcac43 100644 --- a/packages/url/package.json +++ b/packages/url/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava" + "test": "pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean" }, "files": [ "dist", @@ -66,7 +73,7 @@ "globby": "^11.1.0", "rollup": "^4.0.0-24" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/url/test-typings/cjs-node16/index.ts b/packages/url/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/url/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/url/test-typings/cjs-node16/package.json b/packages/url/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/url/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/url/test-typings/cjs-node16/tsconfig.json b/packages/url/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/url/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/url/test-typings/esm-node16/index.ts b/packages/url/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/url/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/url/test-typings/esm-node16/package.json b/packages/url/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/url/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/url/test-typings/esm-node16/tsconfig.json b/packages/url/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/url/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/url/test-typings/node10-commonjs/index.ts b/packages/url/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/url/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/url/test-typings/node10-commonjs/tsconfig.json b/packages/url/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/url/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/url/test-typings/node10-esnext/index.ts b/packages/url/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/url/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/url/test-typings/node10-esnext/tsconfig.json b/packages/url/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/url/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/url/test-typings/node_modules/current-package b/packages/url/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/url/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/url/test-typings/tsconfig.json b/packages/url/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/url/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/virtual/package.json b/packages/virtual/package.json index e3bf35706..b5eb718a8 100755 --- a/packages/virtual/package.json +++ b/packages/virtual/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc --noEmit" }, "files": [ @@ -66,7 +73,7 @@ "rollup": "^4.0.0-24", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "files": [ "!**/fixtures/**", diff --git a/packages/virtual/test-typings/cjs-node16/index.ts b/packages/virtual/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..8e8f1f748 --- /dev/null +++ b/packages/virtual/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage({}); diff --git a/packages/virtual/test-typings/cjs-node16/package.json b/packages/virtual/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/virtual/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/virtual/test-typings/cjs-node16/tsconfig.json b/packages/virtual/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/virtual/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/virtual/test-typings/esm-node16/index.ts b/packages/virtual/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..8e8f1f748 --- /dev/null +++ b/packages/virtual/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage({}); diff --git a/packages/virtual/test-typings/esm-node16/package.json b/packages/virtual/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/virtual/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/virtual/test-typings/esm-node16/tsconfig.json b/packages/virtual/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/virtual/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/virtual/test-typings/node10-commonjs/index.ts b/packages/virtual/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..8e8f1f748 --- /dev/null +++ b/packages/virtual/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage({}); diff --git a/packages/virtual/test-typings/node10-commonjs/tsconfig.json b/packages/virtual/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/virtual/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/virtual/test-typings/node10-esnext/index.ts b/packages/virtual/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..8e8f1f748 --- /dev/null +++ b/packages/virtual/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage({}); diff --git a/packages/virtual/test-typings/node10-esnext/tsconfig.json b/packages/virtual/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/virtual/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/virtual/test-typings/node_modules/current-package b/packages/virtual/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/virtual/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/virtual/test-typings/tsconfig.json b/packages/virtual/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/virtual/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/wasm/package.json b/packages/wasm/package.json index c4723c27b..f69f0b221 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava", + "test": "pnpm test:ts && pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean", "test:ts": "tsc --noEmit" }, "files": [ @@ -72,7 +79,7 @@ "source-map": "^0.7.4", "typescript": "^4.8.3" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/wasm/test-typings/cjs-node16/index.ts b/packages/wasm/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/wasm/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/wasm/test-typings/cjs-node16/package.json b/packages/wasm/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/wasm/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/wasm/test-typings/cjs-node16/tsconfig.json b/packages/wasm/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/wasm/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/wasm/test-typings/esm-node16/index.ts b/packages/wasm/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/wasm/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/wasm/test-typings/esm-node16/package.json b/packages/wasm/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/wasm/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/wasm/test-typings/esm-node16/tsconfig.json b/packages/wasm/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/wasm/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/wasm/test-typings/node10-commonjs/index.ts b/packages/wasm/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/wasm/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/wasm/test-typings/node10-commonjs/tsconfig.json b/packages/wasm/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/wasm/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/wasm/test-typings/node10-esnext/index.ts b/packages/wasm/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/wasm/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/wasm/test-typings/node10-esnext/tsconfig.json b/packages/wasm/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/wasm/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/wasm/test-typings/node_modules/current-package b/packages/wasm/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/wasm/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/wasm/test-typings/tsconfig.json b/packages/wasm/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/wasm/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/packages/yaml/package.json b/packages/yaml/package.json index cd7c102ab..77de8f14d 100755 --- a/packages/yaml/package.json +++ b/packages/yaml/package.json @@ -15,10 +15,16 @@ "bugs": "https://github.com/rollup/plugins/issues", "main": "./dist/cjs/index.js", "module": "./dist/es/index.js", + "type": "commonjs", "exports": { - "types": "./types/index.d.ts", - "import": "./dist/es/index.js", - "default": "./dist/cjs/index.js" + "require": { + "types": "./dist/cjs/index.d.ts", + "default": "./dist/cjs/index.js" + }, + "import": { + "types": "./dist/es/index.d.ts", + "default": "./dist/es/index.js" + } }, "engines": { "node": ">=14.0.0" @@ -34,7 +40,8 @@ "prerelease": "pnpm build", "pretest": "pnpm build", "release": "pnpm --workspace-root package:release $(pwd)", - "test": "ava" + "test": "pnpm test:dts && ava", + "test:dts": "tsc --build ./test-typings && tsc --build ./test-typings --clean" }, "files": [ "dist", @@ -67,7 +74,7 @@ "rollup": "^4.0.0-24", "source-map-support": "^0.5.21" }, - "types": "./types/index.d.ts", + "types": "./dist/cjs/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/yaml/test-typings/cjs-node16/index.ts b/packages/yaml/test-typings/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/yaml/test-typings/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/yaml/test-typings/cjs-node16/package.json b/packages/yaml/test-typings/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/packages/yaml/test-typings/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/packages/yaml/test-typings/cjs-node16/tsconfig.json b/packages/yaml/test-typings/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/packages/yaml/test-typings/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/yaml/test-typings/esm-node16/index.ts b/packages/yaml/test-typings/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/yaml/test-typings/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/yaml/test-typings/esm-node16/package.json b/packages/yaml/test-typings/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/packages/yaml/test-typings/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/packages/yaml/test-typings/esm-node16/tsconfig.json b/packages/yaml/test-typings/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/packages/yaml/test-typings/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/yaml/test-typings/node10-commonjs/index.ts b/packages/yaml/test-typings/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/yaml/test-typings/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/yaml/test-typings/node10-commonjs/tsconfig.json b/packages/yaml/test-typings/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/packages/yaml/test-typings/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/yaml/test-typings/node10-esnext/index.ts b/packages/yaml/test-typings/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/packages/yaml/test-typings/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/packages/yaml/test-typings/node10-esnext/tsconfig.json b/packages/yaml/test-typings/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/packages/yaml/test-typings/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/packages/yaml/test-typings/node_modules/current-package b/packages/yaml/test-typings/node_modules/current-package new file mode 120000 index 000000000..6581736d6 --- /dev/null +++ b/packages/yaml/test-typings/node_modules/current-package @@ -0,0 +1 @@ +../../ \ No newline at end of file diff --git a/packages/yaml/test-typings/tsconfig.json b/packages/yaml/test-typings/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/packages/yaml/test-typings/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +} diff --git a/shared/rollup.config.mjs b/shared/rollup.config.mjs index 377390a95..f113b4b00 100644 --- a/shared/rollup.config.mjs +++ b/shared/rollup.config.mjs @@ -1,12 +1,15 @@ +// @ts-check import { builtinModules } from 'module'; +import fs from 'node:fs/promises'; // eslint-disable-next-line import/no-extraneous-dependencies import typescript from '@rollup/plugin-typescript'; /** * Create a base rollup config - * @param {Record} pkg Imported package.json - * @param {string[]} external Imported package.json + * @param {Object} param + * @param {Record} param.pkg Imported package.json + * @param {string[]} [param.external] Dependencies that should remain external * @returns {import('rollup').RollupOptions} */ export function createConfig({ pkg, external = [] }) { @@ -26,12 +29,13 @@ export function createConfig({ pkg, external = [] }) { file: pkg.main, exports: 'named', footer: 'module.exports = Object.assign(exports.default, exports);', + plugins: emitCjsTypings(), sourcemap: true }, { format: 'es', file: pkg.module, - plugins: [emitModulePackageFile()], + plugins: emitEsmTypings(), sourcemap: true } ], @@ -39,14 +43,56 @@ export function createConfig({ pkg, external = [] }) { }; } -export function emitModulePackageFile() { +/** + * @returns {Array} + */ +export function emitCjsTypings() { + return [ + { + name: 'emit-cjs-types', + async generateBundle() { + this.emitFile({ + type: 'asset', + fileName: `index.d.ts`, + source: await fs.readFile('./types/index.d.ts') + }); + } + }, + emitPackageFile('commonjs') + ]; +} + +/** + * @returns {Array} + */ +function emitEsmTypings() { + return [ + { + name: 'emit-esm-declaration-file', + async generateBundle() { + this.emitFile({ + type: 'asset', + fileName: `index.d.ts`, + source: await fs.readFile('./types/index.d.ts') + }); + } + }, + emitPackageFile('module') + ]; +} + +/** + * @param {'module' | 'commonjs'} type + * @returns {import('rollup').Plugin} + */ +function emitPackageFile(type) { return { - name: 'emit-module-package-file', + name: 'emit-package-file', generateBundle() { this.emitFile({ type: 'asset', fileName: 'package.json', - source: `{"type":"module"}` + source: `{"type":"${type}"}` }); } }; diff --git a/shared/test-typings-template/cjs-node16/index.ts b/shared/test-typings-template/cjs-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/shared/test-typings-template/cjs-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/shared/test-typings-template/cjs-node16/package.json b/shared/test-typings-template/cjs-node16/package.json new file mode 100644 index 000000000..5bbefffba --- /dev/null +++ b/shared/test-typings-template/cjs-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/shared/test-typings-template/cjs-node16/tsconfig.json b/shared/test-typings-template/cjs-node16/tsconfig.json new file mode 100644 index 000000000..be7957356 --- /dev/null +++ b/shared/test-typings-template/cjs-node16/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node16", + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/shared/test-typings-template/esm-node16/index.ts b/shared/test-typings-template/esm-node16/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/shared/test-typings-template/esm-node16/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/shared/test-typings-template/esm-node16/package.json b/shared/test-typings-template/esm-node16/package.json new file mode 100644 index 000000000..3dbc1ca59 --- /dev/null +++ b/shared/test-typings-template/esm-node16/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/shared/test-typings-template/esm-node16/tsconfig.json b/shared/test-typings-template/esm-node16/tsconfig.json new file mode 100644 index 000000000..66f48fc06 --- /dev/null +++ b/shared/test-typings-template/esm-node16/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "module": "Node16", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/shared/test-typings-template/node10-commonjs/index.ts b/shared/test-typings-template/node10-commonjs/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/shared/test-typings-template/node10-commonjs/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/shared/test-typings-template/node10-commonjs/tsconfig.json b/shared/test-typings-template/node10-commonjs/tsconfig.json new file mode 100644 index 000000000..6499170a7 --- /dev/null +++ b/shared/test-typings-template/node10-commonjs/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "CommonJS", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/shared/test-typings-template/node10-esnext/index.ts b/shared/test-typings-template/node10-esnext/index.ts new file mode 100644 index 000000000..91eeaa945 --- /dev/null +++ b/shared/test-typings-template/node10-esnext/index.ts @@ -0,0 +1,3 @@ +import currentPackage from 'current-package'; + +currentPackage(); diff --git a/shared/test-typings-template/node10-esnext/tsconfig.json b/shared/test-typings-template/node10-esnext/tsconfig.json new file mode 100644 index 000000000..61daac90a --- /dev/null +++ b/shared/test-typings-template/node10-esnext/tsconfig.json @@ -0,0 +1,11 @@ +{ + "include": ["./index.ts"], + "compilerOptions": { + "moduleResolution": "Node", + "module": "ESNext", + "composite": true, + "tsBuildInfoFile": "output/.tsbuildinfo", + "skipLibCheck": true, + "noEmit": true + } +} diff --git a/shared/test-typings-template/tsconfig.json b/shared/test-typings-template/tsconfig.json new file mode 100644 index 000000000..72e215ae2 --- /dev/null +++ b/shared/test-typings-template/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": [], + "references": [ + { "path": "./esm-node16" }, + { "path": "./cjs-node16" }, + { "path": "./node10-esnext" }, + { "path": "./node10-commonjs" } + ] +}