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

require disappears #181

Closed
timdp opened this issue Mar 11, 2017 · 1 comment
Closed

require disappears #181

timdp opened this issue Mar 11, 2017 · 1 comment
Assignees

Comments

@timdp
Copy link

timdp commented Mar 11, 2017

Code:

import raf from 'raf'

raf()

Where node_modules/raf/index.js starts with:

var now = require('performance-now')
  , root = typeof window === 'undefined' ? global : window

Rollup config:

import commonjs from 'rollup-plugin-commonjs'
import nodeResolve from 'rollup-plugin-node-resolve'

export default {
  entry: 'main.js',
  dest: 'bundle.js',
  format: 'iife',
  plugins: [
    nodeResolve(),
    commonjs()
  ]
}

Versions:

  "devDependencies": {
    "rollup": "^0.41.5",
    "rollup-plugin-commonjs": "^8.0.1",
    "rollup-plugin-node-resolve": "^2.0.0"
  }

Output of rollup -c rollup.config.js:

🚨   Unexpected token
node_modules/raf/index.js (6:2)
4: 
5: var 
6:   , root = typeof window === 'undefined' ? commonjsHelpers.commonjsGlobal : window
     ^
7:   , vendors = ['moz', 'webkit']
8:   , suffix = 'AnimationFrame'

So it looks like it's stripping out the require('performance-now') but neglecting to remove the comma that follows it?

@Rich-Harris Rich-Harris self-assigned this Mar 11, 2017
Rich-Harris added a commit that referenced this issue Mar 11, 2017
fix another var rewrite bug
@Rich-Harris
Copy link
Contributor

Thanks — fixed in 8.0.2

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

No branches or pull requests

2 participants