我正在使用Deno,但在浏览器中收到以下错误:Uncaught TypeError: Cannot read properties of undefined (reading '$$')
这是bunder.ts:
import * as esbuild from 'https://deno.land/x/esbuild@v0.11.12/mod.js'
import sveltePlugin from 'npm:esbuild-svelte';
import { typescript } from "./build/esbuild-svelte.ts"; // I rebuilt svelte-process-esbuild in ts because it wasn't originally written in ts
// if you want this code to duplicate, I can get it to you np
const result = await esbuild.build({
entryPoints: [
'client/entries/admin.ts',
'client/entries/main.ts'
],
bundle: true,
outdir: 'dist',
mainFields: ["svelte", "browser", "module", "main"],
conditions: ["svelte", "browser"],
watch: {
onRebuild(error: Error, result: any) {
if (error) console.error('watch build failed:', error);
else console.log('watch build succeeded:', result);
}
},
// Deno did not recognise sveltePlugin as a function, but running the code works
plugins: [(sveltePlugin as unknown as Function)({
preprocess: [
typescript()
]
})],
logLevel: "info"
});
Svelte App.Svelte:
<script lang="ts">
export let name: String;
</script>
<main>Hello, {name}</main>
./CLIENT/ENTRIES/main.ts:
import App from '../views/App.svelte';
const app = new App({
target: document.body,
props: {
name: 'World'
}
});
https://github.com/sveltejs/svelte/issues/6584个
说明这与我的svelte
版本有关,但我运行的是npm:esbuild-svelte
,这些版本与svelte
版本不一致,所以我不确定如何修复这个问题.我做错了什么?