Skip to content

Commit

Permalink
Fix JS crash "ReferenceError: babelHelpers is not defined"
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
mo committed Feb 8, 2018
1 parent a34454f commit 857fa83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions .babelrc
Expand Up @@ -6,6 +6,5 @@
"modules": false
}
]
],
"plugins": ["external-helpers"]
}
]
}
3 changes: 2 additions & 1 deletion rollup.config.js
Expand Up @@ -2,7 +2,8 @@ import babel from 'rollup-plugin-babel';

const plugins = [
babel({
exclude: 'node_modules/**'
exclude: 'node_modules/**',
plugins: ['external-helpers']
})
];

Expand Down

0 comments on commit 857fa83

Please sign in to comment.