Regression for object browser keys
Andarist opened this issue · 3 comments
Andarist commented
#127 has introduced regression for object browser keys. From what I see they are kinda ignored.
Example:
const importer = '/Users/mateuszburzynski/Desktop/node-uuid/src/v1.js'
const importee = './rng'
const options = { browser: true }
// what gets passed in as arg for packageFilter
const pkg = {"name":"uuid","version":"3.1.0","description":"RFC4122 (v1, v4, and v5) UUIDs","keywords":["uuid","guid","rfc4122"],"license":"MIT","bin":{"uuid":"./bin/uuid"},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-add-module-exports":"^0.2.1","babel-plugin-transform-es2015-modules-commonjs":"^6.26.0","eslint":"4.5.0","mocha":"3.1.2","runmd":"^1.0.1"},"scripts":{"build":"babel src --out-dir lib","test":"mocha test/test.js","md":"runmd --watch --output=README.md README_js.md","prepare":"npm run build && runmd --output=README.md README_js.md"},"browser":{"./lib/rng.js":"./lib/rng-browser.js","./lib/sha1.js":"./lib/sha1-browser.js","./lib/md5.js":"./lib/md5-browser.js","./src/rng.js":"./src/rng-browser.js","./src/sha1.js":"./src/sha1-browser.js","./src/md5.js":"./src/md5-browser.js"},"repository":{"type":"git","url":"https://github.com/kelektiv/node-uuid.git"},"dependencies":{}}
packageBrowserField {"./lib/rng.js":"./lib/rng-browser.js","./lib/sha1.js":"./lib/sha1-browser.js","./lib/md5.js":"./lib/md5-browser.js","./src/rng.js":"./src/rng-browser.js","./src/sha1.js":"./src/sha1-browser.js","./src/md5.js":"./src/md5-browser.js"}
// result of resolveId call
const resolved = '/Users/mateuszburzynski/Desktop/node-uuid/src/rng.js'
// and this actually should be '/Users/mateuszburzynski/Desktop/node-uuid/src/rng-browser.js'
resolveId
has no knowledge of object browser key - it accept only simple strings in main, so it resolves the whole thing using a simple node algo and the result is not adjusted - especially that importee path was relative to the importer directory and browser field specifies overrides relative to the package root.
keithamus commented
I believe this to be fixed. So I'm going to close this. If you think its an issue still, please comment and I'll re-open.