plasmic
plasmic copied to clipboard
[loader-svelte] "does not provide an export named 'default'" error
Within a fresh installation, I'm getting this error:

Here is a step by step to reproduce:
1. Create & setup SvelteKit demo app
$ npm init svelte@next sveltekit-plasmic-integration
Need to install the following packages:
create-svelte@next
Ok to proceed? (y) y
create-svelte version 2.0.0-next.126
Welcome to SvelteKit! [...]
✔ Which Svelte app template? › [SvelteKit demo app]
✔ Use TypeScript? … No / [Yes]
✔ Add ESLint for code linting? … [No] / Yes
✔ Add Prettier for code formatting? … [No] / Yes
✔ Add Playwright for browser testing? … [No] / Yes
Your project is ready!
✔ Typescript
Inside Svelte components, use <script lang="ts">
[...]
$ npm i @plasmicapp/loader-svelte
2. Create Plasmic init file
// $lib/init.ts
import { initPlasmicLoader } from '@plasmicapp/loader-svelte';
const PROJECT_ID = "xxx";
const API_TOKEN = "xxx";
export const PLASMIC = initPlasmicLoader({
projects: [
{
id: PROJECT_ID,
token: API_TOKEN
}
],
preview: true
});
3. Add to a test route file
<!-- $routes/index.svelte -->
<script lang="ts">
import Counter from '$lib/Counter.svelte';
import { PLASMIC } from "$lib/init"; // <=== this import causes error
import { PlasmicComponent, PlasmicRootProvider } from "@plasmicapp/loader-svelte";
const COMPONENT_NAME = "Home";
</script>
4. Errors :boom:
In the browser
The requested module '/node_modules/isomorphic-unfetch/browser.js?v=84862a93' does not provide an export named 'default'
SyntaxError: The requested module '/node_modules/isomorphic-unfetch/browser.js?v=84862a93' does not provide an export named 'default'
In the terminal
22:52:55 [vite] Error when evaluating SSR module /node_modules/react/index.js?v=84862a93:
ReferenceError: module is not defined
at /node_modules/react/index.js?v=84862a93:6:3
at instantiateModule (/<path>/sveltekit-plasmic-integration/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:15)
22:52:55 [vite] Error when evaluating SSR module /node_modules/@plasmicapp/host/dist/host.esm.js?v=84862a93:
ReferenceError: module is not defined
at /node_modules/react/index.js?v=84862a93:4:3
at instantiateModule (/<path>/sveltekit-plasmic-integration/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:15)
22:52:55 [vite] Error when evaluating SSR module /node_modules/@plasmicapp/loader-react/dist/loader-react.esm.js?v=84862a93:
ReferenceError: module is not defined
at /node_modules/react/index.js?v=84862a93:4:3
at instantiateModule (/<path>/sveltekit-plasmic-integration/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:15)
22:52:55 [vite] Error when evaluating SSR module /node_modules/@plasmicapp/loader-svelte/src/index.js:
ReferenceError: module is not defined
at /node_modules/react/index.js?v=84862a93:4:3
at instantiateModule (/<path>/sveltekit-plasmic-integration/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:15)
22:52:55 [vite] Error when evaluating SSR module /src/lib/init.ts:
ReferenceError: module is not defined
at /node_modules/react/index.js?v=84862a93:4:3
at instantiateModule (/<path>/sveltekit-plasmic-integration/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:15)
22:52:55 [vite] Error when evaluating SSR module /src/routes/index.svelte:
ReferenceError: module is not defined
at /node_modules/react/index.js?v=84862a93:4:3
at instantiateModule (/<path>/sveltekit-plasmic-integration/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:15)
module is not defined
ReferenceError: module is not defined
at /node_modules/react/index.js?v=84862a93:4:3
at instantiateModule (/<path>/sveltekit-plasmic-integration/node_modules/vite/dist/node/chunks/dep-9c153816.js:56193:15)
Originally posted by @arenzel in https://github.com/plasmicapp/plasmic/issues/18#issuecomment-1071597174