browserify / browser-resolve

resolve function which support the browser field in package.json
MIT License
102 stars 70 forks source link

options passed to resolve #20

Closed mikerobe closed 11 years ago

mikerobe commented 11 years ago

I ran into an issue with browserify, which uses browser-resolve, in that it wasn't finding .coffee files. It turns out this was because it (unlike node loaded with require('coffee-script')) requires the full extension -- require('foo.coffee') instead of require('foo'), which is definitely not something you want to do (it locks you into coffee files, won't use the .js if you "transpile" it, etc.)

Browser-resolve uses resolve and resolve has an option to add file extensions using the extensions key in its command options, but resolve's options aren't exposed in the browser-resolve API, so there's no way to add this file extension when using browser-resolve and thus no way to do it in browserify.

I think browser-resolve should pass the options it receives onto the internal resolve call by copying the keys over from parent.

andreypopp commented 11 years ago

see #12 and and #19

alexgorbatchev commented 11 years ago

@mikerobe i have a browserify branch that should have this addressed https://github.com/alexgorbatchev/node-browserify

defunctzombie commented 11 years ago

I will take a look at the rebased work. I will once again say tho that my focus is on JavaScript development and what this proposes is not for JavaScript development and therefore I see it as an anti-feature and am not interested in it :) On May 14, 2013 5:56 PM, "Alex Gorbatchev" notifications@github.com wrote:

@mikerobe https://github.com/mikerobe i have a browserify branch that should have this addressed https://github.com/alexgorbatchev/node-browserify

— Reply to this email directly or view it on GitHubhttps://github.com/shtylman/node-browser-resolve/issues/20#issuecomment-17908025 .

alexgorbatchev commented 11 years ago

I would like to present an argument that supporting a middle language that does compile to your language of choice that you make effort to support only makes your efforts more successful :)

I've been writing in ecma script since early 2000, but switched to coffee because i find it's easier to digest and write... but i still think in ecma, coffee is just a different outfit for it.

I would like to call for no coffee discrimination ;)

andreypopp commented 11 years ago

@shtylman is there any progress with this issue? I asked @substack on #browserify and he seems to be ready to merge corresponding pull request into module-deps and browserify after this one is merged

defunctzombie commented 11 years ago

I have been travelling lately and not had a chance to review this yet. I will add the feature tho; I have given up fighting this. I personally think it is stupid but realize other people are doing it this way.

ghost commented 11 years ago

This seems like such a minor thing. I already do require('./file.js') sometimes because I like how explicit that is. Extensions are global and mutating globals gets really weird and uncomposable really fast.

Raynos commented 11 years ago

I think require('./file") should only be used for folders

andreypopp commented 11 years ago

@substack @Raynos for me it's not a minor thing I use coffeescript and

Given that this change is already supported by node-resolve and is a single-line change, I think, it would make just a little tiny piece of harm to browserify in terms of complexity and at the same time this resolves a lot of burden for AltJS (CoffeeScript in my case) langs developers.

Raynos commented 11 years ago

@andreypopp the fact that coffeescript does not compile require("x.coffee") to require("x.js) is clearly a bug.

andreypopp commented 11 years ago

@Raynos I do not think that it is really sane to allow a compiler to mangle string literals, I would consider this a flaw of CommonJS module system then, because it is uses string literals and not static identifiers for importing modules

Raynos commented 11 years ago

Then you should just only have require("x.js") references and when you compile it into js there is no string munging.

andreypopp commented 11 years ago

Then I have to compile sources separately before running even in nodejs and give up CoffeeScript development tools (such a REPL)

Andrey Popp

On 23.05.2013, at 12:18, Raynos notifications@github.com wrote:

Then you should just only have require("x.js") references and when you compile it into js there is no string munging.

— Reply to this email directly or view it on GitHub.

defunctzombie commented 11 years ago

I believe this issue was resolved a while back. If it is still a problem please let me know.