Skip to content

Commit 78e9c17

Browse files
authored
fix(webpack): map 'svelte' to 'svelte/internal' to avoid forced ssr (NativeScript#9627)
1 parent 7c75966 commit 78e9c17

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/webpack5/src/configuration/svelte.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { merge } from 'webpack-merge';
21
import Config from 'webpack-chain';
32

43
import { getProjectFilePath } from '../helpers/project';
@@ -19,6 +18,10 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
1918
// electron-main sneaks us past the target == 'node' check and gets us HMR
2019
config.target('electron-main');
2120

21+
// turns out this isn't enough now. svelte uses "node" of which "electron-main" is a subset in its export map forcing imports
22+
// for 'svelte' to 'ssr.mjs'. We define an alias here to force it back.
23+
config.resolve.alias.set('svelte$', 'svelte/internal');
24+
2225
// svelte-hmr still references tns-core-modules, so we shim it here for compat.
2326
config.resolve.alias.set('tns-core-modules', '@nativescript/core');
2427

0 commit comments

Comments
 (0)