From d0e46e0bcc869a64ec96ebaef2dba633bb8a9998 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 5 Jul 2022 19:10:32 +0200 Subject: [PATCH 1/3] [fix] export CompileOptions It's are used by SvelteKit and in order to properly use it under the new TS moduleResolution NodeNext it needs to be part of a file that is defined in the exports map --- generate-type-definitions.js | 19 +++++++++++++++---- src/compiler/index.ts | 1 + src/runtime/index.ts | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/generate-type-definitions.js b/generate-type-definitions.js index 6cad31807f0..00b079eb5d6 100644 --- a/generate-type-definitions.js +++ b/generate-type-definitions.js @@ -5,9 +5,20 @@ const { readFileSync, writeFileSync } = require('fs'); execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly'); -// We need to add these types to the index.d.ts here because if we add them before building, the build will fail, +// We need to add these types to the .d.ts files here because if we add them before building, the build will fail, // 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. -const path = 'types/runtime/index.d.ts'; -const content = readFileSync(path, 'utf8'); -writeFileSync(path, content.replace('SvelteComponentTyped', 'SvelteComponentTyped, ComponentType, ComponentConstructorOptions, ComponentProps')); + +function modify(path, modifyFn) { + const content = readFileSync(path, 'utf8'); + writeFileSync(path, modifyFn(content)); +} + +modify( + 'types/runtime/index.d.ts', + content => content.replace('SvelteComponentTyped', 'SvelteComponentTyped, ComponentType, ComponentConstructorOptions, ComponentProps') +); +modify( + 'types/compiler/index.d.ts', + content => content + '\nexport { CompileOptions, ModuleFormat, EnableSourcemap, CssHashGetter } from "./interfaces"' +); diff --git a/src/compiler/index.ts b/src/compiler/index.ts index 14d55f5470d..29c8d48e4b2 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -4,3 +4,4 @@ export { default as preprocess } from './preprocess/index'; export { walk } from 'estree-walker'; export const VERSION = '__VERSION__'; +// additional exports added through generate-type-definitions.js \ No newline at end of file diff --git a/src/runtime/index.ts b/src/runtime/index.ts index 08b25ba2ca4..2029f67a046 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -13,5 +13,5 @@ export { createEventDispatcher, SvelteComponentDev as SvelteComponent, SvelteComponentTyped - // additional exports added through post-typegen.js + // additional exports added through generate-type-definitions.js } from 'svelte/internal'; From 7c74bc790576a59eede2b860f82b48ae14f59426 Mon Sep 17 00:00:00 2001 From: Simon Date: Tue, 5 Jul 2022 19:15:38 +0200 Subject: [PATCH 2/3] ok I lied about running the linter locally --- src/compiler/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/index.ts b/src/compiler/index.ts index 29c8d48e4b2..60447dfdcb6 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -4,4 +4,4 @@ export { default as preprocess } from './preprocess/index'; export { walk } from 'estree-walker'; export const VERSION = '__VERSION__'; -// additional exports added through generate-type-definitions.js \ No newline at end of file +// additional exports added through generate-type-definitions.js From 6a100db86bcafb8c9be065b9cae0b92387738e1a Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Tue, 5 Jul 2022 23:47:26 +0200 Subject: [PATCH 3/3] Update src/compiler/index.ts Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> --- src/compiler/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/index.ts b/src/compiler/index.ts index 60447dfdcb6..76eb45d37fb 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -4,4 +4,4 @@ export { default as preprocess } from './preprocess/index'; export { walk } from 'estree-walker'; export const VERSION = '__VERSION__'; -// additional exports added through generate-type-definitions.js +// additional exports added through generate-type-definitions.js