Skip to content

Commit

Permalink
feat(jsx-runtime): inherit types from main build
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Sep 11, 2021
1 parent f2eb026 commit 2832279
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@
"@rollup/plugin-node-resolve": "13.0.4",
"@rollup/plugin-strip": "^2.0.0",
"@testing-library/dom": "^8.0.0",
"@types/glob": "^7.1.4",
"@types/jest": "^27.0.0",
"@types/node": "^16.4.8",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"eslint": "^7.24.0",
"eslint-config-prettier": "^8.1.0",
"glob": "^7.1.7",
"husky": "^7.0.0",
"jest": "^27.0.6",
"lint-staged": "^11.0.0",
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ rm -rf dist/*
rollup -c

info "\nDist: `ls -xm -d dist/*`\n"

node scripts/fixDeclarations.mjs
17 changes: 17 additions & 0 deletions scripts/fixDeclarations.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import glob from 'glob';
import { readFileSync, writeFileSync } from 'fs';

const replaceDupeTypes = (text) => {
const delim = 'type JSXVNode';
const [, types] = text.split(delim);
return `import { VDelta, VElement, VNode, VProps } from './million';
${delim}${types}`;
};

glob('dist/jsx-runtime.*', {}, (err, files) => {
if (err) console.error(err);
files.forEach((file) => {
const text = readFileSync(file, 'utf8');
writeFileSync(file, replaceDupeTypes(text));
});
});

0 comments on commit 2832279

Please sign in to comment.