Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

babelHelpers is not defined using Rollup [Solved] #1320

Closed
alejandronanez opened this issue Jun 19, 2017 · 11 comments
Closed

babelHelpers is not defined using Rollup [Solved] #1320

alejandronanez opened this issue Jun 19, 2017 · 11 comments

Comments

@alejandronanez
Copy link

Hello there, I created a React component library using Rollup/styled components and when I try to run story book I got this error:

screen shot 2017-06-19 at 1 43 30 pm

babelHelpers is not defined
ReferenceError: babelHelpers is not defined
    at Object.<anonymous> (http://localhost:9001/static/preview.bundle.js:41768:58)
    at Object.defineProperty.value (http://localhost:9001/static/preview.bundle.js:42381:30)
    at __webpack_require__ (http://localhost:9001/static/preview.bundle.js:660:30)
    at fn (http://localhost:9001/static/preview.bundle.js:86:20)
    at Object.<anonymous> (http://localhost:9001/static/preview.bundle.js:42395:70)
    at Object.<anonymous> (http://localhost:9001/static/preview.bundle.js:42414:30)
    at __webpack_require__ (http://localhost:9001/static/preview.bundle.js:660:30)
    at fn (http://localhost:9001/static/preview.bundle.js:86:20)
    at loadStories (http://localhost:9001/static/preview.bundle.js:40294:2)
    at ConfigApi._renderMain (http://localhost:9001/static/preview.bundle.js:40760:20

I'm using master branch https://github.com/react-medellin/components/tree/master for this and regular global installation for story book.

Any ideas why is this happening?

Thanks!!!

@shilman
Copy link
Member

shilman commented Jun 21, 2017

@alejandronanez can you give more info about how you did the install, or better yet share a repo?

@alejandronanez
Copy link
Author

Hello @shilman,
You can check what I've done in here: https://github.com/react-medellin/components/tree/storybook if you have time you can yarn && yarn storybook and then open localhost:9001

@shilman
Copy link
Member

shilman commented Jun 22, 2017

I played around with it and it works if I remove "external-helpers" from the .babelrc. Hope that helps! Closing for now.

@shilman shilman closed this as completed Jun 22, 2017
@alejandronanez
Copy link
Author

alejandronanez commented Jun 22, 2017

Hmmm external-helpers is needed by my library (I'm using rollup) will dig into it and see what's going on! If I find a good solution I'll post it here in case anyone has a similar problem.
Thanks @shilman !

@shilman
Copy link
Member

shilman commented Jun 22, 2017

Good luck! Let us know how it works out!

@emartini
Copy link

@alejandronanez, you can remove external-helpers from your .babelrc file and enable it back only on your rollup.config.js using the rollup-plugin-babel

import babel from 'rollup-plugin-babel';
export default {
  // ...
  plugins: [
    babel({
      exclude: 'node_modules/**',
      plugins: ['external-helpers']
    }),
  ]
}

@alejandronanez
Copy link
Author

alejandronanez commented Jun 23, 2017 via email

@alejandronanez
Copy link
Author

Just tried this, worked like charm! Thanks!

@alejandronanez alejandronanez changed the title babelHelpers is not defined. babelHelpers is not defined using Rollup [Solved] Jun 26, 2017
papandreou added a commit to unexpectedjs/unexpected that referenced this issue Aug 26, 2017
…babelrc

Prevents babelHelpers ReferenceError when running the test suite

Advice found here: storybookjs/storybook#1320 (comment)
papandreou added a commit to unexpectedjs/unexpected that referenced this issue Aug 28, 2017
…babelrc

Prevents babelHelpers ReferenceError when running the test suite

Advice found here: storybookjs/storybook#1320 (comment)
vrajroham referenced this issue in rowanwins/vue-dropzone Dec 13, 2017
mgesmundo added a commit to mgesmundo/vue-plugin-template that referenced this issue Jan 8, 2018
mo added a commit to mo/abortcontroller-polyfill that referenced this issue Feb 7, 2018
abortcontroller-polyfill is using rollup + babel to transpile
modern JS into ES5 checked into dist/, so that other projects
can import these directly regardless whether these projects
are using babel themselves or not.

This crash was happening when Babel was used in a project
that in turn was using abortcontroller-polyfill, and when
the abortcontroller-polyfill dependency was overridden using
"npm link". In that case, the external-helpers declaration
in the abortcontroller-polyfill would be picked up by babel
running in the parent project causing the "missing babelHelpers"
JS crash.

"External Helpers" are generic Babel helper functions that
you can choose to not emit in the beginning of every file
if you prefer to provide them via other means, more here:
https://babeljs.io/docs/plugins/external-helpers/

This github issue was has info on a similar issue:
storybookjs/storybook#1320 (comment)
mo added a commit to mo/abortcontroller-polyfill that referenced this issue Feb 8, 2018
abortcontroller-polyfill is using rollup + babel to transpile
modern JS into ES5 checked into dist/, so that other projects
can import these directly regardless whether these projects
are using babel themselves or not.

This crash was happening when Babel was used in a project
that in turn was using abortcontroller-polyfill, and when
the abortcontroller-polyfill dependency was overridden using
"npm link". Because "npm link" creates a symlink to the folder
of the abortcontroller-polyfill git checkout, the entire folder
is exposed and not just files that "npm install" would have
installed. And in this case, the external-helpers declaration
in the abortcontroller-polyfill .babelrc would be picked up by babel
running in the parent project causing the "missing babelHelpers"
JS crash. The "files" key in package.json was originally added
to workaround the equivalent problem when "npm install" rather
than "npm link" was used.

"External Helpers" are generic Babel helper functions that
you can choose to not emit in the beginning of every file
if you prefer to provide them via other means, more here:
https://babeljs.io/docs/plugins/external-helpers/

This github issue was has info on a similar issue:
storybookjs/storybook#1320 (comment)
@Tomekmularczyk
Copy link
Contributor

Isn't the working configuration missing...

import babel from 'rollup-plugin-babel';
export default {
  // ...
  plugins: [
    babel({
      exclude: 'node_modules/**',
      plugins: ['external-helpers'],
      externalHelpers: true,  // ...this field ???
    }),
  ]
}

@wilomgfx
Copy link

wilomgfx commented May 24, 2018

@Tomekmularczyk
No externalHelpers it is not supported

from the readme

All options are as per the Babel documentation, except the following:
options.externalHelpers: a boolean value indicating whether to bundle in the Babel helpers

@MrJadaml
Copy link

MrJadaml commented Jun 6, 2018

For future googlers -Setting format to ES module in rollup.config.js was the fix for me: output.format: 'es'

Rollup docs:

an ES module bundle, suitable for use in other people's libraries and applications, that imports the external dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants