Skip to content

Commit

Permalink
fix(auth-providers): Move away from babel for building 'setup' packag…
Browse files Browse the repository at this point in the history
…es (#11303)

This switches from babel to esbuild for building the 'api' auth provider
packages. Continuing the work of #11301 but this time for the setup
packages.

I have not included the dbAuth package deliberately and will follow up
with a separate update to that package.

I had to make a small change to the `@redwoodjs/cli-helpers` package.
This was because tsc was not happy that I was statically importing from
a package marked `type: module` from a package marked as `type:
commonjs` because it would result in requiring an es module. It was not
understanding that the cli-helpers package was dual cjs/esm and that it
will be totally fine to either import or require from it. The solution
(it appears) is to be specific in the exports field of the package.json.
Those edits here made tsc happy to generate types and didn't throw the
error.

I didn't update the styling of the tsconfig when I changed the
cli-helpers package. We should refactor that standalone. I'm really not
at all thrilled about my recent changes which use the `moduleResolution:
node` because that isn't what we should be using but tsc errors out
based on your `module` and `moduleResolution` setting which has been a
pain. This for now is okay and we can revisit once we encounter the
issue of using two different module resolution algorithms depending on
cjs vs esm.
  • Loading branch information
Josh-Walker-GM authored Aug 18, 2024
1 parent 9fb2d6b commit 78b897a
Show file tree
Hide file tree
Showing 36 changed files with 414 additions and 122 deletions.
1 change: 0 additions & 1 deletion packages/auth-providers/auth0/setup/.babelrc.js

This file was deleted.

8 changes: 8 additions & 0 deletions packages/auth-providers/auth0/setup/build.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { build, copyAssets } from '@redwoodjs/framework-tools'

await build()

await copyAssets({
buildFileUrl: import.meta.url,
patterns: ['templates/**/*.template'],
})
33 changes: 25 additions & 8 deletions packages/auth-providers/auth0/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,47 @@
"directory": "packages/auth-providers/auth0/setup"
},
"license": "MIT",
"type": "commonjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./dist/setup": {
"types": "./dist/setup.d.ts",
"default": "./dist/setup.js"
},
"./dist/setupHandler": {
"types": "./dist/setupHandler.d.ts",
"default": "./dist/setupHandler.js"
}
},
"main": "./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.mts && yarn build:types",
"build:pack": "yarn pack -o redwoodjs-auth-auth0-setup.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose ./tsconfig.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn attw -P",
"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/cli-helpers": "workspace:*",
"core-js": "3.38.0"
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@arethetypeswrong/cli": "0.15.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
"publint": "0.2.10",
"tsx": "4.17.0",
"typescript": "5.5.4",
"vitest": "2.0.5"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/auth-providers/auth0/setup/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"compilerOptions": {
"strict": true,
"rootDir": "src",
"outDir": "dist"
"outDir": "dist",
"module": "Node16",
"moduleResolution": "Node16",
"tsBuildInfoFile": "./tsconfig.tsbuildinfo"
},
"include": ["src"],
"references": [{ "path": "../../../cli-helpers" }]
Expand Down

This file was deleted.

8 changes: 8 additions & 0 deletions packages/auth-providers/azureActiveDirectory/setup/build.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { build, copyAssets } from '@redwoodjs/framework-tools'

await build()

await copyAssets({
buildFileUrl: import.meta.url,
patterns: ['templates/**/*.template'],
})
33 changes: 25 additions & 8 deletions packages/auth-providers/azureActiveDirectory/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,47 @@
"directory": "packages/auth-providers/azureActiveDirectory/setup"
},
"license": "MIT",
"type": "commonjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./dist/setup": {
"types": "./dist/setup.d.ts",
"default": "./dist/setup.js"
},
"./dist/setupHandler": {
"types": "./dist/setupHandler.d.ts",
"default": "./dist/setupHandler.js"
}
},
"main": "./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.mts && yarn build:types",
"build:pack": "yarn pack -o redwoodjs-auth-azure-active-directory-setup.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose ./tsconfig.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn attw -P",
"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/cli-helpers": "workspace:*",
"core-js": "3.38.0"
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@arethetypeswrong/cli": "0.15.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
"publint": "0.2.10",
"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 @@ -3,7 +3,10 @@
"compilerOptions": {
"strict": true,
"rootDir": "src",
"outDir": "dist"
"outDir": "dist",
"module": "Node16",
"moduleResolution": "Node16",
"tsBuildInfoFile": "./tsconfig.tsbuildinfo"
},
"include": ["src"],
"references": [{ "path": "../../../cli-helpers" }]
Expand Down
1 change: 0 additions & 1 deletion packages/auth-providers/clerk/setup/.babelrc.js

This file was deleted.

8 changes: 8 additions & 0 deletions packages/auth-providers/clerk/setup/build.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { build, copyAssets } from '@redwoodjs/framework-tools'

await build()

