Skip to content

Commit

Permalink
chore(auth-providers): switch firebase web to esbuild (#11467)
Browse files Browse the repository at this point in the history
Switches from babel to esbuild for building the src to dist. Follows the
same pattern we have currently for the rest of them - not perfect but
moving in the right direction.
  • Loading branch information
Josh-Walker-GM authored Sep 8, 2024
1 parent 29dd25a commit 68d1596
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 21 deletions.
1 change: 0 additions & 1 deletion packages/auth-providers/firebase/web/.babelrc.js

This file was deleted.

17 changes: 17 additions & 0 deletions packages/auth-providers/firebase/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/firebase/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,58 @@
"directory": "packages/auth-providers/firebase/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/firebase": {
"import": {
"types": "./dist/firebase.d.ts",
"default": "./dist/firebase.js"
},
"default": {
"types": "./dist/cjs/firebase.d.ts",
"default": "./dist/cjs/firebase.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-firebase-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",
"@redwoodjs/framework-tools": "workspace:*",
"@types/react": "^18.2.55",
"concurrently": "8.2.2",
"firebase": "10.13.1",
"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 @@ -6,8 +6,8 @@ import { vi, beforeAll, beforeEach, describe, it, expect } from 'vitest'

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

import type { FirebaseClient } from '../firebase'
import { createAuth } from '../firebase'
import type { FirebaseClient } from '../firebase.js'
import { createAuth } from '../firebase.js'

const user: User = {
uid: 'unique_user_id',
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/firebase/web/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { createAuth } from './firebase'
export { createAuth } from './firebase.js'
15 changes: 15 additions & 0 deletions packages/auth-providers/firebase/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/firebase/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/firebase/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"]
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7602,14 +7602,14 @@ __metadata:
version: 0.0.0-use.local
resolution: "@redwoodjs/auth-firebase-web@workspace:packages/auth-providers/firebase/web"
dependencies:
"@babel/cli": "npm:7.24.8"
"@babel/core": "npm:^7.22.20"
"@babel/runtime-corejs3": "npm:7.25.0"
"@redwoodjs/auth": "workspace:*"
"@redwoodjs/framework-tools": "workspace:*"
"@types/react": "npm:^18.2.55"
core-js: "npm:3.38.0"
concurrently: "npm:8.2.2"
firebase: "npm:10.13.1"
publint: "npm:0.2.10"
react: "npm:19.0.0-rc-8269d55d-20240802"
tsx: "npm:4.17.0"
typescript: "npm:5.5.4"
vitest: "npm:2.0.5"
peerDependencies:
Expand Down

0 comments on commit 68d1596

Please sign in to comment.