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

babel-runtime/helpers/typeof requires itself - again #4829

Closed
sheerun opened this issue Nov 10, 2016 · 5 comments
Closed

babel-runtime/helpers/typeof requires itself - again #4829

sheerun opened this issue Nov 10, 2016 · 5 comments
Labels
area: helpers outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@sheerun
Copy link

sheerun commented Nov 10, 2016

This issue happens again, in babel-runtime 6.11.6 when using rollup.

This is rollup.config.js to reproduce:

import json from 'rollup-plugin-json';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';

export default {
  entry: 'node_modules/babel-runtime/helpers/typeof.js',
  format: 'cjs',
  plugins: [
    json(),
    babel({ runtimeHelpers: true }),
    nodeResolve({ jsnext: true, main: true }),
    commonjs()
  ],
  dest: 'bundle.js'
};

Related: #3711, rollup/rollup-plugin-babel#97

@tjclement
Copy link

This same issue also happens when transpiling a JSPM (0.17.0-beta.22) project with babel and rollup. Haven't been able to figure out why, so far.

@mfirmin
Copy link

mfirmin commented Mar 10, 2017

I was running into the same problem, and spent most of yesterday trying to fix it.

Turns out, if you just add exclude: 'node_modules/**' (or in my case, make sure the path is correct...) to the babel plugin in your rollup config, it works perfectly:

import json from 'rollup-plugin-json';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';

export default {
  entry: 'node_modules/babel-runtime/helpers/typeof.js',
  format: 'cjs',
  plugins: [
    json(),
    babel({ runtimeHelpers: true, exclude: 'node_modules/**' }),
    nodeResolve({ jsnext: true, main: true }),
    commonjs()
  ],
  dest: 'bundle.js'
};

@chicoxyzzy
Copy link
Member

Seems like this issue is related to rollup-plugin-babel, not Babel

@bdwain
Copy link
Contributor

bdwain commented Apr 10, 2017

@chicoxyzzy running babel-external-helpers -t umd > es/babel-external-helpers.js gives me a file that can't run in the browser. the error is babelHelpers.typeof is not a function.

This seems to be the problematic code (at the very beginning of the function)

  var babelHelpers = global;
  babelHelpers.typeof = typeof Symbol === "function" && babelHelpers.typeof(Symbol.iterator) === "symbol" ? function (obj) {
    return typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj);
  } : function (obj) {
    return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : babelHelpers.typeof(obj);
  };

@loganfsmyth
Copy link
Member

babel-external-helpers works on 7.x branch at least. Closing this otherwise since it does not seem like a babel issue. Compiling the helpers to reference themselves will indeed cause issues.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: helpers outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

7 participants