Skip to content

Conversation

JounQin
Copy link
Member

@JounQin JounQin commented Apr 24, 2025

related unrs/unrs-resolver#95

Summary by CodeRabbit

  • New Features
    • Improved support for the wasm32-wasi target architecture, enabling correct installation when using the --cpu=wasm32 option.
    • Added new constants and type definitions to better support WebAssembly and related environments.
  • Bug Fixes
    • Resolved installation issues for the wasm32-wasi CPU target.
  • Chores
    • Updated development dependencies and npm registry configuration.
    • Refactored internal type and constant management for improved maintainability.

@JounQin JounQin requested a review from Copilot April 24, 2025 02:58
Copy link

changeset-bot bot commented Apr 24, 2025

🦋 Changeset detected

Latest commit: 3d9a839

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

This PR includes changesets to release 1 package
Name Type
napi-postinstall 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

Copy link

coderabbitai bot commented Apr 24, 2025

Walkthrough

This update introduces new constants and type definitions to support the wasm32-wasi target, refactors code to use these constants, and modifies the npm installation process to correctly pass architecture-specific flags. Type declarations for platform and architecture are centralized in dedicated files, and redundant or inline type exports are removed. The npm configuration is updated to specify the registry and adjust the package manager version. Several development dependencies are upgraded, and a new changeset documents the patch-level fix for the wasm32-wasi installation issue.

Changes

File(s) Change Summary
.changeset/neat-bats-scream.md Added a changeset documenting a patch-level fix for correct installation support of the wasm32-wasi target with --cpu=wasm32.
.npmrc Added explicit npm registry URL configuration.
package.json Downgraded packageManager version; upgraded several dev dependencies.
lib/constants.js, lib/constants.d.ts, src/constants.ts Added and exported new constants: WASM32, WASI, WASM32_WASI, and EABI.
lib/types.d.ts, src/types.ts Introduced new type aliases (Platform, NodeJSArch) and the Target interface for platform/architecture typing.
lib/target.d.ts, src/target.ts Removed inline type/interface declarations; imported types and constants from external modules; updated logic to use new constants.
lib/target.js Refactored to use new constants for target triple parsing instead of string literals.
lib/index.d.ts Removed re-export of all types from ./target.js.
lib/index.js, src/index.ts Updated installUsingNPM function signature to accept a target parameter; modified npm install command to conditionally include --cpu=wasm32 for the wasm32-wasi target; improved version variable naming and consistency; removed re-export of target.js.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant checkAndPreparePackage
    participant installUsingNPM
    participant NPM

    User->>checkAndPreparePackage: Initiate package preparation
    checkAndPreparePackage->>installUsingNPM: Call with (hostPkg, pkg, version, target, subpath, nodePath)
    alt target is WASM32_WASI
        installUsingNPM->>NPM: npm install ... --cpu=wasm32
    else Other target
        installUsingNPM->>NPM: npm install ...
    end
    NPM-->>installUsingNPM: Installation result
    installUsingNPM-->>checkAndPreparePackage: Return status
    checkAndPreparePackage-->>User: Completion/result
Loading

Poem

In the warren of code, a patch hops in,
With WASM and WASI, let the installs begin!
Constants now tidy, types gathered with care,
No more stringy confusion floating in air.
The npm path’s clearer, the registry’s set—
A rabbit’s delight in a bug-free vignette!
🐇✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

lib/constants.d.ts

