rollup-plugin-jspm
raw JSON → 1.1.0 verified Mon Apr 27 auth: no javascript
A Rollup plugin that integrates jspm 2 module resolution into the Rollup build pipeline. Version 1.1.0 is the latest stable release, with irregular release cadence. It resolves imports using jspm's import map and handles environment-specific module conditionals (browser/node). Unlike generic Rollup plugins, it leverages jspm's package management and dependency resolution, allowing projects to use jspm's import map as the single source of truth for module loading. Works well with Babel for transpilation. Note that it only supports jspm 2, not earlier versions.
Common errors
error Error: Could not resolve 'dependency' from 'file.js' ↓
cause The dependency is not in jspm's import map or not installed.
fix
Run 'jspm install dependency' and ensure import map is up to date.
error Error: Cannot find module 'rollup-plugin-jspm' ↓
cause The plugin is not installed.
fix
Run 'npm install --save-dev rollup-plugin-jspm'.
Warnings
gotcha The plugin only supports jspm 2 and will not work with jspm 0.x or 1.x. ↓
fix Ensure your project uses jspm 2 (npm package jspm).
gotcha The `basePath` option must be an absolute path; relative paths may cause unexpected behavior. ↓
fix Use path.resolve() to provide absolute path.
Install
npm install rollup-plugin-jspm yarn add rollup-plugin-jspm pnpm add rollup-plugin-jspm Imports
- default wrong
const jspm = require('rollup-plugin-jspm')correctimport jspmRollup from 'rollup-plugin-jspm'
Quickstart
// rollup.config.js
import path from 'path';
import babelRollup from 'rollup-plugin-babel';
import jspmRollup from 'rollup-plugin-jspm';
const basePath = path.resolve('components');
export default {
input: './main.js',
plugins: [
jspmRollup({
basePath,
env: { browser: true, node: false },
envTarget: {
browsers: 'last 2 versions'
},
externals: {}
}),
babelRollup()
]
};