Skip to content

feat: option to skip npm-shrinkwrap.json generation - #2294

Merged
mistydemeo merged 2 commits into
axodotdev:mainfrom
mistydemeo:misty/skip_npm_shrinkwrap_option
Feb 17, 2026
Merged

mistydemeo merged 2 commits into
axodotdev:mainfrom
mistydemeo:misty/skip_npm_shrinkwrap_option

Conversation

@mistydemeo

Copy link
Copy Markdown
Contributor

We've had a request to provide an option to disable npm-shrinkwrap.json for generated packages due to the ongoing churn of dependency versions. I've chosen to keep the current default, which disables it; the option can be used to flip it off. I've updated one of our tests to disable it in order to confirm that it's working.

cc @stewartadam

Fixes #2286.
Closes #2293.

@mistydemeo
mistydemeo force-pushed the misty/skip_npm_shrinkwrap_option branch 2 times, most recently from 4912b02 to 536bae7 Compare February 17, 2026 18:27
@mistydemeo
mistydemeo requested a review from Gankra February 17, 2026 18:29
@mistydemeo
mistydemeo force-pushed the misty/skip_npm_shrinkwrap_option branch from 536bae7 to 6035605 Compare February 17, 2026 18:29
@mistydemeo

Copy link
Copy Markdown
Contributor Author

It also occurs to me I could probably have left the package.json in the npm directory, but that would complicate updating npm-shrinkwrap.json with dependabot.

@mistydemeo
mistydemeo force-pushed the misty/skip_npm_shrinkwrap_option branch 2 times, most recently from 98cfbc4 to 3537c8b Compare February 17, 2026 19:32

@Gankra Gankra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The feature itself makes sense, I'm a bit perplexed by the random other changes.

Comment thread .github/workflows/ci.yml
Comment on lines +32 to +36
- name: Copy package.json to npm installer folder
working-directory: cargo-dist/templates/installer/npm
run: |
cp ../package.json .
cp ../npm-shrinkwrap.json .

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's this about?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry, should have explained this properly. I moved these out of the template directory with the rest of the files so we can write these two files individually, which simplified the choice of whether to skip npm-shrinkwrap.json. However, for the lint CI step to work, they need to be in the same directory as the contents of the module.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a comment above this to explain why.

Comment on lines 147 to -151
let package_json_path = Utf8Path::new(PACKAGE_JSON);
let orig_package_json =
templates.render_file_to_clean_string(TEMPLATE_INSTALLER_NPM_PACKAGE_JSON, &info)?;

// Now mangle the package.json with data we want
let orig_package_json = files
.remove(package_json_path)
.expect("npm template didn't have package.json!?");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why did this change..?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Previously, the package.json and npm-shrinkwrap were in a template directory that was written in a single batch. Since I moved them out of that directory, they need to be written individually.

Comment thread cargo-dist/src/config/v0_to_v1.rs Resolved
@mistydemeo
mistydemeo force-pushed the misty/skip_npm_shrinkwrap_option branch from 3537c8b to 00772ae Compare February 17, 2026 20:16
@mistydemeo
mistydemeo force-pushed the misty/skip_npm_shrinkwrap_option branch from 00772ae to 3c3a1b1 Compare February 17, 2026 21:01
@mistydemeo
mistydemeo merged commit 297b43a into axodotdev:main Feb 17, 2026
17 checks passed
@mistydemeo
mistydemeo deleted the misty/skip_npm_shrinkwrap_option branch February 17, 2026 21:31
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.

Option to disable generation of npm-shrinkwrap.json

2 participants