jlengstorf / learn-rollup

This is an example project to accompany a tutorial on using Rollup.
https://code.lengstorf.com/learn-rollup-js/
ISC License
191 stars 61 forks source link

Update post for moduleName with IIFE #26

Closed ghost closed 7 years ago

ghost commented 7 years ago

rollup version 0.41.4

🚨 You must supply options.moduleName for IIFE bundles

Example module name: http://rollupjs.org/#using-rollup-with-gulp. Without it will not transpile.

jlengstorf commented 7 years ago

Hey, @jhabdas — I think this is Gulp-specific. I can't find anything in the docs or changelog that suggests otherwise. Did you run into this in a non-Gulp setup?

ghost commented 7 years ago

Yes, bare setup. https://github.com/jhabdas/fetch-inject

jlengstorf commented 7 years ago

@jhabdas I think this has changed. I just pulled Rollup v0.41.6 and used the following config:

export default {
  entry: 'src/index.js',
  dest: 'build/js/bundle.js',
  format: 'iife',
  sourceMap: 'inline',
}

This successfully bundled two small modules. The docs do say that moduleName is required for UMD format, though.

I'm going to close this, but let me know if there's something else you've found that could affect IIFE generation.

ghost commented 7 years ago

FYI - https://github.com/rollup/rollup/issues/1157#issuecomment-268284551. TL;DR, if your module exports, then you need to give it a name. Thanks again for your attention and help. Love your website and great article!

jlengstorf commented 7 years ago

@jhabdas This is really helpful — thanks for digging up that comment and clarifying!