Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import svelte from 'rollup-plugin-svelte'
✗ const svelte = require('rollup-plugin-svelte')
The plugin is a default ES module export. CommonJS require() is not supported for this package.
svelte (in rollup.config.js)
✓ import svelte from 'rollup-plugin-svelte'
✗ import { svelte } from 'rollup-plugin-svelte'
The plugin is a default export, not a named export. Using named import will result in undefined.
svelte function usage
✓ plugins: [svelte({ compilerOptions: { hydratable: true } })]
✗ plugins: [new svelte()]
svelte is a function, not a class. Do not use 'new'. It returns a plugin object.
Basic Rollup config to compile Svelte components with the plugin, node-resolve, and commonjs. Includes include filter and dev mode.
// rollup.config.js
import svelte from 'rollup-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
export default {
input: 'src/main.js',
output: {
file: 'public/bundle.js',
format: 'iife',
},
plugins: [
svelte({
include: 'src/**/*.svelte',
compilerOptions: { dev: process.env.NODE_ENV !== 'production' },
}),
resolve({ browser: true, exportConditions: ['svelte'] }),
commonjs(),
],
};
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-svelte'
Package not installed or not in node_modules.
fixRun 'npm install --save-dev rollup-plugin-svelte'.
Error: 'svelte' is not exported by node_modules/rollup-plugin-svelte/index.mjs
Using named import instead of default import.
fixUse 'import svelte from 'rollup-plugin-svelte'' instead of 'import { svelte } from ...'. Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
Rollup cannot parse .svelte files without this plugin.
fixAdd rollup-plugin-svelte to your plugins list in rollup.config.js.
Error: The 'svelte' condition in exports must be used with @rollup/plugin-node-resolve's exportConditions
Missing exportConditions in node-resolve config.
fixAdd 'exportConditions: ['svelte']' to resolve plugin options.
Audit
Dependencies
rolluprequiredPeer dependency, needed as bundler. Requires >=2.0.0.
svelterequiredPeer dependency, required for compiling Svelte components. Requires >=3.5.0.
@rollup/plugin-node-resolveoptionalPlugin resolves node_modules imports; needed to resolve Svelte components from packages with svelte export condition.
@rollup/plugin-commonjsoptionalPlugin converts CommonJS modules to ES module format; often required alongside rollup-plugin-svelte.