marmelab / marmelab/react-admin
Add exports entry point to support node's module resolution.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 26.9k
- Forks
- 5.5k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 19
Description
React admin provides cjs and esm bundles. However, it relies on `main` and `module` in the package.json file to decide which version to use. It will work with most bundlers but fails when using node's module resolution as it doesn't support the `module` field. I was hit with this problem when trying to test a component using vitest.
Example:
```js
function ComponentA() {
return
}
function ComponentB() {
const { watch } = useFormContext()
return ...
}
```
SimpleForm is loaded using cjs and uses FormProvider (cjs) from react-hook-form.
ComponentB uses useFormContext from react-hook-form esm bundle and context will be null.
**Describe the solution you'd like**
Add `exports` to package.json specifying the entry points for `import` and `require`.
**Additional context**
https://github.com/vitest-dev/vitest/discussions/4233
https://nodejs.org/api/packages.html#package-entry-points
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the package.json entry points and the existing CJS and ESM bundles. Review Node's package entry-points guidance and reproduce the Vitest module-resolution case described in the issue. Done means import and require resolve the intended bundles without loading separate react-hook-form contexts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, react, typescript
- Domain
- build-system, developer-experience
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100