Questions tagged [rollupjs]

Rollup.js is a next-generation JavaScript Transpiler and module bundler

rollup.js is a module bundler, similar to browserify, but targeting code written as ES2015 modules.

Rollup takes advantage of the fact that ES2015 import and export declarations are statically analyzable and only bundles the functions / values that are actually referenced.

1172 questions
81
votes
1 answer

What is flat bundling and why is Rollup better at this than Webpack?

I have recently been looking into rollup and seeing how it differs from Webpack and other bundlers. One thing I came across was that it is better for libraries because of "flat bundling". This is based on a tweet and from a recent PR for React to…
aug
  • 11,138
  • 9
  • 72
  • 93
49
votes
6 answers

Vite "rollup failed to resolve" build error

Trying to build a simple Vite project that has tailwindcss in it and getting the following error, any ideas? > vite-project@0.0.0 build > vite build vite v2.3.4 building for production... ✓ 1 modules transformed. [vite]: Rollup failed to resolve…
James Mansfield
  • 591
  • 1
  • 4
  • 5
47
votes
8 answers

Best way to import SVG icons into a Svelte app

I have about 80 custom SVG icons that I'm importing into a Svelte front-end app. Building on https://github.com/sveltejs/template, it's built with Rollup and includes Typescript, Tailwind, and all the modern goodies. The dilemma is how to add the…
Andrew Mao
  • 35,740
  • 23
  • 143
  • 224
29
votes
9 answers

Using Rollup for Angular 2's AoT compiler and importing Moment.js

I'm trying to follow the official AoT guide for Angular 2, and I'm using Moment.js in my application. Moment.js is on my packages.json file, and I'm using version 2.15.0. I've been importing it like this so far: import * as moment from…
Vitor Machado
  • 405
  • 4
  • 9
28
votes
3 answers

Tree shaking create-react-app?

I created my React app with create-react-app and now use TypeScript with create-react-app-typescript. Everything works ok, but the problem is - especially because I use the good but heavy material-ui - the size of the built bundle is quite big -…
mllm
  • 17,068
  • 15
  • 53
  • 64
26
votes
3 answers

String replacements in index.html in vite

I am trying to inject some strings into the index.html of a Vite app (using vue3 template). In a vue-cli project for example we would have What is the Vite way to do that? (I know that BASE_URL is…
v-moe
  • 1,203
  • 1
  • 8
  • 25
26
votes
1 answer

Using jQuery DataTables with Rollup.js

Ok I'm using the tool rollup for the first time and I love how small it is making the code. Tree shaking is great. However, I'm having some trouble getting it to include everything correctly. I tried having a single entry point, exp.js, where I…
syzygy
  • 1,356
  • 3
  • 16
  • 28
25
votes
2 answers

How to prevent tests being bundled by rollup?

I am building a react component package and want to exclude my tests folder from being bundled in my dist file that is built from rollup. My file structure looks like this after running rollup -c . ├── dist │ ├── index.js │ ├── tests │ ├──…
Stretch0
  • 8,362
  • 13
  • 71
  • 133
24
votes
1 answer

Rollup.js unresolved dependencies

I am trying to incorporate rollup.js into a project. Currently I am getting the warnings provided below in the console (unresolved dependencies) and I am not sure why or how to fix it: 'fs' is imported by node_modules\filereader\FileReader.js, but…
Jim M
  • 321
  • 2
  • 5
  • 12
23
votes
3 answers

Rollup Error: 'default' is not exported by node_modules/react/index.js

I have a project where I use webpack and want to switch to rollup.js but I have trouble regarding the plugin @rollup/plugin-commonjs. My rollup.conf.js import resolve from '@rollup/plugin-node-resolve'; import commonjs from…
tiefenb
  • 732
  • 3
  • 16
  • 32
23
votes
1 answer

How to best include assets (images and fonts) referenced in scss files in rollup bundle

I am writing a react component library with typescript, sass and rollup, and I want it to be as standalone as possible. Does anyone have a suggestion on how to best include assets (images and fonts) referenced in scss files? One solution could be…
Mahus
  • 595
  • 1
  • 6
  • 16
23
votes
1 answer

How to embed all dependencies into one fat target bundle with rollup.js?

How do I have to configure rollup.js (=> config file "rollup.config.js") if all dependencies should be embedded into the (fat) result bundle (especially: how to configure the rollup parameters "globals", "external", "plugins.babel.exclude")? Let's…
Natasha
  • 421
  • 1
  • 3
  • 10
22
votes
2 answers

How to get rid of the "@rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps." warning?

I get this warning every time I build for production. When I build for production I disable source maps in the rollup output config. output: [{ dir: "...", format: "...", sourcemap: isProd ? false : true }] I use the same tsconfig for dev and…
user1283776
  • 19,640
  • 49
  • 136
  • 276
22
votes
6 answers

Building Typescript: [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)

I've encountered problem building typescript packages with rollup inside lerna managed monorepo. Error: lerna ERR! rollup --config ../../rollup.config.js stderr: loaded ../../rollup.config.js with warnings (!) Unused external imports terser imported…
Kirill Morozov
  • 493
  • 1
  • 3
  • 12
21
votes
1 answer

How to make rollup expand `require` statements?

I'm trying to wrap my head around rollup. I'm using a library that generates a file with this format: IIFE with a require statement. For example // index.js (function() { const myThing = require('./thing'); })() //thing.js module.exports = { a:…
nachocab
  • 13,328
  • 21
  • 91
  • 149
1
2 3
78 79