Skip to content

Commit

Permalink
refactor(auth-providers): switch to esbuild for some 'web' packages (#…
Browse files Browse the repository at this point in the history
…11334)

Continues switching over packages to use esbuild rather than babel. 

What this PR does:
1. Updates to auth-provider web packages to use esbuild over babel
2. Updates the tsconfig files to match the way we're doing things
3. Updates the imports with relative paths to have extensions.

What this PR doesn't do but that will be followed up on:
1. The dbAuth web and firebase web packages aren't included here because
they still use jest.
2. Switch the build related tsconfigs to use the modern module and
module resolution settings. If you do so it will not build do a type
inference issue which I am choosing not to deal with here.
  • Loading branch information
Josh-Walker-GM committed Aug 21, 2024
1 parent a9eaf54 commit 78f01a2
Show file tree
Hide file tree
Showing 50 changed files with 531 additions and 124 deletions.
1 change: 0 additions & 1 deletion packages/auth-providers/auth0/web/.babelrc.js

This file was deleted.

17 changes: 17 additions & 0 deletions packages/auth-providers/auth0/web/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { buildCjs, buildEsm } from '@redwoodjs/framework-tools'
import {
generateTypesCjs,
generateTypesEsm,
insertCommonJsPackageJson,
} from '@redwoodjs/framework-tools/generateTypes'

// ESM build and type generation
await buildEsm()
await generateTypesEsm()

// CJS build, type generation, and package.json insert
await buildCjs()
await generateTypesCjs()
await insertCommonJsPackageJson({
buildFileUrl: import.meta.url,
})
44 changes: 35 additions & 9 deletions packages/auth-providers/auth0/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,58 @@
"directory": "packages/auth-providers/auth0/web"
},
"license": "MIT",
"main": "./dist/index.js",
"type": "module",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"default": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
},
"./dist/auth0": {
"import": {
"types": "./dist/auth0.d.ts",
"default": "./dist/auth0.js"
},
"default": {
"types": "./dist/cjs/auth0.d.ts",
"default": "./dist/cjs/auth0.js"
}
}
},
"main": "./dist/cjs/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "yarn build:js && yarn build:types",
"build:js": "babel src -d dist --extensions \".js,.jsx,.ts,.tsx\" --copy-files --no-copy-ignored",
"build": "tsx ./build.ts",
"build:pack": "yarn pack -o redwoodjs-auth-auth0-web.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose ./tsconfig.build.json",
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn rw-fwtools-attw",
"check:package": "concurrently npm:check:attw yarn:publint",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "vitest run",
"test:watch": "vitest watch"
},
"dependencies": {
"@babel/runtime-corejs3": "7.25.0",
"@redwoodjs/auth": "workspace:*",
"core-js": "3.38.0"
"@redwoodjs/auth": "workspace:*"
},
"devDependencies": {
"@auth0/auth0-spa-js": "2.1.3",
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@redwoodjs/framework-tools": "workspace:*",
"@types/react": "^18.2.55",
"concurrently": "8.2.2",
"publint": "0.2.10",
"react": "19.0.0-rc-8269d55d-20240802",
"tsx": "4.17.0",
"typescript": "5.5.4",
"vitest": "2.0.5"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { vi, beforeAll, beforeEach, describe, expect, it } from 'vitest'

import type { CurrentUser } from '@redwoodjs/auth'

import { createAuth } from '../auth0'
import { createAuth } from '../auth0.js'

const user: User = {
sub: 'unique_user_id',
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/auth0/web/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { createAuth } from './auth0'
export { createAuth } from './auth0.js'
15 changes: 15 additions & 0 deletions packages/auth-providers/auth0/web/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../../../tsconfig.compilerOption.json",
"compilerOptions": {
"strict": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "./tsconfig.build.tsbuildinfo"
},
"include": ["src"],
"references": [
{
"path": "./../../../auth/tsconfig.build.json"
}
]
}
7 changes: 7 additions & 0 deletions packages/auth-providers/auth0/web/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"outDir": "dist/cjs",
"tsBuildInfoFile": "./tsconfig.cjs.tsbuildinfo"
}
}
12 changes: 8 additions & 4 deletions packages/auth-providers/auth0/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"extends": "../../../../tsconfig.compilerOption.json",
"compilerOptions": {
"strict": true,
"rootDir": "src",
"outDir": "dist"
"module": "Node16",
"moduleResolution": "Node16"
},
"include": ["src"],
"references": [{ "path": "../../../auth/tsconfig.build.json" }]
"include": ["."],
"references": [
{ "path": "../../../auth/tsconfig.build.json" },
{ "path": "../../../framework-tools" }
],
"exclude": ["dist", "node_modules", "**/__mocks__", "**/__tests__/fixtures"]
}

This file was deleted.

17 changes: 17 additions & 0 deletions packages/auth-providers/azureActiveDirectory/web/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { buildCjs, buildEsm } from '@redwoodjs/framework-tools'
import {
generateTypesCjs,
generateTypesEsm,
insertCommonJsPackageJson,
} from '@redwoodjs/framework-tools/generateTypes'

// ESM build and type generation
await buildEsm()
await generateTypesEsm()

