Fix unmet dependency errors by stripping bundledDependencies in WASM package - #20526
abdelrhmanahmed255 wants to merge 1 commit into
Conversation
|
| if (wasmPkg.bundledDependencies) { | ||
| delete wasmPkg.bundledDependencies | ||
| await fs.writeFile(wasmPkgPath, JSON.stringify(wasmPkg, null, 2) + '\n') |
There was a problem hiding this comment.
Npm fix lacks regression coverage
The existing WASM tests install through pnpm and check that the runtime loads. They do not test the npm installation error this change addresses. A test that packs the built WASM package, installs it with npm, and runs npm ls would catch a release tarball that still causes unmet-dependency errors.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. WalkthroughThe WASI package manifest no longer lists Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The WASI package retains its regular dependencies, and the build removes the bundle metadata before packaging. No actionable merge risk is established. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
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. Comment |
Problem
When installing
@tailwindcss/postcssin an environment using strictnpm(especiallynpm 11+), users experienceELSPROBLEMSandunmet dependencyerrors related to the WASM fallback runtime packages (@emnapi/core,@emnapi/wasi-threads,@napi-rs/wasm-runtime,@tybys/wasm-util).The issue stems from
@tailwindcss/oxide-wasm32-wasilisting these packages in bothdependenciesandbundledDependencies. Because of howpnpmworkspaces (which this monorepo uses) handle symlinking, the actualnode_modulesare not fully packed into the published tarball forbundledDependencies. When end-users install the package usingnpm,npmexpects bundled dependencies to already exist inside the downloaded tarball and skips fetching them from the registry. Since they are missing from the tarball,npm lssurfaces unmet dependency errors and blocks strict installations.Solution
This PR strips the
bundledDependenciesarray from@tailwindcss/oxide-wasm32-wasi/package.json.Since these packages are already correctly listed under standard
dependencies, removing them frombundledDependenciesforcesnpm,yarn, andpnpmto correctly fetch and resolve them from the registry during installation, completely eliminating thenpm lserrors.Implementation details:
bundledDependenciesfromcrates/node/npm/wasm32-wasi/package.json.crates/node/scripts/move-artifacts.mjsto automatically stripbundledDependenciesfrom the package.json during thepostbuild:wasmlifecycle. This ensures that even if@napi-rs/cliautomatically injectsbundledDependenciesduringnapi build --target wasm32-wasip1-threads, they are stripped immediately before packing/publishing.Verification
Locally verified that the
package.jsoninnpm/wasm32-wasiis correctly mutated post-build and no longer includesbundledDependencies, while preserving all functionaldependencies.