Skip to content
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

feat: batch installs for npm packages #1089

Merged
merged 1 commit into from
May 25, 2022
Merged

feat: batch installs for npm packages #1089

merged 1 commit into from
May 25, 2022

Conversation

rozenmd
Copy link
Contributor

@rozenmd rozenmd commented May 23, 2022

Closes #1036

@changeset-bot
Copy link

changeset-bot bot commented May 23, 2022

🦋 Changeset detected

Latest commit: 7dcae68

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

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

@github-actions
Copy link
Contributor

github-actions bot commented May 23, 2022

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/2385256223/npm-package-wrangler-1089

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1089/npm-package-wrangler-1089

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2385256223/npm-package-wrangler-1089 dev path/to/script.js

@rozenmd rozenmd force-pushed the batch-npm-calls branch from bd588e0 to 466bbbf Compare May 23, 2022 10:49
@rozenmd rozenmd marked this pull request as ready for review May 23, 2022 10:49
@rozenmd rozenmd force-pushed the batch-npm-calls branch 4 times, most recently from c8b8c73 to 92e8fdf Compare May 23, 2022 16:27
@rozenmd rozenmd force-pushed the batch-npm-calls branch 2 times, most recently from 8d6b8bb to 7cbd65f Compare May 25, 2022 13:31
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

This appears to be doing the right thing now. Thanks!

I made a suggestion about how we could refactor this but I don't want to block this improvement.

Comment on lines 722 to 726
await installPackages(
shouldRunPackageManagerInstall,
devDepsToInstall
);

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand that you are running this here before the writePackageJsonScriptsAndUpdateWranglerToml() function because you want the install to appear before the final instructions to the user.

But I think we could make this cleaner by having an extra "global" called instructions: string[]. Then writePackageJsonScriptsAndUpdateWranglerToml() could add the instructions to that list rather than logging them directly.

This would mean we would just need a single call to installPackages() write at the end, followed by a call to a function like printInstructions() which will then log out the instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a fantastic idea, I'll give that a go now actually

@rozenmd rozenmd force-pushed the batch-npm-calls branch from 7cbd65f to d0548f1 Compare May 25, 2022 14:25
const devDepsToInstall: string[] = [];
const instructions: string[] = [];
let shouldRunPackageManagerInstall = false;
let hasAlreadyRunPackageInstall = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that we only ever run installPackages() once, this is no longer needed.

@rozenmd rozenmd force-pushed the batch-npm-calls branch from d0548f1 to 7dcae68 Compare May 25, 2022 14:53
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Ship it!

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

Successfully merging this pull request may close these issues.

polish: batch npm install calls during wrangler init
2 participants