forked from react-hook-form/react-hook-form
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(esm): Use explicit .mjs extension for ESM
This ensures that Node always treats the ESM output as ESM, despite the package.json (implicit) type of commonjs. Bundlers that expect ESM, such as Next v12, no longer explode when encountering this module. Refs react-hook-form#7095 Refs react-hook-form#7088 Refs react-hook-form/resolvers#271 Refs vercel/next.js#30750
- Loading branch information
Showing
3 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* This file, when executed in the postbuild lifecycle, ensures that | ||
* the ESM output is valid ESM according to the package.json spec. | ||
* | ||
* @see https://nodejs.org/docs/latest/api/packages.html#packages_determining_module_system | ||
*/ | ||
import * as exported from 'react-hook-form'; | ||
import assert from 'assert'; | ||
|
||
/** | ||
* A shell one-liner to update this array when neccessary: | ||
* | ||
* node -e "import('react-hook-form').then((mod) => console.dir(Object.keys(mod)))" | ||
*/ | ||
assert.deepStrictEqual(Object.keys(exported), [ | ||
'Controller', | ||
'FormProvider', | ||
'appendErrors', | ||
'get', | ||
'set', | ||
'useController', | ||
'useFieldArray', | ||
'useForm', | ||
'useFormContext', | ||
'useFormState', | ||
'useWatch', | ||
]); |
This file contains 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