Bug/issue 505 improve default npx support #511
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue
resolves #505
Summary of Changes
process.cwd()
npx
docs back to the home page and quick startTODO
xdescribe
spec here and then we can merge.Notes
For now, just getting this quick and dirty happy path working, using unpkg.com as a fallback. But I did reach out in NodeJS slack channel and got this tip on using NodeJS
require.resolve
.Essentially, give it a package name and it will look up the path for you.
With a better local testing environment (using
npm|yarn link
), we could set it up so that it in plugins-node-modulesresolve
just delegates all this torequire.resolve
instead:We want to generate our own full path since the
url
is what we want based on walking package.json (in theory) as opposed to what NodeJS thinks we want.That said, perhaps there is a case for us to entirely refactor
getPackageEntryPath
to be based offrequire.resolve
logic instead? 🤔We intentionally always want to favor ESM if we can, so I guess it depends on if anything would break but we certainly have enough tests for that. 😃
I'll definitely be making a follow up issue for us to explore this more so we can try and provide the best
npx
experience possible as part of hitting 1.0, and not have to worry ourselves about all this node_modules look up stuff if we can help it.