chore(third-party-dts-extractor): replace resolve with exsolve#4775
chore(third-party-dts-extractor): replace resolve with exsolve#4775gu-stav wants to merge 2 commits into
resolve with exsolve#4775Conversation
The single `resolve.sync()` call (a `${pkg}/package.json` lookup) is
swapped for `exsolve`'s `resolveModulePath`. `exsolve` ships with zero
transitive dependencies and weighs ~100KB less than `resolve`'s
161KB + 6 transitives.
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🦋 Changeset detectedLatest commit: ab8784b The changes in this PR will be included in the next version bump. This PR includes changesets to release 46 packages
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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8ba2b6ec7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| import { existsSync, readFileSync } from 'fs'; | ||
| import path from 'path'; | ||
| import resolve from 'resolve'; | ||
| import { resolveModulePath } from 'exsolve'; |
There was a problem hiding this comment.
Keep CJS build from requiring ESM-only exsolve
When this package is loaded through its existing require export, tsup leaves dependencies external by default, so the generated CJS file will require exsolve at module load time. exsolve@1.0.8 is ESM-only (type: module with only a .mjs export), so CommonJS consumers will hit ERR_REQUIRE_ESM before ThirdPartyExtractor can run; either keep a CJS-compatible resolver or explicitly bundle/noExternal exsolve for the CJS build.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Added a follow-up commit to address the issue 👍🏼
`exsolve@1.0.8` is ESM-only (`type: module`, single `.mjs` export). Left external by tsup's default, CJS consumers (including `@module-federation/dts-plugin`'s own CJS build, which is what `@module-federation/vite` actually loads) hit `ERR_REQUIRE_ESM` on module load before `ThirdPartyExtractor` can run. Split tsup config so the CJS build sets `noExternal: ['exsolve']` while the ESM build keeps it as a runtime dep. CJS dist grows ~41KB; ESM is unchanged.
The single
resolve.sync()call (a${pkg}/package.jsonlookup) is swapped forexsolve'sresolveModulePath.exsolveships with zero transitive dependencies and weighs ~100KB less thanresolve's 161KB + 6 transitives (path-parse,is-core-module,function-bind,hasown,supports-preserve-symlinks-flag,es-define-property). The package is already in the lockfile as a transitive ofpkg-types, so the install footprint goes down without adding a new top-level entry.