Oops! Something went wrong! :(

ESLint: 9.25.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

lib/constants.js

Oops! Something went wrong! :(

ESLint: 9.25.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

lib/index.js

Oops! Something went wrong! :(

ESLint: 9.25.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@1stg/eslint-config' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

  • 7 others
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the installation of the wasm32-wasi target by updating type definitions, target parsing logic, and installation commands to correctly handle the --cpu flag.

  • Updated type definitions in src/types.ts for Platform, NodeJSArch, and Target.
  • Revised triple parsing logic in both src/target.ts and lib/target.js using new constants.
  • Modified installation commands in src/index.ts and lib/index.js to support the wasm32-wasi target.

Reviewed Changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/types.ts Introduced new types to include 'wasi' and 'wasm'/platform values.
src/target.ts Updated triple parsing to use constants and removed redundant type declarations.
src/index.ts Adjusted installUsingNPM call and package version comparisons.
src/constants.ts Added constants for WASM32, WASI, WASM32_WASI, and EABI.
lib/target.js Mirrored triple parsing updates from src/target.ts.
lib/index.js Updated npm installation command to conditionally set the --cpu flag.
lib/constants.js Updated constants consistent with the src version.
Files not reviewed (2)
  • .npmrc: Language not supported
  • package.json: Language not supported
Comments suppressed due to low confidence (2)

src/target.ts:52

  • [nitpick] Consider using EABI.length instead of the hardcoded value 4 when slicing rawTriple to enhance clarity and maintainability.
const triple = rawTriple.endsWith(EABI) ? `${rawTriple.slice(0, -4)}-${EABI}` : rawTriple

lib/target.js:32

  • [nitpick] Consider using constants_js_1.EABI.length in place of the hardcoded value 4 when slicing rawTriple, to improve code clarity and reduce potential errors.
const triple = rawTriple.endsWith(constants_js_1.EABI) ? `${rawTriple.slice(0, -4)}-${constants_js_1.EABI}` : rawTriple;

Copy link

socket-security bot commented Apr 24, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​shikijs/​rehype@​3.2.2 ⏵ 3.3.0100 +11006897 +3100
Updatedclean-pkg-json@​1.2.1 ⏵ 1.3.079 +1100100 +186100
Updatedeslint-plugin-node-dependencies@​0.12.0 ⏵ 0.13.099 +2100100 +185 +8100
Updated@​types/​web@​0.0.222 ⏵ 0.0.22410010088 +196 +1100
Updatedeslint@​9.25.0 ⏵ 9.25.197 +110010096100
Updated@​vitest/​coverage-v8@​3.1.1 ⏵ 3.1.2100 +2100100 +31100 +2100

View full report

Copy link
Contributor

github-actions bot commented Apr 24, 2025

📊 Package size report   2%↑

File Before After
lib/constants.d.ts 168 B 96%↑330 B
lib/constants.js 486 B 41%↑687 B
lib/constants.js.map 306 B 47%↑449 B
lib/index.d.ts 291 B -11.7%↓257 B
lib/index.js 6.2 kB 1%↑6.3 kB
lib/index.js.map 5.8 kB 2%↑5.9 kB
lib/target.d.ts 348 B -71%↓101 B
lib/target.js 1.4 kB 14%↑1.6 kB
lib/target.js.map 1.4 kB 4%↑1.5 kB
lib/types.d.ts 541 B 52%↑825 B
Total (Includes all files) 42.7 kB 2%↑43.7 kB
Tarball size 12.4 kB 2%↑12.7 kB
Unchanged files
File Size
lib/cli.d.ts 31 B
lib/cli.js 326 B
lib/cli.js.map 328 B
lib/helpers.d.ts 685 B
lib/helpers.js 7.1 kB
lib/helpers.js.map 6.2 kB
lib/types.js 110 B
lib/types.js.map 102 B
LICENSE 1.1 kB
package.json 3.5 kB
README.md 6.4 kB

🤖 This report was automatically generated by pkg-size-action

Copy link

pkg-pr-new bot commented Apr 24, 2025

Open in StackBlitz

npm i https://pkg.pr.new/napi-postinstall@18

commit: 3d9a839

Copy link
Contributor

github-actions bot commented Apr 24, 2025

size-limit report 📦

Path Size
lib/index.js 2.07 KB (+2.13% 🔺)

Copy link

codecov bot commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 55.79%. Comparing base (bbdef3a) to head (3d9a839).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/index.ts 81.81% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main      #18       +/-   ##
===========================================
+ Coverage   39.95%   55.79%   +15.83%     
===========================================
  Files           6        6               
  Lines         458      466        +8     
  Branches       53       67       +14     
===========================================
+ Hits          183      260       +77     
+ Misses        275      206       -69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

github-actions bot commented Apr 24, 2025

Deploy preview for napi-postinstall ready!

✅ Preview
https://napi-postinstall-d37wduy70-1stg.vercel.app

Built with commit 3d9a839.
This pull request is being automatically deployed with vercel-action

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (3)
.changeset/neat-bats-scream.md (1)

1-6: Reference related issue in changeset. Consider adding a link to unrs/unrs-resolver#95 in the changeset body to provide context for this patch-level fix. For example:

fix: support install `wasm32-wasi` correctly with `--cpu=wasm32`

Closes unrs/unrs-resolver#95
package.json (1)

10-10: Consider documenting the reason for package manager downgrade.

Downgrading from npm@11.3.0 to npm@10.9.2 might have been done for specific compatibility reasons. Consider adding a comment or updating the README to explain why this change was necessary.

lib/index.js (1)

130-130: Correctly updated function calls with new parameters.

The calls to installUsingNPM and downloadDirectlyFromNPM have been properly updated to use the correct version parameter and pass the target parameter where needed.

I'd recommend adding a small unit test to verify the --cpu=wasm32 flag is correctly added for wasm32-wasi targets.

Also applies to: 136-136

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bbdef3a and 5c25e05.

⛔ Files ignored due to path filters (4)
  • lib/constants.js.map is excluded by !**/*.map
  • lib/index.js.map is excluded by !**/*.map
  • lib/target.js.map is excluded by !**/*.map
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (14)
  • .changeset/neat-bats-scream.md (1 hunks)
  • .npmrc (1 hunks)
  • lib/constants.d.ts (1 hunks)
  • lib/constants.js (1 hunks)
  • lib/index.d.ts (0 hunks)
  • lib/index.js (3 hunks)
  • lib/target.d.ts (1 hunks)
  • lib/target.js (2 hunks)
  • lib/types.d.ts (1 hunks)
  • package.json (3 hunks)
  • src/constants.ts (1 hunks)
  • src/index.ts (6 hunks)
  • src/target.ts (2 hunks)
  • src/types.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • lib/index.d.ts
🧰 Additional context used
🧬 Code Graph Analysis (4)
lib/index.js (4)
lib/helpers.js (7)
  • pkg (65-65)
  • version (62-62)
  • path (12-12)
  • fs (11-11)
  • node_child_process_1 (10-10)
  • constants_js_1 (13-13)
  • napi (55-55)
lib/constants.js (1)
  • path (5-5)
src/constants.ts (1)
  • require (7-9)
lib/target.js (1)
  • constants_js_1 (4-4)
src/target.ts (1)
src/constants.ts (4)
  • WASM32_WASI (15-15)
  • WASM32 (13-13)
  • WASI (14-14)
  • EABI (17-17)
lib/constants.d.ts (1)
src/constants.ts (4)
  • WASM32 (13-13)
  • WASI (14-14)
  • WASM32_WASI (15-15)
  • EABI (17-17)
lib/types.d.ts (1)
src/types.ts (3)
  • Platform (35-35)
  • NodeJSArch (37-37)
  • Target (39-45)
🪛 GitHub Check: codecov/patch
src/index.ts

[warning] 197-197: src/index.ts#L197
Added line #L197 was not covered by tests


[warning] 254-254: src/index.ts#L254
Added line #L254 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on windows-latest
🔇 Additional comments (21)
src/constants.ts (1)

13-17: Centralize target strings with new constants. Introducing WASM32, WASI, WASM32_WASI, and EABI improves maintainability and avoids magic strings across modules.
Please verify that all hard-coded references to these values in src/target.ts and src/index.ts have been replaced with the new constants.

lib/target.d.ts (1)

1-2: Validate import path for type declarations. Importing Target from ./types.js in a .d.ts file may require specific module resolution settings (e.g., "moduleResolution": "node16"), or alternatively dropping the .js extension for better compatibility. Please verify your TypeScript configuration supports this import pattern.

lib/constants.d.ts (1)

4-7: Add new WASM and ABI constants in declarations. The new constant declarations for WASM32, WASI, WASM32_WASI, and EABI correctly mirror the runtime definitions, keeping the type declarations in sync with implementation.

lib/constants.js (1)

9-12: Well-structured addition of WebAssembly-related constants.

Adding these constants is a good practice for improving maintainability and consistency across the codebase. The constants are clearly named and I like how WASM32_WASI is constructed using template literals from the other constants.

package.json (1)

59-94: Good maintenance of dependencies.

The dependency updates look appropriate and keeping dependencies up-to-date is a good security practice.

lib/target.js (2)

4-4: Excellent refactoring to use constants.

Replacing hardcoded string literals with constants improves code maintainability and consistency. The conditional checks are now more readable and less prone to typos.

Also applies to: 20-28


31-33: Good use of constants for EABI suffix check.

Refactoring the EABI suffix check to use the constant improves consistency and reduces the chance of errors in future modifications.

lib/index.js (3)

57-57: Well-designed function signature update.

Adding the target parameter to the installUsingNPM function enhances the API to support WebAssembly architectures.


64-64: Good conditional flag addition for wasm32 CPU target.

The conditional addition of --cpu=wasm32 for wasm32-wasi targets is the core fix for the issue in the PR description. This will correctly handle the installation for WebAssembly targets.


100-103: Good variable renaming to avoid shadowing.

Renaming the destructured version to pkgVersion and using version = pkgVersion as a fallback prevents variable shadowing and makes the code clearer. The version consistency check is appropriately updated to use the new variable names.

lib/types.d.ts (1)

29-37: Good addition of WebAssembly and WASI type support.

The new type definitions effectively extend NodeJS platform and architecture types to support WebAssembly environments. The Target interface properly encapsulates all necessary properties for target platform identification.

src/types.ts (1)

35-45: Well-structured type definitions with proper spacing.

These type definitions mirror those in lib/types.d.ts, maintaining consistency across the TypeScript source and declaration files. Good organization with appropriate spacing between type declarations for readability.

src/target.ts (3)

3-4: Good refactoring to use centralized types and constants.

Importing types from a dedicated module and constants instead of using string literals improves maintainability.


40-49: Improved code with constants replacing magic strings.

Using the imported constants (WASM32_WASI, WASM32, WASI) instead of hardcoded string literals makes the code more maintainable and reduces the risk of typos or inconsistencies.


52-53: Good use of constant for EABI check.

Replacing the hardcoded 'eabi' string with the EABI constant maintains consistency with the other constant usage in this file.

src/index.ts (6)

9-9: Good import of required constants.

Added import for the WebAssembly-related constants that will be used later in the conditional logic.


79-79: Critical parameter addition for target-specific installation.

Adding the target parameter to installUsingNPM is essential for implementing the WebAssembly-specific flag handling.


103-105: Key implementation for wasm32-wasi support.

This conditional addition of the --cpu=wasm32 flag when the target is WASM32_WASI is the core change needed to fix the installation support for the wasm32-wasi target, which aligns with the PR objective.


188-188: Good variable renaming to avoid shadowing.

Renaming version to pkgVersion in destructuring avoids variable shadowing in the subsequent code.


190-193: Proper variable naming with good default.

Setting version = pkgVersion as a default value ensures backward compatibility and provides a sensible fallback.


243-243: Properly passing the target parameter.

Updated function call to include the new target parameter, ensuring it's available for the conditional CPU flag logic.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (1)
src/index.ts (1)

75-83: 🛠️ Refactor suggestion

Explicitly type the new target parameter

installUsingNPM() now accepts a target argument but it’s typed generically as string.
Since you already have a Target/NodeJSArch union in src/types.ts, using that type will:

  • give callers autocomplete / compile-time safety (only recognised targets compile),
  • prevent accidental typos (e.g. "wasm32_wasi" vs "wasm32-wasi"),
  • reduce the risk of injecting unexpected shell flags later on.
-function installUsingNPM(
-  hostPkg: string,
-  pkg: string,
-  version: string,
-  target: string,
+function installUsingNPM(
+  hostPkg: string,
+  pkg: string,
+  version: string,
+  target: Target,        // <-- or `NodeJSArch` depending on which is correct
🧹 Nitpick comments (2)
src/index.ts (2)

103-105: Shell-injection surface – quote interpolated values

pkg and version ultimately come from package.json; still, quoting is a good defensive habit and prevents accidental breaks when a version contains shell-metacharacters (e.g. pre-release tags like 1.0.0-beta.1).

-      } ${pkg}@${version}`,
+      } "${pkg}@${version}"`,

This also keeps behaviour consistent across Windows where caret (^) in version strings can be interpreted by cmd.exe.


188-199: Add tests for the new version-consistency branch

Static analysis flags lines 195-197 as uncovered. A simple happy-path test exercising the mismatch branch will lock in behaviour:

  1. Create a dummy package.json with version: "1.0.0".
  2. Stub getNapiInfoFromPackageJson to return { napi: { packageName: 'dummy' }, version: '2.0.0' }.
  3. Expect checkAndPreparePackage(pkgJson, true) to throw the exact error.

Would you like assistance scaffolding that unit test?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 197-197: src/index.ts#L197
Added line #L197 was not covered by tests

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c25e05 and 3d9a839.

⛔ Files ignored due to path filters (4)
  • lib/constants.js.map is excluded by !**/*.map
  • lib/index.js.map is excluded by !**/*.map
  • lib/target.js.map is excluded by !**/*.map
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (14)
  • .changeset/neat-bats-scream.md (1 hunks)
  • .npmrc (1 hunks)
  • lib/constants.d.ts (1 hunks)
  • lib/constants.js (1 hunks)
  • lib/index.d.ts (0 hunks)
  • lib/index.js (3 hunks)
  • lib/target.d.ts (1 hunks)
  • lib/target.js (2 hunks)
  • lib/types.d.ts (1 hunks)
  • package.json (3 hunks)
  • src/constants.ts (1 hunks)
  • src/index.ts (6 hunks)
  • src/target.ts (2 hunks)
  • src/types.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • lib/index.d.ts
✅ Files skipped from review due to trivial changes (1)
  • src/target.ts
🚧 Files skipped from review as they are similar to previous changes (11)
  • .npmrc
  • lib/target.d.ts
  • .changeset/neat-bats-scream.md
  • src/constants.ts
  • src/types.ts
  • lib/constants.js
  • lib/constants.d.ts
  • lib/index.js
  • lib/types.d.ts
  • package.json
  • lib/target.js
🧰 Additional context used
🪛 GitHub Check: codecov/patch
src/index.ts

[warning] 197-197: src/index.ts#L197
Added line #L197 was not covered by tests


[warning] 254-254: src/index.ts#L254
Added line #L254 was not covered by tests

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Lint and Test with Node.js 20 on macos-latest
  • GitHub Check: Lint and Test with Node.js 20 on ubuntu-latest
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on macos-latest
  • GitHub Check: Lint and Test with Node.js 20 on windows-latest
  • GitHub Check: Lint and Test with Node.js 22 on windows-latest
  • GitHub Check: Lint and Test with Node.js 18 on windows-latest
🔇 Additional comments (2)
src/index.ts (2)

103-105: Double-check the CLI flag – npm recognises --arch, not --cpu

According to npm’s current CLI docs the correct flag for overriding architecture is --arch=<arch>.
--cpu is not listed and may silently be ignored, meaning the wasm32-wasi package could still install for the host architecture and break at runtime.

Please verify the required flag and adjust accordingly:

-        target === WASM32_WASI ? ` --cpu=${WASM32}` : ''
+        target === WASM32_WASI ? ` --arch=${WASM32}` : ''

If --cpu is intentional (e.g. for a custom npm fork) add a comment with a reference explaining why, to avoid future regressions.


243-244:

✅ Verification successful

Ensure all call-sites were updated to pass target

installUsingNPM() gained a parameter and this call was adapted, but others (internal scripts/tests) might still use the old signature.

Update any remaining occurrences to avoid runtime TypeError: expected 6 arguments but got 5.


🏁 Script executed:

# quick grep to verify
rg -n "installUsingNPM\(" --glob '!dist/**'

Length of output: 365


All installUsingNPM call-sites updated
Ran rg -n "installUsingNPM(" --glob "!dist/**" and confirmed every invocation now passes six arguments (including target). No further changes needed.

@JounQin JounQin merged commit 8a887ee into main Apr 24, 2025
30 checks passed
@JounQin JounQin deleted the fix/wasi branch April 24, 2025 03:20
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.

1 participant