-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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, with CJS interop (#7
… (#7262) * build(esm): Use explicit .mjs extension for ESM, with CJS interop (#7261) * 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 #7244 Refs #7095 Refs #7088 Refs react-hook-form/resolvers#271 Refs vercel/next.js#30750 * fix(esm-interop): Import non-ESM React as default * 7.21.3-beta.0 * update with v2 compress * fix lint error and update packages Co-authored-by: Daniel Stockman <5605+evocateur@users.noreply.github.com>
- Loading branch information
1 parent
f8aa875
commit 892aa0d
Showing
55 changed files
with
434 additions
and
408 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
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,13 @@ | ||
[ | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* This file, when executed in the postbuild lifecycle, ensures that | ||
* the CJS output is valid CJS according to the package.json spec. | ||
* | ||
* @see https://nodejs.org/docs/latest/api/packages.html#packages_determining_module_system | ||
*/ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const exported = require('react-hook-form'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
|
||
/** | ||
* When this fails, fine the update one-liner in ./assert-esm-exports.mjs | ||
*/ | ||
const expected = JSON.parse( | ||
fs.readFileSync( | ||
require('path').resolve(__dirname, './all-exports.json'), | ||
'utf-8', | ||
), | ||
); | ||
|
||
assert.deepStrictEqual(Object.keys(exported), expected); |
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,22 @@ | ||
/** | ||
* 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'; | ||
import fs from 'fs'; | ||
|
||
/** | ||
* A shell one-liner to update this array when neccessary (run from root of repo): | ||
* node -e "import('react-hook-form').then((mod) => console.log(JSON.stringify(Object.keys(mod), null, 2)))" > scripts/rollup/all-exports.json | ||
*/ | ||
const expected = JSON.parse( | ||
fs.readFileSync( | ||
new URL('./all-exports.json', import.meta.url).pathname, | ||
'utf-8', | ||
), | ||
); | ||
|
||
assert.deepStrictEqual(Object.keys(exported), expected); |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act, | ||
fireEvent, | ||
|
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
|
||
import { Controller } from '../controller'; | ||
import { | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act, | ||
fireEvent, | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act as actComponent, | ||
fireEvent, | ||
|
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act as actComponent, | ||
fireEvent, | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act as actComponent, | ||
fireEvent, | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act as actComponent, | ||
fireEvent, | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act as actComponent, | ||
fireEvent, | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act as actComponent, | ||
fireEvent, | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act as actComponent, | ||
fireEvent, | ||
|
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act as actComponent, | ||
fireEvent, | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as React from 'react'; | ||
import React from 'react'; | ||
import { | ||
act as actComponent, | ||
fireEvent, | ||
|
Oops, something went wrong.