Closed mihairaulea closed 5 years ago
This doesn't look like a bug in Svelte, you are importing things incorrectly in your bundler configuration. You might be better looking for help in the Svelte Discord.
Please create a reproduction using the REPL. We would also need to see your rollup/webpack configuration, and the source of MenuDrawer.svelte There isn't nearly enough information here to assist you as it stands.
Errors like this can also happen when the Svelte compiler produces unparseable js for a component, which would be a bug. In any case, we do need to see a repro.
I have a similar issue I think. Might be related.
Based on the normal app template. I think something is off with the rollup config somehow. https://github.com/mvanhalen/svelte-app-issue
Also posted here https://github.com/kaisermann/svelte-loadable/issues/7
Here a compiled version showing the issue https://igtemplate.blob.core.windows.net/public/packages/svelte/public/index.html
@Conduitry have the same error 😞
removed all my code and created small repo:
https://github.com/bravecow/svelte-example
yarn watch
:
Your Rollup config is wrong. plugins
and watch
need to go outside output
. https://rollupjs.org/guide/en/#configuration-files
@Conduitry Thanks! 🙄
@mvanhalen Your issue is that you are attempting to load a component from a URL, and aren't using an appropriate Rollup plugin to allow downloading and bundling external modules on the fly. (I would guess that someone has written such a plugin, but I've never personally used one.) In the compiled code, the import('https://igtemplate.blob.core.windows.net/public/packages/svelte/ScreenCDN.svelte')
remains unchanged, and so the browser is attempting to load an uncompiled svelte file as an ES module, which won't work.
I'm going to close this issue, as none of the comments in it have been about the actual same issue, nor have we gotten a repro for the original problem.
I encountered this error when trying to add sass support to my rollup.config.js
. I commented out css({ output: 'bundle.css' }),
and the error mentioned by OP appeared. The css method is from import css from 'rollup-plugin-css-only';
I had the same error. Everything worked fine before. But without changing any configs/packages, I created a regular style block in an existing component and it broke from nowhere.
Turns out that my specific error only showed up from importing components with aliased paths (@rollup/plugin-alias) trough my router.js file (svelte-spa-router).
Changing the aliased paths to relative paths removed my problem. Hope it helps someone.
I had the same error... because my component had the extension .Svelte
instead of .svelte
. 😞
@ezriharmusial thanks so much for your answer. I searched for hours but I never would have thought that @rollup/plugin-alias
was causing this issue.
After some tinkering I found a solution that lets me keep my aliases.
The following change in my rollup.config.js
did the trick for me.
alias({
resolve: [...],
enties: [
- { find: '$lib', replacement: './src/lib' },
+ { find: '$lib', replacement: require('path').resolve(__dirname, './src/lib') },
]
})
On macos I got this error after renaming a file timeline.ts
to Timeline.ts
(and updated the imports). Restarting scripts/VSCode did not help. Renaming it to anything else like Timelinex.ts
solved the issue.
This issue can also appear when updating rollup-plugin-svelte
to 7.0.0
or higher. The breaking change is described in the changelog:
https://github.com/sveltejs/rollup-plugin-svelte/blob/master/CHANGELOG.md#700 - "Offload CSS handling to Rollup", with the suggestion to use rollup-plugin-css-only
I got this error, because I was using soft link over sshfs mount files. Took some time to figure that out.
I am having this issue what could be wrong here
Please use the questions facility in the Svelte discord rather than closed github issues, you are more likely to recieve help.
Stack trace
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript) src/common/components/MenuDrawer.svelte (772:16)What bothers me is the fact that MenuDrawer.svelte only has 258 lines. How can i translate the svelte bundled source to my file?