await copyAssets({
buildFileUrl: import.meta.url,
patterns: ['templates/**/*.template'],
})
33 changes: 25 additions & 8 deletions packages/auth-providers/clerk/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,45 @@
"directory": "packages/auth-providers/clerk/setup"
},
"license": "MIT",
"type": "commonjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./dist/setup": {
"types": "./dist/setup.d.ts",
"default": "./dist/setup.js"
},
"./dist/setupHandler": {
"types": "./dist/setupHandler.d.ts",
"default": "./dist/setupHandler.js"
}
},
"main": "./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.mts && yarn build:types",
"build:pack": "yarn pack -o redwoodjs-auth-clerk-setup.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose ./tsconfig.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn attw -P",
"check:package": "concurrently npm:check:attw yarn:publint",
"prepublishOnly": "NODE_ENV=production yarn build"
},
"dependencies": {
"@babel/runtime-corejs3": "7.25.0",
"@redwoodjs/cli-helpers": "workspace:*",
"core-js": "3.38.0"
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@arethetypeswrong/cli": "0.15.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
"publint": "0.2.10",
"tsx": "4.17.0",
"typescript": "5.5.4"
},
"gitHead": "3905ed045508b861b495f8d5630d76c7a157d8f1"
Expand Down
5 changes: 4 additions & 1 deletion packages/auth-providers/clerk/setup/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"compilerOptions": {
"strict": true,
"rootDir": "src",
"outDir": "dist"
"outDir": "dist",
"module": "Node16",
"moduleResolution": "Node16",
"tsBuildInfoFile": "./tsconfig.tsbuildinfo"
},
"include": ["src"],
"references": [{ "path": "../../../cli-helpers" }]
Expand Down
1 change: 0 additions & 1 deletion packages/auth-providers/custom/setup/.babelrc.js

This file was deleted.

8 changes: 8 additions & 0 deletions packages/auth-providers/custom/setup/build.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { build, copyAssets } from '@redwoodjs/framework-tools'

await build()

await copyAssets({
buildFileUrl: import.meta.url,
patterns: ['templates/**/*.template'],
})
33 changes: 25 additions & 8 deletions packages/auth-providers/custom/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,47 @@
"directory": "packages/auth-providers/custom/setup"
},
"license": "MIT",
"type": "commonjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./dist/setup": {
"types": "./dist/setup.d.ts",
"default": "./dist/setup.js"
},
"./dist/setupHandler": {
"types": "./dist/setupHandler.d.ts",
"default": "./dist/setupHandler.js"
}
},
"main": "./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.mts && yarn build:types",
"build:pack": "yarn pack -o redwoodjs-auth-custom-setup.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose ./tsconfig.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn attw -P",
"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/cli-helpers": "workspace:*",
"core-js": "3.38.0"
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@arethetypeswrong/cli": "0.15.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
"publint": "0.2.10",
"tsx": "4.17.0",
"typescript": "5.5.4",
"vitest": "2.0.5"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/auth-providers/custom/setup/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"compilerOptions": {
"strict": true,
"rootDir": "src",
"outDir": "dist"
"outDir": "dist",
"module": "Node16",
"moduleResolution": "Node16",
"tsBuildInfoFile": "./tsconfig.tsbuildinfo"
},
"include": ["src"],
"references": [{ "path": "../../../cli-helpers" }]
Expand Down
1 change: 0 additions & 1 deletion packages/auth-providers/firebase/setup/.babelrc.js

This file was deleted.

8 changes: 8 additions & 0 deletions packages/auth-providers/firebase/setup/build.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { build, copyAssets } from '@redwoodjs/framework-tools'

await build()

await copyAssets({
buildFileUrl: import.meta.url,
patterns: ['templates/**/*.template'],
})
33 changes: 25 additions & 8 deletions packages/auth-providers/firebase/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,47 @@
"directory": "packages/auth-providers/firebase/setup"
},
"license": "MIT",
"type": "commonjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./dist/setup": {
"types": "./dist/setup.d.ts",
"default": "./dist/setup.js"
},
"./dist/setupHandler": {
"types": "./dist/setupHandler.d.ts",
"default": "./dist/setupHandler.js"
}
},
"main": "./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.mts && yarn build:types",
"build:pack": "yarn pack -o redwoodjs-auth-firebase-setup.tgz",
"build:types": "tsc --build --verbose",
"build:types": "tsc --build --verbose ./tsconfig.json",
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
"check:attw": "yarn attw -P",
"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/cli-helpers": "workspace:*",
"core-js": "3.38.0"
"@redwoodjs/cli-helpers": "workspace:*"
},
"devDependencies": {
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@arethetypeswrong/cli": "0.15.4",
"@redwoodjs/framework-tools": "workspace:*",
"@types/yargs": "17.0.33",
"concurrently": "8.2.2",
"publint": "0.2.10",
"tsx": "4.17.0",
"typescript": "5.5.4",
"vitest": "2.0.5"
},
Expand Down
5 changes: 4 additions & 1 deletion packages/auth-providers/firebase/setup/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"compilerOptions": {
"strict": true,
"rootDir": "src",
"outDir": "dist"
"outDir": "dist",
"module": "Node16",
"moduleResolution": "Node16",
"tsBuildInfoFile": "./tsconfig.tsbuildinfo"
},
"include": ["src"],
"references": [{ "path": "../../../cli-helpers" }]
Expand Down
1 change: 0 additions & 1 deletion packages/auth-providers/netlify/setup/.babelrc.js

This file was deleted.

Loading

0 comments on commit 78b897a

Please sign in to comment.