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

Not working in Node 6.2 #24

Closed
lemonmade opened this issue Jun 9, 2016 · 3 comments
Closed

Not working in Node 6.2 #24

lemonmade opened this issue Jun 9, 2016 · 3 comments

Comments

@lemonmade
Copy link
Member

I'm not sure exactly why this is breaking on newer Node, but an example app with the following index file fails to compile with Node 6.2.0:

import {map} from 'lodash';
console.log(map([1, 2, 3], (val) => val * 3);

Fails with the following error (as an aside, I had to dive into the source code to expose the error stack, might be worth exposing that here: https://github.com/Shopify/schmooze/blob/master/lib/schmooze/processor_generator.rb#L18):

TypeError: /Users/chris/Projects/illustrations/app/assets/javascripts/application.js: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.dirname (path.js:1324:5)
    at resolve.sync (/Users/chris/.gem/ruby/2.3.1/gems/sprockets-commoner-0.2.6/js/babel-plugin-sprockets-commoner-internal/node_modules/browser-resolve/index.js:281:21)
    at resolveTarget (/Users/chris/.gem/ruby/2.3.1/gems/sprockets-commoner-0.2.6/js/babel-plugin-sprockets-commoner-internal/index.js:124:26)
    at PluginPass.VariableDeclarator (/Users/chris/.gem/ruby/2.3.1/gems/sprockets-commoner-0.2.6/js/babel-plugin-sprockets-commoner-internal/index.js:166:18)
    at NodePath._call (/Users/chris/Projects/illustrations/node_modules/babel-traverse/lib/path/context.js:78:18)
    at NodePath.call (/Users/chris/Projects/illustrations/node_modules/babel-traverse/lib/path/context.js:49:17)
    at NodePath.visit (/Users/chris/Projects/illustrations/node_modules/babel-traverse/lib/path/context.js:108:12)
    at TraversalContext.visitQueue (/Users/chris/Projects/illustrations/node_modules/babel-traverse/lib/context.js:174:16)
    at TraversalContext.visitMultiple (/Users/chris/Projects/illustrations/node_modules/babel-traverse/lib/context.js:119:17)
    at TraversalContext.visit (/Users/chris/Projects/illustrations/node_modules/babel-traverse/lib/context.js:217:19)

I can fix this by changing https://github.com/Shopify/sprockets-commoner/blob/master/js/babel-plugin-sprockets-commoner-internal/index.js#L124 to read:

var resolvedPath = resolve(path, Object.assign({}, opts, {filename: file.opts.filename}));

This issue goes away in 5.7.0.

cc/ @bouk @dfmcphee

@bouk
Copy link
Contributor

bouk commented Jun 10, 2016

Hmm seems browser-resolve does a weird thing where it always calls dirname on filename, even if it doesn't use it and goes with basedir instead (look at line 231 in browser-resolve/index.js). I'll PR to browser-resolve

@bouk
Copy link
Contributor

bouk commented Jun 10, 2016

Oh actually it's fixed already upstream browserify/browser-resolve#80

@bouk
Copy link
Contributor

bouk commented Jun 13, 2016

Version 0.2.7 has been released with this issue fixed

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

No branches or pull requests

2 participants