jlengstorf/learn-rollup

Configuration option is out of date in "Rollup.js Tutorial, Part 1: How to Set Up Smaller, More Efficient JavaScript Bundling Using Rollup"

Open

#48 opened on Apr 11, 2018

View on GitHub
 (1 comment) (1 reaction) (0 assignees)JavaScript (56 forks)github user discovery
help wanted

Repository metrics

Stars
 (190 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

What's wrong?

The rollup.config.js in the tutorial is out of date.

Error Steps

The tutorial, Rollup.js Tutorial, Part 1: How to Set Up Smaller, More Efficient JavaScript Bundling Using Rollup using the following configuration option fails

export default {
  entry: "src/scripts/main.js",
  dest: "build/js/main.min.js",
  format: "iife",
  sourceMap: "inline"
};

with following messages.

dance2die@CC c:\misc\sources\throwaway\rollupdemo\learn-rollup
> .\node_modules\.bin\rollup -c
(!) Some options have been renamed
https://gist.github.com/Rich-Harris/d472c50732dab03efeb37472b08a3f32
entry is now input
sourceMap is now output.sourcemap
format is now output.format
dest is now output.file

src/scripts/main.js → build/js/main.min.js...
[!] Error: You must specify options.format, which can be one of 'amd', 'cjs', 'system', 'es', 'iife' or 'umd'
https://rollupjs.org/#format-f-output-format-
Error: You must specify options.format, which can be one of 'amd', 'cjs', 'system', 'es', 'iife' or 'umd'
    at error (c:\misc\sources\throwaway\rollupdemo\learn-rollup\node_modules\rollup\dist\rollup.js:224:15)
    at checkOutputOptions (c:\misc\sources\throwaway\rollupdemo\learn-rollup\node_modules\rollup\dist\rollup.js:19531:9)
    at normalizeOptions (c:\misc\sources\throwaway\rollupdemo\learn-rollup\node_modules\rollup\dist\rollup.js:19603:21)
    at generate (c:\misc\sources\throwaway\rollupdemo\learn-rollup\node_modules\rollup\dist\rollup.js:19607:41)
    at Object.write (c:\misc\sources\throwaway\rollupdemo\learn-rollup\node_modules\rollup\dist\rollup.js:19638:32)
    at c:\misc\sources\throwaway\rollupdemo\learn-rollup\node_modules\rollup\bin\rollup:3430:77
    at next (c:\misc\sources\throwaway\rollupdemo\learn-rollup\node_modules\rollup\bin\rollup:3371:32)
    at c:\misc\sources\throwaway\rollupdemo\learn-rollup\node_modules\rollup\bin\rollup:3374:53
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:182:7)

How to fix it

Rollup.JS documentation has a different format for the rollup.config.js and the following works for the tutorial

export default {
  input: "src/scripts/main.js",
  output: {
    file: "build/js/main.min.js",
    format: "iife",
    sourceMap: "inline"
  }
};

With the new configuration above,

Rollup Version

"rollup": "^0.57.1"

Contributor guide