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

browser field in package.json no longer works #1250

Open
Gillingham opened this issue May 7, 2015 · 2 comments
Open

browser field in package.json no longer works #1250

Gillingham opened this issue May 7, 2015 · 2 comments
Labels

Comments

@Gillingham
Copy link

In package.json I have

"browser": {
    "rampage": "./rampage/static-dev/js/rampage.js"
}

In browserify <10.1.1 I could then use .add('rampage') just fine, now however it errors out:

Error: Cannot find module '*snip*/rampage' from '*snip*'
    at *snip*/node_modules/browserify/node_modules/resolve/lib/async.js:55:21
    at load (*snip*/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
    at onex (*snip*/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
    at *snip*/node_modules/browserify/node_modules/resolve/lib/async.js:22:47

I can't test 10.1.1 to be certain because of the JSONStream changes, I can't even roll back to a working browserify version because of that as well. This was most definitely working in 10.1.0 though.

@Gillingham
Copy link
Author

This happened prior as reported in #1072 and was fixed, and in a previous browserify version as well.

Is this a non-standard usage of the field?

#1072 mentions a work-around using syntax like .require('./rampage/static-dev/js/rampage.js', {'expose': 'rampage'}) which I can confirm works with 10.1.2, I would just prefer to have the alias in package.json instead of my build files, but if I have to swap I will.

@jmm
Copy link
Collaborator

jmm commented May 7, 2015

@Gillingham

Is this a non-standard usage of the field?

#1072 was about doing b.require('thing-in-browser-field') and as I mentioned there, that usage was not documented and did not appear to have test coverage either. So unless and until it gained those things, I consider it an accident.

Doing b.add('thing-in-browser-field') is likewise not documented and apparently doesn't have test coverage either. Furthermore, there's now the uncertainty in #1248 about whether b.add('some-module-not-in-browser-field') is even supposed to work.

#1072 mentions a work-around using syntax like .require('./rampage/static-dev/js/rampage.js', {'expose': 'rampage'}) which I can confirm works with 10.1.2

That is also not documented. See #1137. I would consider using the workaround I suggested in #1072 (comment) for now:

b.add(require('/somedir/package.json').browser.rampage)

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

No branches or pull requests

3 participants