Skip to content

Commit

Permalink
building types as part of rollup build
Browse files Browse the repository at this point in the history
  • Loading branch information
ehrencrona committed Nov 14, 2020
1 parent 7c425f2 commit 5a9c17d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 25 deletions.
19 changes: 0 additions & 19 deletions packages/app-utils/cpr.js

This file was deleted.

1 change: 0 additions & 1 deletion packages/app-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"build": "npm run clean && rollup -c",
"lint": "eslint --ignore-pattern node_modules/ --ignore-pattern dist/ --ignore-pattern files/ --ignore-pattern http/ --ignore-pattern renderer/ '**/*.{ts,js,svelte}'",
"format": "prettier --write . --config ../../.prettierrc --ignore-path ../../.prettierignore",
"buildTypes": "tsc && node cpr build/types . && node cpr src/types types",
"prepare": "npm run build",
"prepublishOnly": "npm run build",
"test": "uvu -r ts-node/register"
Expand Down
29 changes: 24 additions & 5 deletions packages/app-utils/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import pkg from './package.json';
const fs = require('fs');
const path = require('path');

const input = {};
Object.keys(pkg.exports).forEach(key => {
Expand All @@ -27,10 +29,27 @@ export default {
],
plugins: [
nodeResolve(),
typescript()
typescript({ useTsconfigDeclarationDir: true }),
{
name: 'copy-types',
resolveId: () => null,
load: () => null,
writeBundle: (...args) => {
copyRecursiveSync('build/types', '.');
copyRecursiveSync('src/types', 'types');
}
}
],
external: [
...require('module').builtinModules,
...Object.keys(pkg.dependencies)
]
external: [...require('module').builtinModules, ...Object.keys(pkg.dependencies)]
};

function copyRecursiveSync(src, dest) {
if (fs.existsSync(src) && fs.statSync(src).isDirectory()) {
fs.mkdirSync(dest, { recursive: true });
fs.readdirSync(src).forEach(file =>
copyRecursiveSync(path.join(src, file), path.join(dest, file))
);
} else {
fs.copyFileSync(src, dest);
}
}

0 comments on commit 5a9c17d

Please sign in to comment.