Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Typeof transform #69

Closed
scola84 opened this issue Aug 1, 2016 · 9 comments
Closed

Typeof transform #69

scola84 opened this issue Aug 1, 2016 · 9 comments

Comments

@scola84
Copy link

scola84 commented Aug 1, 2016

When I try to transform code with typeof a === 'symbol' in it, the output of rollup-plugin-babel becomes erroneous. In the second example below, var typeof = ... is wrong. I suppose it has to do with https://github.com/rollup/rollup-plugin-babel/blob/master/src/index.js#L43?

With babel:

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };

With rollup-plugin-babel:

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

The transform is triggered by https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-typeof-symbol

@eventualbuddha
Copy link
Contributor

Can you provide some more information? What do your rollup.config.js, .babelrc, and input file look like?

@derduher
Copy link

I am running into the same issue so I'll chime in with those files. I'll note I'm only running into the issue with karma-rollup-preprocessor which has [email protected]
I'm pretty sure OP either is using the same or is on an older version. I'll see if I can open an update against karma-rollup-preprocessor

{
  presets: [ "es2015-rollup" ],
  sourceMaps: true
}

and

import babel from 'rollup-plugin-babel'
export default {
  entry: 'src/index.js',
  format: 'cjs',
  plugins: [babel()],
  dest: 'bundle.js' // equivalent to --output
}
    preprocessors: {
      'tests/**/*.js': [ 'rollup' ]
    },
    rollupPreprocessor: {
      rollup: {
        plugins: [
          require('rollup-plugin-babel')({
            presets: [
              require('babel-preset-es2015-rollup')
            ]
          })
        ]
      },
      bundle: {
        sourceMap: 'inline'
      }
    },

@derduher
Copy link

I've just confirmed that forcing the dep of karma-rollup-preprocessor to the latest resolves the issue

@scola84
Copy link
Author

scola84 commented Sep 3, 2016

Sorry for not getting back sooner. I tried to reliably reproduce this problem: what I found out is that the problem relates to the 'lodash-es' package and that the problem disappears when I upgrade the 'rollup' package from '0.26.3' to '0.34.13'. I suggest to close this issue and never look back.

@differui
Copy link

differui commented Nov 4, 2016

When I use clipboard produce same error message:

Uncaught TypeError: _typeof is not a function(…)

@Hilzu
Copy link

Hilzu commented Nov 5, 2016

I was trying to build a React project with react-router using rollup and hit this bug. I created a minimal reproduction in this gist. I copied the mod.js typeof code from react-routers history dependency.

@alexnaish
Copy link

Just hit this issue with react-router too. The bundle builds fine but results in an Uncaught TypeError: _typeof is not a function error in the console.

@maxval1
Copy link

maxval1 commented Mar 13, 2018

I have the same problem
No name was provided for external module 'babel-runtime/core-js/json/stringify' in options.globals – guessing '_JSON$stringify'
No name was provided for external module 'babel-runtime/helpers/typeof' in options.globals – guessing '_typeof'

My config

{
  presets: [
    [
      "env",
      {
        targets: {
          browsers: ["> 5%", "since 2015"]
        },
        modules: false
      }
    ]
  ],
  runtimeHelpers: true
}

@Andarist
Copy link
Member

Closing this as outdated and not actionable due to lack of reproduction case. Feel free to open new issue.

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

No branches or pull requests

8 participants