Closed
Description
I'm a super n00b at this Rollup thingymobobber, but I've been trying to build my own app using Svelte from scratch — WITHOUT using a boilerplate. I tried copy-pasting the example in the README.md, but it didn't work. Rollup was giving me this error:
$ npx rollup -c
src/main.js → dist/bundle.js...
(!) Unresolved dependencies
https://rollupjs.org/guide/en#warning-treating-module-as-external-dependency
svelte/internal (imported by src/main.js, src/App.svelte)
(!) Missing global variable name
Use output.globals to specify browser global variable names corresponding to external modules
svelte/internal (guessing 'internal')
created dist/bundle.js in 76ms
I tried importing svelte/internal
in node, and it worked fine. Eventually, I looked at some GitHub examples of Svelte 3 + Rollup, and found this plugin required for ALL of them: rollup-plugin-node-resolve
. I popped it into my config:
import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
export default {
input: 'src/main.js',
output: {
file: 'dist/bundle.js',
format: 'iife'
},
plugins: [
svelte({
// You can restrict which files are compiled
// using `include` and `exclude`
include: 'src/**/*.svelte',
}),
resolve()
]
}
And everything worked!
ACTION ITEM
State in the README that rollup-plugin-node-resolve
is required and must be used to have a fully working rollup.config.js
.