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

fix(browser-resolve): fix regressions from refactor #133

Merged
merged 4 commits into from
Feb 14, 2018

Conversation

keithamus
Copy link
Contributor

@keithamus keithamus commented Jan 15, 2018

This should fix #130 and #131, with tests added for each regression.

@keithamus keithamus force-pushed the fix-browser-resolve-regressions branch from f00c623 to f0258b6 Compare January 15, 2018 12:00
@Andarist
Copy link
Member

Im not entirely sure, but looking at the source code for a brief moment it seems that this PR is focused on supporting relativeMain, my original issue was for such package.json:

{
	"main": "index.js",
	"browser": {
		"./index.js": "./browser.js",
		"./nested/dep.js": "./nested/browser-dep.js",
		"test": "./browser-test.js"
	}
}

And im not sure if this PR fixes that. I'd suspect ./nested/dep.js still being resolved against wrong directory, correct me if im wrong (it would also be good to add test for my case).

We could go even further and check what gets resolved if we omit "main" entirely and leave just "browser" field with relative paths and nested relative paths. I'd suspect at least one of those cases won't work.

@keithamus
Copy link
Contributor Author

@Andarist this is a fix for #130 - a fix for your issue will be coming soon.

@Andarist
Copy link
Member

Cool, haven't realized that those 2 are separate underlaying issues.

While I could have made a PR to browser-resolve to fix the above issues - doing so would reduce browser-resolve down to a few LOC, and I'm not sure it is under active maintainence. There are open PRs from a few years ago. I figured it would be best to move the few LOC it needs into this module.

Im only wondering if this one wouldnt be overally a better fix for the whole issue. Even if they do not merge it, ur fork could be released under a new package name - or you could even ask npm for package 'takeover' if the original package is in fact unmaintained.

Inlining this here seems like a duplicated effort - other tools could benefit from this being a separate package.

@keithamus keithamus force-pushed the fix-browser-resolve-regressions branch from f0258b6 to 7529f70 Compare January 15, 2018 13:38
@keithamus
Copy link
Contributor Author

@Andarist I've pushed new changes which also fix #131

@keithamus
Copy link
Contributor Author

keithamus commented Jan 15, 2018

original package

I did look into this, but it added too much bureaucratic complexity. Admittedly there were some regressions but this solution here is still only a handful of lines that are integrated into node-resolve. As a standalone package it would be much larger. I didn't consider it a worthwhile endeavor.

Copy link
Member

@Andarist Andarist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not a rollup org member, but the code looks good to me and fixes reported issues.

@allex
Copy link
Contributor

allex commented Jan 24, 2018

@Andarist, @keithamus For this issue, actually we just need provide a path filter option pathFilter( pkg, resvPath, relativePath ) of resolve module, please see #134 for detail codes

For more about resolve module options, see:
https://www.npmjs.com/package/resolve#resolveid-opts-cb

@keithamus
Copy link
Contributor Author

This has been updated to cover some additional usecases @mislav found. This should be very robust now I believe.I'm very confident in this PR.

@Rich-Harris Rich-Harris merged commit 4c35e91 into rollup:master Feb 14, 2018
@Rich-Harris
Copy link
Contributor

released as 3.0.3, thanks!

@keithamus keithamus deleted the fix-browser-resolve-regressions branch February 14, 2018 15:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.0.1 and 3.0.2 have a regression on file size
5 participants