diff options
author | 2021-04-30 09:35:18 -0500 | |
---|---|---|
committer | 2021-04-30 09:35:18 -0500 | |
commit | 509fad6b9a0b4925a85daf95aa9699d726f69ed0 (patch) | |
tree | 58cd7f6685fb34674e04e9881209d44e8511688a /src/compiler/codegen/index.ts | |
parent | f1a7b5ba9419bb84a4fd9d478c9feb8b9b5492ac (diff) | |
download | astro-509fad6b9a0b4925a85daf95aa9699d726f69ed0.tar.gz astro-509fad6b9a0b4925a85daf95aa9699d726f69ed0.tar.zst astro-509fad6b9a0b4925a85daf95aa9699d726f69ed0.zip |
Fix Svelte bundled behavior (#151)
* build: add svelte to dynamic component imports
* fix: svelte bundling
* fix: ensure svelte runtime is bundled with build
* fix: svelte runtime in dev mode
* fix: include svelte runtime in imports
Co-authored-by: Duncan Healy <duncan.healy@gmail.com>
Diffstat (limited to 'src/compiler/codegen/index.ts')
-rw-r--r-- | src/compiler/codegen/index.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/codegen/index.ts b/src/compiler/codegen/index.ts index bca24d81d..73c038de1 100644 --- a/src/compiler/codegen/index.ts +++ b/src/compiler/codegen/index.ts @@ -128,11 +128,12 @@ interface ComponentInfo { const defaultExtensions: Readonly<Record<string, ValidExtensionPlugins>> = { '.astro': 'astro', '.jsx': 'react', + '.tsx': 'react', '.vue': 'vue', '.svelte': 'svelte', }; -type DynamicImportMap = Map<'vue' | 'react' | 'react-dom' | 'preact', string>; +type DynamicImportMap = Map<'vue' | 'react' | 'react-dom' | 'preact' | 'svelte', string>; interface GetComponentWrapperOptions { filename: string; @@ -212,7 +213,7 @@ function getComponentWrapper(_name: string, { type, plugin, url }: ComponentInfo componentUrl: getComponentUrl('.svelte.js'), componentExport: 'default', frameworkUrls: { - 'astro/frontend/runtime/svelte': internalImport('runtime/svelte.js'), + 'svelte-runtime': internalImport('runtime/svelte.js'), }, })})`, wrapperImport: `import {__svelte_${kind}} from '${internalImport('render/svelte.js')}';`, @@ -278,6 +279,10 @@ async function acquireDynamicComponentImports(plugins: Set<ValidExtensionPlugins importMap.set('preact', await resolvePackageUrl('preact')); break; } + case 'svelte': { + importMap.set('svelte', await resolvePackageUrl('svelte')); + break; + } } } return importMap; |