Skip to content

Commit

Permalink
incremental...
Browse files Browse the repository at this point in the history
  • Loading branch information
AsPulse committed Dec 14, 2023
1 parent 5255365 commit 44f9128
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 17 additions & 3 deletions packages/core/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { execa } from 'execa';
import { nodeExternalsPlugin } from 'esbuild-node-externals';
import packageJson from './package.json' assert { type: 'json' };
import { transfer } from 'multi-stage-sourcemap';
import { createCompilerHost, createIncrementalCompilerHost, createProgram } from 'typescript';

Check warning on line 10 in packages/core/build.ts

View workflow job for this annotation

GitHub Actions / eslint

'createCompilerHost' is defined but never used

const entry = './lib.ts';

Expand Down Expand Up @@ -65,9 +66,22 @@ async function bundle() {
async function types() {
const output = join(packageJson.exports['.'].types);
consola.start('Building types...');
await execa('dts-bundle-generator', ['-o', output, entry])
.pipeStdout?.(process.stdout)
.pipeStderr?.(process.stderr);

const createdFiles: Record<string, string> = {};

await writeFile('./dist/index.ts', (await bundled).source);
const options = {
declaration: true,
declarationMap: true,
emitDeclarationOnly: true,
};
const host = createIncrementalCompilerHost(options);
host.writeFile = (fileName: string, contents: string) => createdFiles[fileName] = contents;

const program = createProgram(['./dist/index.ts'], options, host);
program.emit();

console.log(createdFiles);
consola.success(`Done! (${output})`);
}

Expand Down
4 changes: 3 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "@repo/typescript-config/react-library.json",
"compilerOptions": {
"outDir": "dist"
"outDir": "dist",
"incremental": true,
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
},
"include": ["../**/*.ts", "../**/*.tsx"],
"exclude": ["node_modules", "dist"]
Expand Down

0 comments on commit 44f9128

Please sign in to comment.