fix(package): keep the generated installer's artifact URL statically analyzable in packed consumers (#252) - #288
Conversation
…analyzable in packed consumers (#252)
🦋 Changeset detectedLatest commit: a8a4fc5 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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a8a4fc5c9d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| '', | ||
| 'process.exitCode = await runGeneratedInstallProcess(process.argv.slice(2), Object.freeze({', | ||
| ` artifactRelativeUrl: ${JSON.stringify(options.artifactRelativeUrl)},`, | ||
| ` artifactRoot: fileURLToPath(new URL(${JSON.stringify(options.artifactRelativeUrl)}, import.meta.url)),`, |
There was a problem hiding this comment.
Keep filesystem URL conversion inside the installer error boundary
When the project path contains a literal % (for example, /tmp/plugin%build), fileURLToPath throws URI malformed synchronously while constructing these options, before runGeneratedInstallProcess can handle --help or enter its diagnostic try block. This makes even <name>-install --help terminate with an unhandled stack trace; previously URL conversion happened after the help check and inside the try. Keep the literal new URL(...) in the generated wrapper for static analysis, but defer fileURLToPath until the runtime's guarded path (for example, by passing the URL itself or a resolver).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Summary
Follow-up fix to #281, caught while wiring #252's release lane: in a packed consumer (a plugin project whose
node_modulescarriesagent-bundleinstalled from the real tarball), anyagent-bundle buildwith a package build plus install-capable targets failed withAB5000: Bundler stats selected a module without an authored source path.install-entryruntime callednew URL(options.artifactRelativeUrl, import.meta.url)with a non-literal first argument. Rspack turns that into a directory ContextModule (…/agent-bundle/dist|sync) with nonameForCondition, and the provenance collector correctly fail-closes on it. Every feat(package): package-relative host installer bins and the agent-bundle prepack inventory gate (#252) #281/test(install): empty-dir packed-tarball host-install proofs for the package-relative installer (#252) #283 gate missed this because their fixtures resolve the runtime shell from the workspace tree; the failure only reproduces when the shell is bundled out of an installednode_modules/agent-bundle/dist, which the release-lane scaffolder matrix (cli-tool journey) does.fileURLToPath(new URL('<literal>', import.meta.url))itself and hands the absolute artifact root torunGeneratedInstallProcess. Statically analyzable for the bundler, identical package-relative behavior, and no weakening of the provenance collector's fail-closed posture.claude/codextargets through the installed framework and asserts the emitted executabledist/bin/<name>-install.js(fails with the exact AB5000 before this fix).Test plan
pnpm build,pnpm typecheck,pnpm lint— greenpnpm test:packed packages/agent-bundle/tests/packed-consumer.test.ts— 1 passed (failed with AB5000 pre-fix)pnpm exec rstest … prepack.test.ts installer-entry.test.ts package-build.test.ts— 24 passedpnpm test:packed:release …/scaffold-packed-matrix.e2e.test.ts— 2 passed (cli-tool journey'snpm run buildwas the original failure)