Use vite-plugin-iso-import to fix leaflet async imports
This commit is contained in:
parent
57d83a349d
commit
acaaf364c4
@ -31,6 +31,7 @@
|
||||
"tailwindcss": "^3.2.7",
|
||||
"typescript": "^4.9.3",
|
||||
"vite": "^4.1.4",
|
||||
"vite-plugin-iso-import": "^1.0.0",
|
||||
"vite-plugin-pwa": "^0.14.6",
|
||||
"vite-plugin-wasm-pack": "^0.1.12"
|
||||
},
|
||||
|
@ -2,6 +2,8 @@
|
||||
import { onMount, onDestroy } from 'svelte';
|
||||
import { browser } from '$app/environment';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import * as leaflet from 'leaflet?client';
|
||||
import * as leafletControlGeocoder from 'leaflet-control-geocoder?client';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
@ -35,11 +37,8 @@
|
||||
}
|
||||
};
|
||||
|
||||
onMount(async () => {
|
||||
onMount(() => {
|
||||
if (browser) {
|
||||
const leaflet = await import('leaflet');
|
||||
const leafletControlGeocoder = await import('leaflet-control-geocoder');
|
||||
|
||||
map = leaflet.map(mapElement);
|
||||
// TODO: Pick a better spot
|
||||
map.setView([51.505, -0.09], 13);
|
||||
|
@ -2,6 +2,7 @@ import { sveltekit } from '@sveltejs/kit/vite';
|
||||
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
|
||||
import wasmPack from 'vite-plugin-wasm-pack';
|
||||
import { defineConfig } from 'vite';
|
||||
import { isoImport } from 'vite-plugin-iso-import';
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [sveltekit(), wasmPack('../xpin-wasm/'), SvelteKitPWA({
|
||||
@ -11,5 +12,7 @@ export default defineConfig({
|
||||
devOptions: {
|
||||
enabled: true,
|
||||
},
|
||||
})]
|
||||
}),
|
||||
isoImport(),
|
||||
]
|
||||
});
|
||||
|
@ -2094,6 +2094,11 @@ es-abstract@^1.19.0, es-abstract@^1.20.4:
|
||||
unbox-primitive "^1.0.2"
|
||||
which-typed-array "^1.1.9"
|
||||
|
||||
es-module-lexer@^1.1.0:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.2.1.tgz#ba303831f63e6a394983fde2f97ad77b22324527"
|
||||
integrity sha512-9978wrXM50Y4rTMmW5kXIC09ZdXQZqkE4mxhwkd8VbzsGkXGPgV4zWuqQJgCEzYngdo2dYDa0l8xhX4fkSwJSg==
|
||||
|
||||
es-set-tostringtag@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/es-set-tostringtag/-/es-set-tostringtag-2.0.1.tgz#338d502f6f674301d710b80c8592de8a15f09cd8"
|
||||
@ -4689,6 +4694,14 @@ verror@1.10.0:
|
||||
core-util-is "1.0.2"
|
||||
extsprintf "^1.2.0"
|
||||
|
||||
vite-plugin-iso-import@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/vite-plugin-iso-import/-/vite-plugin-iso-import-1.0.0.tgz#71d83047d8dc77327278b56bff9e1e362edffbce"
|
||||
integrity sha512-DqhCElHfkbkqLXtm0UMiAXqh9FdqRHegHpawXtp5LWHjGsdAqYPhmUGBTKFuTRwPSNFYCpyjHRsm7lvM2dskGw==
|
||||
dependencies:
|
||||
es-module-lexer "^1.1.0"
|
||||
magic-string "^0.27.0"
|
||||
|
||||
vite-plugin-pwa@^0.14.6:
|
||||
version "0.14.6"
|
||||
resolved "https://registry.yarnpkg.com/vite-plugin-pwa/-/vite-plugin-pwa-0.14.6.tgz#71d77a9e39a3b3ccc265aa5e4d920d1fdd661461"
|
||||
|
Loading…
Reference in New Issue
Block a user