fix(webpack): map 'svelte' to 'svelte/internal' to avoid forced ssr (#9627)

This commit is contained in:
halfnelson
2021-10-29 20:32:56 +10:00
committed by GitHub
parent 7c75966b3b
commit 78e9c17be3

View File

@ -1,4 +1,3 @@
import { merge } from 'webpack-merge';
import Config from 'webpack-chain';
import { getProjectFilePath } from '../helpers/project';
@ -19,6 +18,10 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
// electron-main sneaks us past the target == 'node' check and gets us HMR
config.target('electron-main');
// turns out this isn't enough now. svelte uses "node" of which "electron-main" is a subset in its export map forcing imports
// for 'svelte' to 'ssr.mjs'. We define an alias here to force it back.
config.resolve.alias.set('svelte$', 'svelte/internal');
// svelte-hmr still references tns-core-modules, so we shim it here for compat.
config.resolve.alias.set('tns-core-modules', '@nativescript/core');