thlorenz / browserify-shim

📩 Makes CommonJS incompatible files browserifyable.
MIT License
933 stars 87 forks source link

Multiple package.json in one app #200

Closed xueruini closed 9 years ago

xueruini commented 9 years ago

I come to a weird shim error with the following dirs. package.json exists in both the top-level folder (a) and sub-folder (b).

~ $  tree a
a
├── a.js
├── b
│   ├── b.js
│   └── package.json
└── package.json

Both package.json files have different b-shim configurations, and b.js is required by a.js like

# a.js
require('./b/b.js');

When executing browserify -t browserify-shim a.js, I found b/package.json was taking effect. I think a.js is the entry file, so a/package.json should be read, and during requiring, b/package.json will not be read any more. But it seems not.

bendrucker commented 9 years ago

The nearest parent package.json with b-shim config will always be read. This is expected behavior.