michaelficarra / commonjs-everywhere

:rainbow: minimal CommonJS browser bundler with aliasing, extensibility, and source maps
BSD 3-Clause "New" or "Revised" License
158 stars 21 forks source link

fix canonicalisation of paths #78

Closed piranha closed 11 years ago

piranha commented 11 years ago

Before that when I were doing cjsify -r src main.coffee -o build/out.js, everything would be normal except for the root require, which would look like require('/../main.coffee'). This change fixes the problem.

michaelficarra commented 11 years ago

No, I believe this just breaks things. If you have a file in /src called main.coffee, its canonical name will be /main.coffee. That will conflict with /main.coffee derived from /src/main.coffee. What actual issue has the current method of canonicalisation caused? Can you add a test that shows the issue?

piranha commented 11 years ago

To be honest, I can't figure out how to add a test - bundle is replaced in test-setup.coffee by custom function, which doesn't accept root.

Can you please just try it yourself?

mkdir src
echo 'console.log 1' > src/main.coffee
node_modules/.bin/cjsify -r src main.coffee

And just look at the output. Second line from the end is the wrong one.

jesstelford commented 11 years ago

Just ran into this myself, and found this fix, thanks!

@michaelficarra Any plan to release a new minor version (v0.9.4)?

michaelficarra commented 11 years ago

Done: https://npmjs.org/package/commonjs-everywhere

jesstelford commented 11 years ago

:+1: