Skip to content

Commit 457cdf6

Browse files
mrkishiConduitry
authored andcommitted
create package.json stubs on build
1 parent b0604b5 commit 457cdf6

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
"dev": "rollup -cw",
3636
"pretest": "npm run build",
3737
"posttest": "agadoo internal/index.mjs",
38-
"prepublishOnly": "export PUBLISH=true && npm test && npm run create-stubs",
39-
"create-stubs": "node scripts/create-stubs.js",
38+
"prepublishOnly": "PUBLISH=true npm test",
4039
"tsd": "tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly",
4140
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
4241
},

rollup.config.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,22 @@ export default [
6161
external,
6262
plugins: [
6363
ts_plugin,
64-
dir === 'internal' && {
65-
generateBundle(options, bundle) {
66-
const mod = bundle['index.mjs'];
67-
if (mod) {
68-
fs.writeFileSync('src/compiler/compile/internal-exports.ts', `// This file is automatically generated\nexport default new Set(${JSON.stringify(mod.exports)});`);
64+
{
65+
writeBundle(bundle) {
66+
if (dir === 'internal') {
67+
const mod = bundle['index.mjs'];
68+
if (mod) {
69+
fs.writeFileSync('src/compiler/compile/internal-exports.ts', `// This file is automatically generated\nexport default new Set(${JSON.stringify(mod.exports)});`);
70+
}
6971
}
72+
73+
fs.writeFileSync(`${dir}/package.json`, JSON.stringify({
74+
main: './index',
75+
module: './index.mjs',
76+
types: './index.d.ts'
77+
}, null, ' '));
78+
79+
fs.writeFileSync(`${dir}/index.d.ts`, `export * from '../types/runtime/${dir}/index';`);
7080
}
7181
}
7282
]

scripts/create-stubs.js

-12
This file was deleted.

0 commit comments

Comments
 (0)