Skip to content

Commit

Permalink
Merge branch 'feat/rw-uploads' of github.com:dac09/redwood into feat/…
Browse files Browse the repository at this point in the history
…rw-uploads

* 'feat/rw-uploads' of github.com:dac09/redwood:
  chore(tsconfig.build): Fix type checking for tests etc (redwoodjs#11167)
  chore(config): migrate renovate config (redwoodjs#11157)
  fix(deps): update prisma monorepo to v5.18.0 (redwoodjs#11165)
  chore(fixture): Rebuild test project fixture (redwoodjs#11166)
  chore(ci): Print full diff when check-test-project-fixture fails (redwoodjs#11164)
  chore(rwjs/vite): Rename build script and format source (redwoodjs#11163)
  chore(tsconfig): Format vite tsconfig (redwoodjs#11162)
  RSC: RSA: Better match error handling with how we generally do it in RW (redwoodjs#11161)
  RSC: RSA: Add more comments to the basic 'use server' check (redwoodjs#11160)
  RSC: RSA: Remove unused check for '$$id' (redwoodjs#11159)
  RSC: Fix red squiggles in transform client tests (redwoodjs#11156)
  RSC: Improve type safety in RSC transform plugins (redwoodjs#11155)
  • Loading branch information
dac09 committed Aug 7, 2024
2 parents a7d06f4 + 75bb556 commit 58c3530
Show file tree
Hide file tree
Showing 25 changed files with 318 additions and 332 deletions.
26 changes: 5 additions & 21 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"configMigration": true,

"extends": [
"config:recommended"
],

"postUpdateOptions": [
"yarnDedupeHighest"
],
"extends": ["config:recommended"],
"postUpdateOptions": ["yarnDedupeHighest"],
"prConcurrentLimit": 3,
"rebaseWhen": "conflicted",

"packageRules": [
{
"matchUpdateTypes": [
"minor",
"patch"
],
"matchUpdateTypes": ["minor", "patch"],
"automerge": true
},

{
"groupName": "ESM and @redwoodjs packages",
"enabled": false,

"matchPackageNames": [
"boxen",
"chalk",
Expand All @@ -41,16 +29,12 @@
"tempy",
"terminal-link",
"title-case",
"untildify"
],
"matchPackagePatterns": [
"^@redwoodjs/"
"untildify",
"/^@redwoodjs//"
]
},

{
"groupName": "chore",

"matchPackageNames": [
"all-contributors-cli",
"cypress",
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/check-test-project-fixture.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ jobs:
echo 'Untracked files:'
git status --porcelain | grep '^?? ' | awk '{print " " $2}'
echo
echo
echo 'Full diff:'
git diff
exit 1;
fi
Expand Down
2 changes: 1 addition & 1 deletion __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.40",
"postcss": "^8.4.41",
"postcss-loader": "^8.1.1",
"prettier-plugin-tailwindcss": "^0.5.12",
"tailwindcss": "^3.4.7"
Expand Down
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.24.8",
"@prisma/client": "5.17.0",
"@prisma/client": "5.18.0",
"@whatwg-node/fetch": "0.9.19",
"cookie": "0.6.0",
"core-js": "3.37.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/middleware/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"include": ["src/**/*"],
"references": [
{ "path": "../../../auth/tsconfig.build.json" },
{ "path": "../../../vite" }
{ "path": "../../../vite/tsconfig.build.json" }
]
}
2 changes: 1 addition & 1 deletion packages/auth-providers/dbAuth/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.24.8",
"@prisma/internals": "5.17.0",
"@prisma/internals": "5.18.0",
"@redwoodjs/cli-helpers": "workspace:*",
"@simplewebauthn/browser": "7.4.0",
"core-js": "3.37.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-providers/supabase/middleware/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"include": ["src/**/*"],
"references": [
{ "path": "../../../auth/tsconfig.build.json" },
{ "path": "../../../vite" }
{ "path": "../../../vite/tsconfig.build.json" }
]
}
2 changes: 1 addition & 1 deletion packages/cli-packages/dataMigrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"yargs": "17.7.2"
},
"devDependencies": {
"@prisma/client": "5.17.0",
"@prisma/client": "5.18.0",
"@redwoodjs/framework-tools": "workspace:*",
"@types/fs-extra": "11.0.4",
"@types/yargs": "17.0.32",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@opentelemetry/resources": "1.22.0",
"@opentelemetry/sdk-trace-node": "1.22.0",
"@opentelemetry/semantic-conventions": "1.22.0",
"@prisma/internals": "5.17.0",
"@prisma/internals": "5.18.0",
"@redwoodjs/api-server": "workspace:*",
"@redwoodjs/cli-helpers": "workspace:*",
"@redwoodjs/fastify-web": "workspace:*",
Expand Down Expand Up @@ -70,7 +70,7 @@
"pluralize": "8.0.0",
"portfinder": "1.0.32",
"prettier": "3.3.3",
"prisma": "5.17.0",
"prisma": "5.18.0",
"prompts": "2.4.2",
"rimraf": "6.0.1",
"semver": "7.6.3",
Expand Down
20 changes: 5 additions & 15 deletions packages/ogimage-gen/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,11 @@
"rootDir": "src",
"outDir": "dist"
},
"include": [
"src"
],
"include": ["src"],
"references": [
{
"path": "../project-config"
},
{
"path": "../vite"
},
{
"path": "../router/tsconfig.build.json"
},
{
"path": "../internal"
}
{ "path": "../project-config" },
{ "path": "../vite/tsconfig.build.json" },
{ "path": "../router/tsconfig.build.json" },
{ "path": "../internal" }
]
}
4 changes: 2 additions & 2 deletions packages/record/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.24.8",
"@prisma/client": "5.17.0",
"@prisma/client": "5.18.0",
"@redwoodjs/project-config": "workspace:*",
"core-js": "3.37.1"
},
"devDependencies": {
"@babel/cli": "7.24.8",
"@babel/core": "^7.22.20",
"@prisma/internals": "5.17.0",
"@prisma/internals": "5.18.0",
"esbuild": "0.23.0",
"vitest": "2.0.4"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/structure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"@babel/runtime-corejs3": "7.24.8",
"@prisma/internals": "5.17.0",
"@prisma/internals": "5.18.0",
"@redwoodjs/project-config": "workspace:*",
"@types/line-column": "1.0.2",
"camelcase": "6.3.0",
Expand Down
50 changes: 34 additions & 16 deletions packages/vite/build.mts → packages/vite/build.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import { writeFileSync } from 'node:fs'

import { commonjs } from '@hyrious/esbuild-plugin-commonjs'
import * as esbuild from 'esbuild'

import {
build,
defaultBuildOptions,
defaultIgnorePatterns,
} from '@redwoodjs/framework-tools'

import { writeFileSync } from 'node:fs'
import { commonjs } from '@hyrious/esbuild-plugin-commonjs'

import * as esbuild from 'esbuild'

// CJS Build
await build({
entryPointOptions: {
ignore: [...defaultIgnorePatterns, '**/bundled'],
},
buildOptions: {
...defaultBuildOptions,
tsconfig: 'tsconfig.build.json',
outdir: 'dist/cjs',
packages: 'external',
},
Expand All @@ -28,6 +29,7 @@ await build({
},
buildOptions: {
...defaultBuildOptions,
tsconfig: 'tsconfig.build.json',
format: 'esm',
packages: 'external',
},
Expand All @@ -43,28 +45,44 @@ await esbuild.build({
conditions: ['react-server'],
platform: 'node',
target: ['node20'],
// ⭐ Without this plugin, we get "Error: Dynamic require of "util" is not supported"
// when trying to run the built files. This plugin will
// "just rewrite that file to replace "require(node-module)" to a toplevel static import statement." (see issue)
// Without this plugin, we get "Error: Dynamic require of "util" is not
// supported" when trying to run the built files. This plugin will "just
// rewrite that file to replace "require(node-module)" to a toplevel static
// import statement." (see issue)
// https://github.com/evanw/esbuild/issues/2113
// https://github.com/evanw/esbuild/pull/2067
plugins: [commonjs()],
logLevel: 'info',
tsconfig: 'tsconfig.build.json',
})

// Place a package.json file with `type: commonjs` in the dist/cjs folder so that
// all .js files are treated as CommonJS files.
// Place a package.json file with `type: commonjs` in the dist/cjs folder so
// that all .js files are treated as CommonJS files.
writeFileSync('dist/cjs/package.json', JSON.stringify({ type: 'commonjs' }))

// Place a package.json file with `type: module` in the dist folder so that
// all .js files are treated as ES Module files.
writeFileSync('dist/package.json', JSON.stringify({ type: 'module' }))

// Add CommonJS types by creating common JS types. Using a .d.ts file, because .d.cts files don't auto resolve
// Notice I haven't specified thee types in package.json for these - it's following the naming conversion TSC wants.
// Add CommonJS types by creating common JS types. Using a .d.ts file, because
// .d.cts files don't auto resolve
// Notice I haven't specified the types in package.json for these - it's
// following the naming conversion TSC wants.
writeFileSync('dist/cjs/index.d.ts', 'export type * from "../index.d.ts"')
writeFileSync('dist/cjs/buildFeServer.d.ts', 'export type * from "../buildFeServer.d.ts"')
writeFileSync(
'dist/cjs/buildFeServer.d.ts',
'export type * from "../buildFeServer.d.ts"',
)
writeFileSync('dist/cjs/client.d.ts', 'export type * from "../client.d.ts"')
writeFileSync('dist/cjs/clientSsr.d.ts', 'export type * from "../clientSsr.d.ts"')
writeFileSync('dist/cjs/ClientRouter.d.ts', 'export type * from "../ClientRouter.d.ts"')
writeFileSync('dist/cjs/build/build.d.ts', 'export type * from "../../build/build.d.ts"')
writeFileSync(
'dist/cjs/clientSsr.d.ts',
'export type * from "../clientSsr.d.ts"',
)
writeFileSync(
'dist/cjs/ClientRouter.d.ts',
'export type * from "../ClientRouter.d.ts"',
)
writeFileSync(
'dist/cjs/build/build.d.ts',
'export type * from "../../build/build.d.ts"',
)
4 changes: 2 additions & 2 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
"inject"
],
"scripts": {
"build": "tsx build.mts && yarn build:types",
"build": "tsx build.ts && yarn build:types",
"build:pack": "yarn pack -o redwoodjs-vite.tgz",
"build:types": "tsc --build --verbose ./tsconfig.json",
"build:types": "tsc --build --verbose ./tsconfig.build.json",
"check:attw": "tsx ./attw.ts",
"test": "vitest run",
"check:package": "concurrently npm:check:attw yarn:publint",
Expand Down
2 changes: 0 additions & 2 deletions packages/vite/src/middleware/createMiddlewareRouter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ vi.mock('@redwoodjs/project-config', async () => {

const distRegisterMwMock = vi.fn()
vi.mock('/proj/web/dist/ssr/entry-server.mjs', () => {
console.log('using unix mock')
return {
registerMiddleware: distRegisterMwMock,
}
})
vi.mock('/C:/proj/web/dist/ssr/entry-server.mjs', () => {
console.log('using win32 mock')
return {
registerMiddleware: distRegisterMwMock,
}
Expand Down
18 changes: 15 additions & 3 deletions packages/vite/src/middleware/register.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { describe, expect, it, vitest } from 'vitest'
import { afterEach, beforeEach, describe, expect, it, vi, vitest } from 'vitest'

import type { Middleware, MiddlewareClass } from '@redwoodjs/web/middleware'
import {
MiddlewareRequest,
MiddlewareResponse,
} from '@redwoodjs/web/middleware'

import { addMiddlewareHandlers, chain, groupByRoutePatterns } from './register'
import type { MiddlewareReg } from './types'
import {
addMiddlewareHandlers,
chain,
groupByRoutePatterns,
} from './register.js'
import type { MiddlewareReg } from './types.js'

const fakeMiddleware: Middleware = vitest.fn()

Expand All @@ -26,6 +30,14 @@ class FakeClassMw implements MiddlewareClass {
}

describe('groupByRoutePatterns', () => {
beforeEach(() => {
vi.spyOn(console, 'error').mockImplementation(() => {})
})

afterEach(() => {
vi.mocked(console).error.mockRestore()
})

it('should group middleware by default *', () => {
const simpleExample = [fakeMiddleware]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ import { excludeOnMatch } from '../vite-plugin-remove-from-bundle.js'

describe('excludeModule', () => {
it('should return true if idToExclude matches id', () => {
const loadOutput = excludeOnMatch([{
id: /router\/dist\/splash-page/,
}],
const loadOutput = excludeOnMatch(
[{ id: /router\/dist\/splash-page/ }],
'/Users/dac09/Experiments/splash-page-null-loader/node_modules/@redwoodjs/router/dist/splash-page.js?commonjs-exports',
)

expect(loadOutput).not.toEqual({
code: 'module.exports = null'
code: 'module.exports = null',
})
})

it("should return false if idToExclude doesn't match id", () => {
const loadOutput = excludeOnMatch([{
id: /bazinga-page/,
}],
'/Users/dac09/Experiments/splash-page-null-loader/node_modules/@redwoodjs/router/dist/params.js')
const loadOutput = excludeOnMatch(
[{ id: /bazinga-page/ }],
'/Users/dac09/Experiments/splash-page-null-loader/node_modules/@redwoodjs/router/dist/params.js',
)

expect(loadOutput).toEqual(null)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { swapApolloProvider } from '../vite-plugin-swap-apollo-provider.js'
import { describe, it, expect } from 'vitest'

import { swapApolloProvider } from '../vite-plugin-swap-apollo-provider.js'

describe('excludeModule', () => {
it('should swap the import', async () => {
const plugin = swapApolloProvider()
Expand Down
Loading

0 comments on commit 58c3530

Please sign in to comment.