-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(auth): Convert
@redwoodjs/auth
to ESM+CJS dual build (#10417)
Co-authored-by: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com>
- Loading branch information
1 parent
bb7ad2d
commit a2a00cf
Showing
25 changed files
with
134 additions
and
68 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 was deleted.
Oops, something went wrong.
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,36 @@ | ||
import { renameSync, writeFileSync } from 'node:fs' | ||
|
||
import { build, defaultBuildOptions } from '@redwoodjs/framework-tools' | ||
|
||
// ESM build | ||
await build({ | ||
buildOptions: { | ||
...defaultBuildOptions, | ||
tsconfig: 'tsconfig.build-esm.json', | ||
format: 'esm', | ||
outdir: 'dist/esm', | ||
packages: 'external', | ||
}, | ||
}) | ||
|
||
// CJS build | ||
await build({ | ||
buildOptions: { | ||
...defaultBuildOptions, | ||
tsconfig: 'tsconfig.build.json', | ||
packages: 'external', | ||
}, | ||
}) | ||
|
||
// Because the package.json files has `type: module` the CJS entry file can't | ||
// be named `index.js` because in that case it would be treated as an ESM file. | ||
// By changing it to .cjs it will be treated as a CommonJS file. | ||
renameSync('dist/index.js', 'dist/index.cjs') | ||
|
||
// Place a package.json file with `type: commonjs` in the dist folder so that | ||
// all .js files are treated as CommonJS files. | ||
writeFileSync('dist/package.json', JSON.stringify({ type: 'commonjs' })) | ||
|
||
// Place a package.json file with `type: module` in the dist/esm folder so that | ||
// all .js files are treated as ES Module files. | ||
writeFileSync('dist/esm/package.json', JSON.stringify({ type: 'module' })) |
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
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
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
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
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
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,5 @@ | ||
export { AuthContextInterface, CurrentUser } from './AuthContext' | ||
export { useNoAuth, UseAuth } from './useAuth' | ||
export { createAuthentication } from './authFactory' | ||
export type { AuthImplementation } from './AuthImplementation' | ||
export type { AuthContextInterface, CurrentUser } from './AuthContext.js' | ||
export { useNoAuth } from './useAuth.js' | ||
export type { UseAuth } from './useAuth.js' | ||
export { createAuthentication } from './authFactory.js' | ||
export type { AuthImplementation } from './AuthImplementation.js' |
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,14 @@ | ||
{ | ||
"extends": "../../tsconfig.compilerOption.json", | ||
"compilerOptions": { | ||
"isolatedModules": true, | ||
"moduleResolution": "NodeNext", | ||
"module": "NodeNext", | ||
"rootDir": "src", | ||
"outDir": "dist/esm", | ||
}, | ||
"include": ["src", "ambient.d.ts"], | ||
"references": [ | ||
{ "path": "../framework-tools" } | ||
] | ||
} |
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,8 +1,14 @@ | ||
{ | ||
"extends": "../../tsconfig.compilerOption.json", | ||
"compilerOptions": { | ||
"isolatedModules": true, | ||
"moduleResolution": "NodeNext", | ||
"module": "NodeNext", | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
}, | ||
"include": ["src", "ambient.d.ts"], | ||
"references": [ | ||
{ "path": "../framework-tools" } | ||
] | ||
} |
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
Oops, something went wrong.