-
Notifications
You must be signed in to change notification settings - Fork 856
Delegate to local installs of wrangler when possible #1270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 4f4c50a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2536345365/npm-package-wrangler-1270 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1270/npm-package-wrangler-1270 Or you can use npx https://prerelease-registry.developers.workers.dev/runs/2536345365/npm-package-wrangler-1270 dev path/to/script.js |
a749166
to
8cc6fbf
Compare
Users will frequently install `wrangler` globally to run commands like `wrangler init`, but we also recommend pinning a specific version of `wrangler` in a project's `package.json`. Now, when a user invokes a global install of `wrangler`, we'll check to see if they also have a local installation. If they do, we'll delegate to that version. This requires that we define a `main` (maybe `module` would work too?) field in `package.json` so that `require.resolve` can find `"wrangler"`, but it's something of an implementation detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with the following NITS:
- Add a warning message when we do actually delegate (inside
runDelegatedWrangler()
?). - Move the node version check inside
runWrangler()
. - Make
shouldDelegate
a function and then we can call it like:
wranglerProcess = shouldDelegate() ? runDelegatedWrangler() : runWrangler();
Delegate to a local install of
wrangler
if one exists.Users will frequently install
wrangler
globally to run commands likewrangler init
, but we also recommend pinning a specific version ofwrangler
in a project'spackage.json
. Now, when a user invokes a global install ofwrangler
, we'll check to see if they also have a local installation. If they do, we'll delegate to that version.Closes #955
Here's a recording of this in action, with a couple
console.log
s indicating if a global or local installation is running: