2022-07-01 14:48:10 +02:00
|
|
|
// This script generates the TypeScript definitions
|
|
|
|
|
|
|
|
const { execSync } = require('child_process');
|
|
|
|
const { readFileSync, writeFileSync } = require('fs');
|
|
|
|
|
2023-03-15 16:38:03 +01:00
|
|
|
execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly', { stdio: 'inherit' });
|
2022-07-06 11:58:43 +02:00
|
|
|
// We need to add these types to the .d.ts files here because if we add them before building, the build will fail,
|
2022-07-01 14:48:10 +02:00
|
|
|
// because the TS->JS transformation doesn't know these exports are types and produces code that fails at runtime.
|
|
|
|
// We can't use `export type` syntax either because the TS version we're on doesn't have this feature yet.
|
2022-07-06 11:58:43 +02:00
|
|
|
|
|
|
|
function modify(path, modifyFn) {
|
|
|
|
const content = readFileSync(path, 'utf8');
|
|
|
|
writeFileSync(path, modifyFn(content));
|
|
|
|
}
|
|
|
|
|
|
|
|
modify(
|
|
|
|
'types/runtime/index.d.ts',
|
2022-07-25 21:09:03 +02:00
|
|
|
content => content.replace('SvelteComponentTyped', 'SvelteComponentTyped, ComponentType, ComponentConstructorOptions, ComponentProps, ComponentEvents')
|
2022-07-06 11:58:43 +02:00
|
|
|
);
|
|
|
|
modify(
|
|
|
|
'types/compiler/index.d.ts',
|
|
|
|
content => content + '\nexport { CompileOptions, ModuleFormat, EnableSourcemap, CssHashGetter } from "./interfaces"'
|
|
|
|
);
|