// CJS build, type generation, and package.json insert
await buildCjs()
await generateTypesCjs()
await insertCommonJsPackageJson({
buildFileUrl: import.meta.url,
})
44 changes: 35 additions & 9 deletions packages/auth-providers/azureActiveDirectory/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,59 @@
"directory": "packages/auth-providers/azureActiveDirectory/web"
},
"license": "MIT",
"main": "./dist/index.js",
"type": "module",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"default": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
},
"./dist/azureActiveDirectory": {
"import": {
"types": "./dist/azureActiveDirectory.d.ts",
"default": "./dist/azureActiveDirectory.js"
},
"default": {
"types": "./dist/cjs/azureActiveDirectory.d.ts",
"default": "./dist/cjs/azureActiveDirectory.js"
}
}
},
"main": "./dist/cjs/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "yarn build:js && yarn build:types",
"build:js": "babel src -d dist --extensions \".js,.jsx,.ts,.tsx\" --copy-files --no-copy-ignored",
"build": "tsx ./build.ts",
"build:pack": "yarn pack -o redwoodjs-auth-azure-active-directory-web.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose ./tsconfig.build.json",
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn rw-fwtools-attw",
"check:package": "concurrently npm:check:attw yarn:publint",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "vitest run",
"test:watch": "vitest watch"
},
"dependencies": {
"@babel/runtime-corejs3": "7.25.0",
"@redwoodjs/auth": "workspace:*",
"core-js": "3.38.0"
"@redwoodjs/auth": "workspace:*"
},
"devDependencies": {
"@azure/msal-browser": "2.39.0",
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@redwoodjs/framework-tools": "workspace:*",
"@types/netlify-identity-widget": "1.9.6",
"@types/react": "^18.2.55",
"concurrently": "8.2.2",
"publint": "0.2.10",
"react": "19.0.0-rc-8269d55d-20240802",
"tsx": "4.17.0",
"typescript": "5.5.4",
"vitest": "2.0.5"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { vi, it, expect, describe, beforeAll, beforeEach } from 'vitest'

import type { CurrentUser } from '@redwoodjs/auth'

import { createAuth } from '../azureActiveDirectory'
import { createAuth } from '../azureActiveDirectory.js'

const user: AccountInfo = {
name: 'John',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { createAuth } from './azureActiveDirectory'
export { createAuth } from './azureActiveDirectory.js'
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../../../../tsconfig.compilerOption.json",
"compilerOptions": {
"strict": true,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "./tsconfig.build.tsbuildinfo"
},
"include": ["src"],
"references": [
{
"path": "./../../../auth/tsconfig.build.json"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.build.json",
"compilerOptions": {
"outDir": "dist/cjs",
"tsBuildInfoFile": "./tsconfig.cjs.tsbuildinfo"
}
}
11 changes: 7 additions & 4 deletions packages/auth-providers/azureActiveDirectory/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
"extends": "../../../../tsconfig.compilerOption.json",
"compilerOptions": {
"strict": true,
"rootDir": "src",
"outDir": "dist"
"module": "Node16",
"moduleResolution": "Node16"
},
"include": ["src"],
"references": [{ "path": "../../../auth/tsconfig.build.json" }]
"include": ["."],
"references": [
{ "path": "../../../auth/tsconfig.build.json" },
{ "path": "../../../framework-tools" }
]
}
1 change: 0 additions & 1 deletion packages/auth-providers/clerk/web/.babelrc.js

This file was deleted.

17 changes: 17 additions & 0 deletions packages/auth-providers/clerk/web/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { buildCjs, buildEsm } from '@redwoodjs/framework-tools'
import {
generateTypesCjs,
generateTypesEsm,
insertCommonJsPackageJson,
} from '@redwoodjs/framework-tools/generateTypes'

// ESM build and type generation
await buildEsm()
await generateTypesEsm()

// CJS build, type generation, and package.json insert
await buildCjs()
await generateTypesCjs()
await insertCommonJsPackageJson({
buildFileUrl: import.meta.url,
})
44 changes: 35 additions & 9 deletions packages/auth-providers/clerk/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,59 @@
"directory": "packages/auth-providers/clerk/web"
},
"license": "MIT",
"main": "./dist/index.js",
"type": "module",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"default": {
"types": "./dist/cjs/index.d.ts",
"default": "./dist/cjs/index.js"
}
},
"./dist/clerk": {
"import": {
"types": "./dist/clerk.d.ts",
"default": "./dist/clerk.js"
},
"default": {
"types": "./dist/cjs/clerk.d.ts",
"default": "./dist/cjs/clerk.js"
}
}
},
"main": "./dist/cjs/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "yarn build:js && yarn build:types",
"build:js": "babel src -d dist --extensions \".js,.jsx,.ts,.tsx\" --copy-files --no-copy-ignored",
"build": "tsx ./build.ts",
"build:pack": "yarn pack -o redwoodjs-auth-clerk-web.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose ./tsconfig.build.json",
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn rw-fwtools-attw",
"check:package": "concurrently npm:check:attw yarn:publint",
"prepublishOnly": "NODE_ENV=production yarn build",
"test": "vitest run",
"test:watch": "vitest watch"
},
"dependencies": {
"@babel/runtime-corejs3": "7.25.0",
"@redwoodjs/auth": "workspace:*",
"core-js": "3.38.0"
"@redwoodjs/auth": "workspace:*"
},
"devDependencies": {
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@clerk/clerk-react": "4.32.3",
"@clerk/types": "3.65.3",
"@redwoodjs/framework-tools": "workspace:*",
"@types/react": "^18.2.55",
"concurrently": "8.2.2",
"publint": "0.2.10",
"react": "19.0.0-rc-8269d55d-20240802",
"tsx": "4.17.0",
"typescript": "5.5.4",
"vitest": "2.0.5"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { vi, expect, describe, it, beforeAll, beforeEach } from 'vitest'

import type { CurrentUser } from '@redwoodjs/auth'

import { createAuth } from '../clerk'
import { createAuth } from '../clerk.js'

const user: Partial<UserResource> = {
id: 'unique_user_id',
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/clerk/web/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { createAuth } from './clerk'
export { createAuth } from './clerk.js'
Loading

0 comments on commit 78f01a2

Please sign in to comment.