Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Regression for object browser keys #131

Closed
Andarist opened this issue Jan 13, 2018 · 3 comments
Closed

Regression for object browser keys #131

Andarist opened this issue Jan 13, 2018 · 3 comments

Comments

@Andarist
Copy link
Member

@keithamus

#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
Copy link
Contributor

Hey @Andarist - thanks for this, I'll work on a fix.

@allex
Copy link
Contributor

allex commented Jan 23, 2018

fixed in pr #134

@keithamus
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants