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

Browserifying a file with for-of does not work #1146

Closed
domenic opened this issue Mar 2, 2015 · 7 comments
Closed

Browserifying a file with for-of does not work #1146

domenic opened this issue Mar 2, 2015 · 7 comments

Comments

@domenic
Copy link
Contributor

domenic commented Mar 2, 2015

Throws a "error: parsing file", seems to originate in module-deps.

domenic added a commit to jsdom/jsdom that referenced this issue Mar 2, 2015
It isn't supported by browserify: browserify/browserify#1146
@ghost
Copy link

ghost commented Mar 2, 2015

acorn allows:

var src = 'const xs = [1,2,3]\n'
  + 'for (let x in xs) console.log(x)'
var acorn = require('acorn');
console.log(acorn.parse(src, { ecmaVersion: 6 }));

but not:

var src = 'const xs = [1,2,3]\n'
  + 'for (const x in xs) console.log(x)'
var acorn = require('acorn');
console.log(acorn.parse(src, { ecmaVersion: 6 }));

I'm not sure if that's an acorn bug or the spec doesn't allow an iterator variable to be a constant. Anyways it might be good to raise with acorn since all of the underlying packages use acorn now.

@domenic
Copy link
Contributor Author

domenic commented Mar 2, 2015

for-of, not for-in :)

@domenic
Copy link
Contributor Author

domenic commented Mar 2, 2015

I can't confirm just by browsing GitHub but my guess is this was fixed in a more recent acorn version than the 0.9.0 that detective uses. @RReverser do you know if acorn supports for-of these days?

@ghost
Copy link

ghost commented Mar 2, 2015

I wish acorn was at 1.0.0 already so I could just depend on ^1.0.0

@domenic
Copy link
Contributor Author

domenic commented Mar 2, 2015

Me too: acornjs/acorn#209

@ghost
Copy link

ghost commented Mar 2, 2015

Same issue with const vs let or var:

x1.js:

const xs = [1,2,3]
for (let x of xs) console.log(x)

x2.js:

const xs = [1,2,3]
for (const x of xs) console.log(x)
$ browserify x1.js
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
const xs = [1,2,3]
for (let x of xs) console.log(x)

},{}]},{},[1]);
$ browserify x2.js

/tmp/x2.js:2
for (const x of xs) console.log(x)
     ^
ParseError: Unexpected token

@domenic
Copy link
Contributor Author

domenic commented Mar 2, 2015

Closing in favor of acornjs/acorn#213.

@domenic domenic closed this as completed Mar 2, 2015
domenic added a commit to jsdom/jsdom that referenced this issue Mar 3, 2015
It isn't supported by browserify: browserify/browserify#1146
domenic added a commit to whatwg/streams that referenced this issue Apr 27, 2015
Now that the browserify bug browserify/browserify#1146 is fixed we can do browser tests builds again
domenic added a commit to whatwg/streams that referenced this issue Apr 27, 2015
Now that the browserify bug browserify/browserify#1146 is fixed we can do browser tests builds again.

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

No branches or pull requests

1 participant