feat: expose @microsoft/webui/platform subpath#298
Merged
mohamedmansour merged 1 commit intoMay 16, 2026
Conversation
mohamedmansour
requested changes
May 16, 2026
49c1c7e to
f6e2235
Compare
Add a `./platform.js` entry to the package's `exports` map so adopters
can import the platform helpers (`platformKey`, `packageName`,
`resolve`) without reaching into `dist/` directly.
The file `packages/webui/src/platform.ts` already exports a small,
useful API:
- `platformKey()` - `${process.platform}-${process.arch}` string
used for diagnostics and native addon selection.
- `packageName()` - the matching `@microsoft/webui-<platform>` npm
package name, useful for "is the right native addon installed?"
preflight checks in adopter environments.
- `resolve(kind: 'bin' | 'addon')` - resolves the platform-specific
binary path so adopters can spawn the CLI from their own scripts.
These are all real, useful exports already shipped to disk via the
package's `files: ["dist/"]` entry. The `exports` map just doesn't
surface them.
The subpath includes the `.js` extension to stay ESM-compliant and
match the convention used by the rest of the package's resolved
paths.
f6e2235 to
0c65356
Compare
mohamedmansour
approved these changes
May 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add a
./platform.jsentry to theexportsmap inpackages/webui/package.jsonso adopters can write:The
.jsextension on the subpath stays ESM-compliant and matches the rest of the package's resolved paths.Why
I'm integrating WebUI into a non-WebUI Node host. The integration needs to:
@microsoft/webui-darwin-arm64.platformKey()andpackageName()give the exact strings to put in that error.resolve('bin')returns the right binary path; without the subpath export the only options arenpx webui(slow startup) or reaching intonode_modules/@microsoft/webui/dist/platform.jsdirectly (fragile).packages/webui/src/platform.tsalready exports all three functions, anddist/platform.js/dist/platform.d.tsare already shipped viafiles: ["dist/"]. The only thing missing is theexportsmap entry, which under Node's strict ESM resolution makes them unreachable.This PR adds 6 lines to
package.json. No code change, no behavior change for existing imports.How I tested
The new entry mirrors the existing
.entry exactly:typespoints to./dist/platform.d.ts(already produced bytscsincesrc/platform.tsis a sibling ofsrc/index.ts).defaultpoints to./dist/platform.js.Both files exist after
npm run buildbecauseindex.tsalready imports from./platform.js.Notes
users/janechu/add-platform-exports-to-main-exportper my host repo's agent-driven branch convention.platform.tsintentionally private (i.e., reserved for internal-only use), or just an oversight in the exports map? If the former, please close this and I'll switch my integration to re-implementingplatformKey()locally.