From 95259ce8b1a0093e18b43a05ce5c6c38f5d0522d Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Mon, 5 Aug 2024 20:54:21 +0200 Subject: [PATCH 01/12] RSC: Improve type safety in RSC transform plugins (#11155) --- .../vite-plugin-rsc-transform-client.ts | 8 ++--- .../vite-plugin-rsc-transform-server.ts | 34 ++++++++++++++----- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/packages/vite/src/plugins/vite-plugin-rsc-transform-client.ts b/packages/vite/src/plugins/vite-plugin-rsc-transform-client.ts index 9d6b2358bc08..4435a0440e77 100644 --- a/packages/vite/src/plugins/vite-plugin-rsc-transform-client.ts +++ b/packages/vite/src/plugins/vite-plugin-rsc-transform-client.ts @@ -1,6 +1,6 @@ import path from 'node:path' -import type { Statement, ModuleDeclaration, AssignmentExpression } from 'acorn' +import type { AssignmentExpression, Program } from 'acorn' import * as acorn from 'acorn-loose' import { normalizePath, type Plugin } from 'vite' @@ -27,7 +27,7 @@ export function rscTransformUseClientPlugin( return code } - let body: (Statement | ModuleDeclaration)[] + let body: Program['body'] try { body = acorn.parse(code, { @@ -126,7 +126,7 @@ function addExportNames(names: Array, node: any) { */ async function parseExportNamesIntoNames( code: string, - body: (Statement | ModuleDeclaration)[], + body: Program['body'], names: Array, ): Promise { for (let i = 0; i < body.length; i++) { @@ -246,7 +246,7 @@ async function parseExportNamesIntoNames( async function transformClientModule( code: string, - body: (Statement | ModuleDeclaration)[], + body: Program['body'], url: string, clientEntryFiles: Record, ): Promise { diff --git a/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts b/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts index bbfc35f33d0e..de2c01848e3e 100644 --- a/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts +++ b/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts @@ -1,4 +1,5 @@ -import * as acorn from 'acorn-loose' +import type { AssignmentProperty, Expression, Pattern, Program } from 'acorn' +import { parse } from 'acorn-loose' import type { Plugin } from 'vite' export function rscTransformUseServerPlugin(): Plugin { @@ -20,10 +21,10 @@ export function rscTransformUseServerPlugin(): Plugin { return code } - let body + let body: Program['body'] try { - body = acorn.parse(code, { + body = parse(code, { ecmaVersion: 2024, sourceType: 'module', }).body @@ -68,7 +69,10 @@ export function rscTransformUseServerPlugin(): Plugin { } } -function addLocalExportedNames(names: Map, node: any) { +function addLocalExportedNames( + names: Map, + node: Pattern | AssignmentProperty | Expression, +) { switch (node.type) { case 'Identifier': names.set(node.name, node.name) @@ -106,13 +110,20 @@ function addLocalExportedNames(names: Map, node: any) { case 'ParenthesizedExpression': addLocalExportedNames(names, node.expression) return + + default: + throw new Error(`Unsupported node type: ${node.type}`) } } -function transformServerModule(body: any, url: string, code: string): string { +function transformServerModule( + body: Program['body'], + url: string, + code: string, +): string { // If the same local name is exported more than once, we only need one of the names. - const localNames = new Map() - const localTypes = new Map() + const localNames = new Map() + const localTypes = new Map() for (let i = 0; i < body.length; i++) { const node = body[i] @@ -157,7 +168,14 @@ function transformServerModule(body: any, url: string, code: string): string { for (let j = 0; j < specifiers.length; j++) { const specifier = specifiers[j] - localNames.set(specifier.local.name, specifier.exported.name) + if ( + specifier.local.type === 'Identifier' && + specifier.exported.type === 'Identifier' + ) { + localNames.set(specifier.local.name, specifier.exported.name) + } else { + throw new Error('Unsupported export specifier') + } } } From aa99976c55a7ac8c513ad77300c0da195d5bcf59 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Mon, 5 Aug 2024 21:24:00 +0200 Subject: [PATCH 02/12] RSC: Fix red squiggles in transform client tests (#11156) --- .../vite-plugin-rsc-transform-client.test.mts | 34 +++---------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.mts b/packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.mts index 65f2b56e78a3..18f931821aaa 100644 --- a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.mts +++ b/packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.mts @@ -1,7 +1,7 @@ import path from 'node:path' + import { vol } from 'memfs' import { normalizePath } from 'vite' - import { afterAll, beforeAll, @@ -41,7 +41,7 @@ describe('rscRoutesAutoLoader', () => { it('should handle CJS modules with exports.Link = ...', async () => { const id = normalizePath( path.join( - process.env.RWJS_CWD, + process.env.RWJS_CWD || '', 'node_modules', '@redwoodjs', 'router', @@ -105,23 +105,11 @@ describe('rscRoutesAutoLoader', () => { id, ) - const clientId = normalizePath( - path.join( - process.env.RWJS_CWD, - 'web', - 'dist', - 'rsc', - 'assets', - 'rsc-link.js-13.mjs', - ), - ) - // What we are interested in seeing here is: // - There's a CLIENT_REFERENCE // - There's a Link export // - There's a proper $$id - expect(output) - .toMatchInlineSnapshot(` + expect(output).toMatchInlineSnapshot(` "import {registerClientReference} from "react-server-dom-webpack/server"; export const Link = registerClientReference(function() {throw new Error("Attempted to call Link() from the server but Link is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");},"/Users/tobbe/rw-app/web/dist/rsc/assets/rsc-link.js-13.mjs","Link") ;" @@ -131,7 +119,7 @@ describe('rscRoutesAutoLoader', () => { it('should handle CJS modules with module.exports = { ErrorIcon, ToastBar, ... }', async () => { const id = normalizePath( path.join( - process.env.RWJS_CWD, + process.env.RWJS_CWD || '', 'node_modules', 'react-hot-toast', 'dist', @@ -175,22 +163,10 @@ describe('rscRoutesAutoLoader', () => { id, ) - const clientId = normalizePath( - path.join( - process.env.RWJS_CWD, - 'web', - 'dist', - 'rsc', - 'assets', - 'rsc-index.js-15.mjs', - ), - ) - // What we are interested in seeing here is: // - The import of `renderFromRscServer` from `@redwoodjs/vite/client` // - The call to `renderFromRscServer` for each page that wasn't already imported - expect(output) - .toMatchInlineSnapshot(` + expect(output).toMatchInlineSnapshot(` "import {registerClientReference} from "react-server-dom-webpack/server"; export const CheckmarkIcon = registerClientReference(function() {throw new Error("Attempted to call CheckmarkIcon() from the server but CheckmarkIcon is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");},"/Users/tobbe/rw-app/web/dist/rsc/assets/rsc-index.js-15.mjs","CheckmarkIcon") ;export const ErrorIcon = registerClientReference(function() {throw new Error("Attempted to call ErrorIcon() from the server but ErrorIcon is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");},"/Users/tobbe/rw-app/web/dist/rsc/assets/rsc-index.js-15.mjs","ErrorIcon") From 5dea4a7cf3a2c671e25ac900961d53084d45e244 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Tue, 6 Aug 2024 13:33:39 +0200 Subject: [PATCH 03/12] RSC: RSA: Remove unused check for '$$id' (#11159) --- .../vite/src/plugins/vite-plugin-rsc-transform-server.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts b/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts index de2c01848e3e..65dd7fab61e1 100644 --- a/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts +++ b/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts @@ -12,15 +12,6 @@ export function rscTransformUseServerPlugin(): Plugin { return code } - // TODO (RSC): Bad bad hack. Don't do this. - // At least look for something that's guaranteed to be only present in - // transformed modules - // Ideally don't even try to transform twice - if (code.includes('$$id')) { - // Already transformed - return code - } - let body: Program['body'] try { From c81683bd8f3d7110cd0110ac7e0348c4f81fe2ba Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Tue, 6 Aug 2024 13:33:49 +0200 Subject: [PATCH 04/12] RSC: RSA: Add more comments to the basic 'use server' check (#11160) --- .../vite/src/plugins/vite-plugin-rsc-transform-server.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts b/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts index 65dd7fab61e1..a058f1f46da4 100644 --- a/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts +++ b/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts @@ -7,7 +7,10 @@ export function rscTransformUseServerPlugin(): Plugin { name: 'rsc-transform-use-server-plugin', transform: async function (code, id) { // Do a quick check for the exact string. If it doesn't exist, don't - // bother parsing. + // bother parsing. This check doesn't have to be perfect. It's just a + // quick check to avoid doing a full parse to build an AST. + // Plesae benchmark before making any changes here. + // See https://github.com/redwoodjs/redwood/pull/11158 if (!code.includes('use server')) { return code } From a413bbc8d11639b9127866f0ec32c5d73436fc05 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Tue, 6 Aug 2024 14:19:47 +0200 Subject: [PATCH 05/12] RSC: RSA: Better match error handling with how we generally do it in RW (#11161) --- packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts b/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts index a058f1f46da4..b1a1aed6d44b 100644 --- a/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts +++ b/packages/vite/src/plugins/vite-plugin-rsc-transform-server.ts @@ -22,8 +22,8 @@ export function rscTransformUseServerPlugin(): Plugin { ecmaVersion: 2024, sourceType: 'module', }).body - } catch (x: any) { - console.error('Error parsing %s %s', id, x.message) + } catch (e: any) { + console.error('Error parsing', id, e.message) return code } From b925930d978a0ca272fad53aef2c0cc634297ef4 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Tue, 6 Aug 2024 14:26:19 +0200 Subject: [PATCH 06/12] chore(tsconfig): Format vite tsconfig (#11162) --- packages/vite/tsconfig.json | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/packages/vite/tsconfig.json b/packages/vite/tsconfig.json index ca6c432788a1..969b8aca80b8 100644 --- a/packages/vite/tsconfig.json +++ b/packages/vite/tsconfig.json @@ -4,31 +4,15 @@ "rootDir": "src", "outDir": "dist", "moduleResolution": "NodeNext", - "module": "NodeNext", + "module": "NodeNext" }, - "include": [ - "src/**/*", - "./ambient.d.ts", - "./modules.d.ts", - ], + "include": ["src/**/*", "./ambient.d.ts", "./modules.d.ts"], "references": [ - { - "path": "../cookie-jar" - }, - { - "path": "../internal" - }, - { - "path": "../project-config" - }, - { - "path": "../router/tsconfig.build.json" - }, - { - "path": "../server-store" - }, - { - "path": "../web/tsconfig.build.json" - } + { "path": "../cookie-jar" }, + { "path": "../internal" }, + { "path": "../project-config" }, + { "path": "../router/tsconfig.build.json" }, + { "path": "../server-store" }, + { "path": "../web/tsconfig.build.json" } ] } From a34e23f90bccc5ac0b14099d279da7d0c8fd1101 Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Tue, 6 Aug 2024 14:45:07 +0200 Subject: [PATCH 07/12] chore(rwjs/vite): Rename build script and format source (#11163) --- packages/vite/{build.mts => build.ts} | 47 ++++++++++++++++++--------- packages/vite/package.json | 2 +- 2 files changed, 32 insertions(+), 17 deletions(-) rename packages/vite/{build.mts => build.ts} (65%) diff --git a/packages/vite/build.mts b/packages/vite/build.ts similarity index 65% rename from packages/vite/build.mts rename to packages/vite/build.ts index b670113cdda2..bedf13fdca97 100644 --- a/packages/vite/build.mts +++ b/packages/vite/build.ts @@ -1,14 +1,14 @@ +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: { @@ -43,28 +43,43 @@ 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', }) -// 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"', +) diff --git a/packages/vite/package.json b/packages/vite/package.json index cf357a114917..2e4f9b58fa05 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -51,7 +51,7 @@ "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", "check:attw": "tsx ./attw.ts", From 24a30ab7ef5eccfa848769467495f61388a3992e Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Tue, 6 Aug 2024 14:57:25 +0200 Subject: [PATCH 08/12] chore(ci): Print full diff when check-test-project-fixture fails (#11164) --- .github/workflows/check-test-project-fixture.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/check-test-project-fixture.yml b/.github/workflows/check-test-project-fixture.yml index 07addec6f5d9..d6c083cae954 100644 --- a/.github/workflows/check-test-project-fixture.yml +++ b/.github/workflows/check-test-project-fixture.yml @@ -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 From 71c5b026b5706127bc222ebfa7bd72b50906dc5a Mon Sep 17 00:00:00 2001 From: Josh GM Walker <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Tue, 6 Aug 2024 19:36:11 +0100 Subject: [PATCH 09/12] chore(fixture): Rebuild test project fixture (#11166) As title. Just needed to commit the version update for the CI check to go green on other PRs. --- __fixtures__/test-project/web/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__fixtures__/test-project/web/package.json b/__fixtures__/test-project/web/package.json index c925000a5920..120309fcb040 100644 --- a/__fixtures__/test-project/web/package.json +++ b/__fixtures__/test-project/web/package.json @@ -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" From 255cffbfdce6592f7a3a1a98084fffde9ba7f3d1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 19:38:02 +0100 Subject: [PATCH 10/12] fix(deps): update prisma monorepo to v5.18.0 (#11165) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@prisma/client](https://www.prisma.io) ([source](https://togithub.com/prisma/prisma/tree/HEAD/packages/client)) | [`5.17.0` -> `5.18.0`](https://renovatebot.com/diffs/npm/@prisma%2fclient/5.17.0/5.18.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@prisma%2fclient/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@prisma%2fclient/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@prisma%2fclient/5.17.0/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@prisma%2fclient/5.17.0/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [@prisma/internals](https://www.prisma.io) ([source](https://togithub.com/prisma/prisma/tree/HEAD/packages/internals)) | [`5.17.0` -> `5.18.0`](https://renovatebot.com/diffs/npm/@prisma%2finternals/5.17.0/5.18.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@prisma%2finternals/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@prisma%2finternals/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@prisma%2finternals/5.17.0/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@prisma%2finternals/5.17.0/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [prisma](https://www.prisma.io) ([source](https://togithub.com/prisma/prisma/tree/HEAD/packages/cli)) | [`5.17.0` -> `5.18.0`](https://renovatebot.com/diffs/npm/prisma/5.17.0/5.18.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/prisma/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/prisma/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/prisma/5.17.0/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/prisma/5.17.0/5.18.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
prisma/prisma (@​prisma/client) ### [`v5.18.0`](https://togithub.com/prisma/prisma/releases/tag/5.18.0) [Compare Source](https://togithub.com/prisma/prisma/compare/5.17.0...5.18.0) 🌟 **Help us spread the word about Prisma by starring the repo or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20@​prisma%20release%20v5.18.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/5.18.0) about the release.** 🌟 ##### Highlights ##### Native support for UUIDv7 Previous to this release, the Prisma Schema function `uuid()` did not accept any arguments and created a UUIDv4 ID. While sufficient in many cases, UUIDv4 has a few drawbacks, namely that it is not temporally sortable. UUIDv7 attempts to resolve this issue, making it easy to temporally sort your database rows by ID! To support this, we’ve updated the `uuid()` function in Prisma Schema to accept an optional, integer argument. Right now, the only valid values are `4` and `7`, with `4` being the default. ```tsx model User { id String @​id @​default(uuid()) // defaults to 4 name String } model User { id String @​id @​default(uuid(4)) // same as above, but explicit name String } model User { id String @​id @​default(uuid(7)) // will use UUIDv7 instead of UUIDv4 name String } ``` ##### Bug squashing We’ve squashed a number of bugs this release, special thanks to everyone who helped us! A few select highlights are: - [SQLite db will now be created and read from the correct location when using `prismaSchemaFolder`](https://togithub.com/prisma/prisma/issues/24779). - [Empty `Json[]` fields will now return `[]` instead of `null` when accessed through a join using the `relationJoins` Preview feature.](https://togithub.com/prisma/prisma/issues/22923) ##### Fixes and improvements ##### Prisma - [Support UUID v7](https://togithub.com/prisma/prisma/issues/24079) ##### Language tools (e.g. VS Code) - [Support fetching references for a model](https://togithub.com/prisma/language-tools/issues/982) ##### Credits Huge thanks to [@​mcuelenaere](https://togithub.com/mcuelenaere), [@​pagewang0](https://togithub.com/pagewang0), [@​Druue](https://togithub.com/Druue), [@​key-moon](https://togithub.com/key-moon), [@​Jolg42](https://togithub.com/Jolg42), [@​pranayat](https://togithub.com/pranayat), [@​ospfranco](https://togithub.com/ospfranco), [@​yubrot](https://togithub.com/yubrot), [@​skyzh](https://togithub.com/skyzh), [@​haaawk](https://togithub.com/haaawk) for helping!
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [x] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/redwoodjs/redwood). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- packages/api/package.json | 2 +- .../auth-providers/dbAuth/setup/package.json | 2 +- .../cli-packages/dataMigrate/package.json | 2 +- packages/cli/package.json | 4 +- packages/record/package.json | 4 +- packages/structure/package.json | 2 +- yarn.lock | 140 +++++++++--------- 7 files changed, 78 insertions(+), 78 deletions(-) diff --git a/packages/api/package.json b/packages/api/package.json index 0df448503288..862052d23265 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -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", diff --git a/packages/auth-providers/dbAuth/setup/package.json b/packages/auth-providers/dbAuth/setup/package.json index 50940093d6e0..e8ab616660e5 100644 --- a/packages/auth-providers/dbAuth/setup/package.json +++ b/packages/auth-providers/dbAuth/setup/package.json @@ -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", diff --git a/packages/cli-packages/dataMigrate/package.json b/packages/cli-packages/dataMigrate/package.json index bfeac55bf432..1c78926fc5f3 100644 --- a/packages/cli-packages/dataMigrate/package.json +++ b/packages/cli-packages/dataMigrate/package.json @@ -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", diff --git a/packages/cli/package.json b/packages/cli/package.json index b77547ca1c9d..07265579ad90 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -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:*", @@ -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", diff --git a/packages/record/package.json b/packages/record/package.json index 7dd98dad53e8..0654cb92fba9 100644 --- a/packages/record/package.json +++ b/packages/record/package.json @@ -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" }, diff --git a/packages/structure/package.json b/packages/structure/package.json index 8265d4403f32..f42d06e9b4a2 100644 --- a/packages/structure/package.json +++ b/packages/structure/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index cd78288431a9..9336878b1c22 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6406,104 +6406,104 @@ __metadata: languageName: node linkType: hard -"@prisma/client@npm:5.17.0": - version: 5.17.0 - resolution: "@prisma/client@npm:5.17.0" +"@prisma/client@npm:5.18.0": + version: 5.18.0 + resolution: "@prisma/client@npm:5.18.0" peerDependencies: prisma: "*" peerDependenciesMeta: prisma: optional: true - checksum: 10c0/cc6c5e9bfbc2f9a01fdf73e009c42298b8a9fea8c9b19db0089cad84a9ee94c3bb6f66f53f1e2f4b32b3506706bf16d23a8e3bcb4619a8bc76d0812a8382ae63 + checksum: 10c0/2031e0521671e8d922abefbe24e0e37d38dfda38a0069206c928491e570afceb25630ea322536c6c16f24e73e162ce84062e8735e373e1659d8cdf849251a47b languageName: node linkType: hard -"@prisma/debug@npm:5.17.0": - version: 5.17.0 - resolution: "@prisma/debug@npm:5.17.0" - checksum: 10c0/10aca89c8cd3a96c7f1153792110f33d96d1875e4af807002b9ca061eda255b1aa21e757b9e7a1690ac0676fb2312c441191cdb357acf45617dd658678984053 +"@prisma/debug@npm:5.18.0": + version: 5.18.0 + resolution: "@prisma/debug@npm:5.18.0" + checksum: 10c0/fcc1e784748e207410aac9fe5989d0b9b889f8fe1bf52ca742d7fcc09c5abd5897b7ee4dbce33c86ce501681619a06c5802bbe9bd2ba5264435f6c04eeddeeec languageName: node linkType: hard -"@prisma/engines-version@npm:5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053": - version: 5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053 - resolution: "@prisma/engines-version@npm:5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053" - checksum: 10c0/164b4cd6965da770bcd085fa0596466b092060d19eb8a4ba3402e66bd9b2e813cae417eeca99422b66a3a05a65cfe6d0e0339083b53644acf553ac138693232d +"@prisma/engines-version@npm:5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169": + version: 5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169 + resolution: "@prisma/engines-version@npm:5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169" + checksum: 10c0/6f5683a61414e95f4adf7bdffa2854733bb4b3bed1c020aa3b9241f6ad38ecf6e2cf0be36492fbd9aa3bbf9d0b2b6d4d2b7b0578d4c1b6b65336ef90f52e79b9 languageName: node linkType: hard -"@prisma/engines@npm:5.17.0": - version: 5.17.0 - resolution: "@prisma/engines@npm:5.17.0" +"@prisma/engines@npm:5.18.0": + version: 5.18.0 + resolution: "@prisma/engines@npm:5.18.0" dependencies: - "@prisma/debug": "npm:5.17.0" - "@prisma/engines-version": "npm:5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053" - "@prisma/fetch-engine": "npm:5.17.0" - "@prisma/get-platform": "npm:5.17.0" - checksum: 10c0/b1d48c39fbe16680947685960be615894ccc1a2ca40263fc6d1ac4599e3100f2f31e71b02bd000c0f3269cd045f38817dfbddd37fefcb8a4dec6155a6df48e2f + "@prisma/debug": "npm:5.18.0" + "@prisma/engines-version": "npm:5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169" + "@prisma/fetch-engine": "npm:5.18.0" + "@prisma/get-platform": "npm:5.18.0" + checksum: 10c0/3d39b8e2e620c54cbb98df303896ef980dd5707f872f26471f6fd3e7dd59d4ddacac70020da1fc9f864c87a69bf38b5a50d3884f7a820314306de53c9aefaa43 languageName: node linkType: hard -"@prisma/fetch-engine@npm:5.17.0": - version: 5.17.0 - resolution: "@prisma/fetch-engine@npm:5.17.0" +"@prisma/fetch-engine@npm:5.18.0": + version: 5.18.0 + resolution: "@prisma/fetch-engine@npm:5.18.0" dependencies: - "@prisma/debug": "npm:5.17.0" - "@prisma/engines-version": "npm:5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053" - "@prisma/get-platform": "npm:5.17.0" - checksum: 10c0/b5c554e8a637871fd6497e656d67e649d9eea3a06be325b68a686b707c78d200ba9ba20bd76b0a3408e5cb78f6e34bab535ce161174273db377353a01368806e + "@prisma/debug": "npm:5.18.0" + "@prisma/engines-version": "npm:5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169" + "@prisma/get-platform": "npm:5.18.0" + checksum: 10c0/98e6a9cdaad41b2f99846f9b56d679295353ab33104bd8074ed9390ab898d7c80a3a62b0726b8fafb685da5748c4eca71254777aaa815b9a8da3041d402bdf4e languageName: node linkType: hard -"@prisma/generator-helper@npm:5.17.0": - version: 5.17.0 - resolution: "@prisma/generator-helper@npm:5.17.0" +"@prisma/generator-helper@npm:5.18.0": + version: 5.18.0 + resolution: "@prisma/generator-helper@npm:5.18.0" dependencies: - "@prisma/debug": "npm:5.17.0" - checksum: 10c0/edf1c8a8ea34fb86a8836aa5b2a933fb1bae949bdede17f2f153de2db27f8c523595518a92f791047fd994701c15c4a0847c448dd4349aa892d5dd3a1ffab7b4 + "@prisma/debug": "npm:5.18.0" + checksum: 10c0/ef4618a799d6a6f9899858eca9b7ca87ab3fd027587cd076ecc0c98d458f5d20b393d06beb293385af269139bc1b8254e7a2cf6b239a1032ecf8141a484c182b languageName: node linkType: hard -"@prisma/get-platform@npm:5.17.0": - version: 5.17.0 - resolution: "@prisma/get-platform@npm:5.17.0" +"@prisma/get-platform@npm:5.18.0": + version: 5.18.0 + resolution: "@prisma/get-platform@npm:5.18.0" dependencies: - "@prisma/debug": "npm:5.17.0" - checksum: 10c0/8687736c6e18737e29544bc1f98653b75b4dcb85c1ffe02686da100e843bb30041dd9d00146a2178517d34b783a650c8b76bdde5029d1675bd28c2be6ee6565a + "@prisma/debug": "npm:5.18.0" + checksum: 10c0/a633b6390382899723c88d41af939e324a98a0bdd1683d1a07df5e80ce01f1e24cc534926652ab5352675e553ce54f1123e60eaba911066fb3bbc516b0f3ba19 languageName: node linkType: hard -"@prisma/internals@npm:5.17.0": - version: 5.17.0 - resolution: "@prisma/internals@npm:5.17.0" +"@prisma/internals@npm:5.18.0": + version: 5.18.0 + resolution: "@prisma/internals@npm:5.18.0" dependencies: - "@prisma/debug": "npm:5.17.0" - "@prisma/engines": "npm:5.17.0" - "@prisma/fetch-engine": "npm:5.17.0" - "@prisma/generator-helper": "npm:5.17.0" - "@prisma/get-platform": "npm:5.17.0" - "@prisma/prisma-schema-wasm": "npm:5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053" - "@prisma/schema-files-loader": "npm:5.17.0" + "@prisma/debug": "npm:5.18.0" + "@prisma/engines": "npm:5.18.0" + "@prisma/fetch-engine": "npm:5.18.0" + "@prisma/generator-helper": "npm:5.18.0" + "@prisma/get-platform": "npm:5.18.0" + "@prisma/prisma-schema-wasm": "npm:5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169" + "@prisma/schema-files-loader": "npm:5.18.0" arg: "npm:5.0.2" prompts: "npm:2.4.2" - checksum: 10c0/d58227bb50e96c48fbc698e811a9be38e0dc47d9050677c263d1d2549a26ba76c31d6635a64c5946adbfc1fc15c6a08a96f15ee145d5e7b1b97d9fd02fc2f2af + checksum: 10c0/616f28a321143bbff739b8604bd75a253db880c04aeaf569417e12ff5373ff859055c18c7747993a63947e6e9737d3f1dbf8281f3ab415bd7086edf95f616314 languageName: node linkType: hard -"@prisma/prisma-schema-wasm@npm:5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053": - version: 5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053 - resolution: "@prisma/prisma-schema-wasm@npm:5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053" - checksum: 10c0/4beecf2482efc6e13e902af6210d838a1414947ac972714744462a439e6e8fe07222b19761337511ecc178dc723d7c9db728c3c9034132a565ade5562ed555f9 +"@prisma/prisma-schema-wasm@npm:5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169": + version: 5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169 + resolution: "@prisma/prisma-schema-wasm@npm:5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169" + checksum: 10c0/f07d2c7b93517cdb7a69c7b0872137f7d5ed1707abc31dd56f98361c123cc876cb00bf3a92da496029a1106cec3c379507c6aa6aaa0e7fc684f5a1720f7854b1 languageName: node linkType: hard -"@prisma/schema-files-loader@npm:5.17.0": - version: 5.17.0 - resolution: "@prisma/schema-files-loader@npm:5.17.0" +"@prisma/schema-files-loader@npm:5.18.0": + version: 5.18.0 + resolution: "@prisma/schema-files-loader@npm:5.18.0" dependencies: - "@prisma/prisma-schema-wasm": "npm:5.17.0-31.393aa359c9ad4a4bb28630fb5613f9c281cde053" + "@prisma/prisma-schema-wasm": "npm:5.18.0-25.4c784e32044a8a016d99474bd02a3b6123742169" fs-extra: "npm:11.1.1" - checksum: 10c0/a53adda5b5dbe0a3c1f0756186bbf440e3d9aa3b9bd24035536e5d91a57e4108160ea6e75df4ad44faf0e0df8ca1f763035ef054a2a70df8e0bd6f3ba9be8980 + checksum: 10c0/e19fb3e1d0f6154a433743b9a9ce1dc29f22f1d71e00d8924ebfd7030b352da82985cf281da1e39a41ebf5ba62a2ab9aa8c018d9e2aca1b4736d96c08f621925 languageName: node linkType: hard @@ -7283,7 +7283,7 @@ __metadata: "@babel/cli": "npm:7.24.8" "@babel/core": "npm:^7.22.20" "@babel/runtime-corejs3": "npm:7.24.8" - "@prisma/client": "npm:5.17.0" + "@prisma/client": "npm:5.18.0" "@types/aws-lambda": "npm:8.10.142" "@types/jsonwebtoken": "npm:9.0.6" "@types/memjs": "npm:1" @@ -7536,7 +7536,7 @@ __metadata: "@babel/cli": "npm:7.24.8" "@babel/core": "npm:^7.22.20" "@babel/runtime-corejs3": "npm:7.24.8" - "@prisma/internals": "npm:5.17.0" + "@prisma/internals": "npm:5.18.0" "@redwoodjs/cli-helpers": "workspace:*" "@simplewebauthn/browser": "npm:7.4.0" "@simplewebauthn/typescript-types": "npm:7.4.0" @@ -7858,7 +7858,7 @@ __metadata: version: 0.0.0-use.local resolution: "@redwoodjs/cli-data-migrate@workspace:packages/cli-packages/dataMigrate" dependencies: - "@prisma/client": "npm:5.17.0" + "@prisma/client": "npm:5.18.0" "@redwoodjs/babel-config": "workspace:*" "@redwoodjs/framework-tools": "workspace:*" "@redwoodjs/project-config": "workspace:*" @@ -7946,7 +7946,7 @@ __metadata: "@opentelemetry/resources": "npm:1.22.0" "@opentelemetry/sdk-trace-node": "npm:1.22.0" "@opentelemetry/semantic-conventions": "npm:1.22.0" - "@prisma/internals": "npm:5.17.0" + "@prisma/internals": "npm:5.18.0" "@redwoodjs/api-server": "workspace:*" "@redwoodjs/cli-helpers": "workspace:*" "@redwoodjs/fastify-web": "workspace:*" @@ -7984,7 +7984,7 @@ __metadata: pluralize: "npm:8.0.0" portfinder: "npm:1.0.32" prettier: "npm:3.3.3" - prisma: "npm:5.17.0" + prisma: "npm:5.18.0" prompts: "npm:2.4.2" rimraf: "npm:6.0.1" semver: "npm:7.6.3" @@ -8506,8 +8506,8 @@ __metadata: "@babel/cli": "npm:7.24.8" "@babel/core": "npm:^7.22.20" "@babel/runtime-corejs3": "npm:7.24.8" - "@prisma/client": "npm:5.17.0" - "@prisma/internals": "npm:5.17.0" + "@prisma/client": "npm:5.18.0" + "@prisma/internals": "npm:5.18.0" "@redwoodjs/project-config": "workspace:*" core-js: "npm:3.37.1" esbuild: "npm:0.23.0" @@ -8567,7 +8567,7 @@ __metadata: "@babel/cli": "npm:7.24.8" "@babel/core": "npm:^7.22.20" "@babel/runtime-corejs3": "npm:7.24.8" - "@prisma/internals": "npm:5.17.0" + "@prisma/internals": "npm:5.18.0" "@redwoodjs/project-config": "workspace:*" "@types/fs-extra": "npm:11.0.4" "@types/line-column": "npm:1.0.2" @@ -24920,14 +24920,14 @@ __metadata: languageName: node linkType: hard -"prisma@npm:5.17.0": - version: 5.17.0 - resolution: "prisma@npm:5.17.0" +"prisma@npm:5.18.0": + version: 5.18.0 + resolution: "prisma@npm:5.18.0" dependencies: - "@prisma/engines": "npm:5.17.0" + "@prisma/engines": "npm:5.18.0" bin: prisma: build/index.js - checksum: 10c0/30546a8576ffadf66d6f34cd833e25e21eec99847db92c4d88f6c9dbbc401abbd3f699f9e0f0dbcd9d5229ccba47c6aadb42ba6cd6e29afb7335689c7257c964 + checksum: 10c0/83649284d590dc996b1c1ac1b0382dae5f838d2d1c0098ac075564acbb0450ec0f6716077184c4cc1889ca79eae8c6f295dcbc9721b41c00a8494936cd20eab3 languageName: node linkType: hard From fdd0a149a7f73593ecbf39a9cb91f9b58ef83cd1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 18:48:53 +0000 Subject: [PATCH 11/12] chore(config): migrate renovate config (#11157) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) The Renovate config in this repository needs migrating. Typically this is because one or more configuration options you are using have been renamed. You don't need to merge this PR right away, because Renovate will continue to migrate these fields internally each time it runs. But later some of these fields may be fully deprecated and the migrations removed. So it's a good idea to merge this migration PR soon. 🔕 **Ignore**: Close this PR and you won't be reminded about config migration again, but one day your current config may no longer be valid. ❓ Got questions? Does something look wrong to you? Please don't hesitate to [request help here](https://togithub.com/renovatebot/renovate/discussions). --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/redwoodjs/redwood). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/renovate.json | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/.github/renovate.json b/.github/renovate.json index 3aa6fbfd133d..63d627ee067a 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -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", @@ -41,16 +29,12 @@ "tempy", "terminal-link", "title-case", - "untildify" - ], - "matchPackagePatterns": [ - "^@redwoodjs/" + "untildify", + "/^@redwoodjs//" ] }, - { "groupName": "chore", - "matchPackageNames": [ "all-contributors-cli", "cypress", From f192815a94f5b0927152502b44f7a3b2dc615d6b Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Wed, 7 Aug 2024 09:48:38 +0200 Subject: [PATCH 12/12] chore(tsconfig.build): Fix type checking for tests etc (#11167) --- .../dbAuth/middleware/tsconfig.json | 2 +- .../supabase/middleware/tsconfig.json | 2 +- packages/ogimage-gen/tsconfig.json | 20 +-- packages/vite/build.ts | 3 + packages/vite/package.json | 2 +- .../middleware/createMiddlewareRouter.test.ts | 2 - packages/vite/src/middleware/register.test.ts | 18 ++- ...le.test.mts => remove-from-bundle.test.ts} | 15 +- ....test.mts => swap-apollo-provider.test.ts} | 3 +- ...vite-plugin-rsc-route-auto-loader.test.ts} | 148 +++++++++--------- ... vite-plugin-rsc-transform-client.test.ts} | 55 +++---- packages/vite/tsconfig.build.json | 18 +++ packages/vite/tsconfig.json | 10 +- 13 files changed, 155 insertions(+), 143 deletions(-) rename packages/vite/src/plugins/__tests__/{remove-from-bundle.test.mts => remove-from-bundle.test.ts} (70%) rename packages/vite/src/plugins/__tests__/{swap-apollo-provider.test.mts => swap-apollo-provider.test.ts} (99%) rename packages/vite/src/plugins/__tests__/{vite-plugin-rsc-route-auto-loader.test.mts => vite-plugin-rsc-route-auto-loader.test.ts} (82%) rename packages/vite/src/plugins/__tests__/{vite-plugin-rsc-transform-client.test.mts => vite-plugin-rsc-transform-client.test.ts} (93%) create mode 100644 packages/vite/tsconfig.build.json diff --git a/packages/auth-providers/dbAuth/middleware/tsconfig.json b/packages/auth-providers/dbAuth/middleware/tsconfig.json index ef0803ddf324..abbc9e9219c5 100644 --- a/packages/auth-providers/dbAuth/middleware/tsconfig.json +++ b/packages/auth-providers/dbAuth/middleware/tsconfig.json @@ -10,6 +10,6 @@ "include": ["src/**/*"], "references": [ { "path": "../../../auth/tsconfig.build.json" }, - { "path": "../../../vite" } + { "path": "../../../vite/tsconfig.build.json" } ] } diff --git a/packages/auth-providers/supabase/middleware/tsconfig.json b/packages/auth-providers/supabase/middleware/tsconfig.json index ef0803ddf324..abbc9e9219c5 100644 --- a/packages/auth-providers/supabase/middleware/tsconfig.json +++ b/packages/auth-providers/supabase/middleware/tsconfig.json @@ -10,6 +10,6 @@ "include": ["src/**/*"], "references": [ { "path": "../../../auth/tsconfig.build.json" }, - { "path": "../../../vite" } + { "path": "../../../vite/tsconfig.build.json" } ] } diff --git a/packages/ogimage-gen/tsconfig.json b/packages/ogimage-gen/tsconfig.json index 2208ea577509..e06bc797109b 100644 --- a/packages/ogimage-gen/tsconfig.json +++ b/packages/ogimage-gen/tsconfig.json @@ -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" } ] } diff --git a/packages/vite/build.ts b/packages/vite/build.ts index bedf13fdca97..2f2f9f833748 100644 --- a/packages/vite/build.ts +++ b/packages/vite/build.ts @@ -16,6 +16,7 @@ await build({ }, buildOptions: { ...defaultBuildOptions, + tsconfig: 'tsconfig.build.json', outdir: 'dist/cjs', packages: 'external', }, @@ -28,6 +29,7 @@ await build({ }, buildOptions: { ...defaultBuildOptions, + tsconfig: 'tsconfig.build.json', format: 'esm', packages: 'external', }, @@ -51,6 +53,7 @@ await esbuild.build({ // 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 diff --git a/packages/vite/package.json b/packages/vite/package.json index 2e4f9b58fa05..5c90af60d61a 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -53,7 +53,7 @@ "scripts": { "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", diff --git a/packages/vite/src/middleware/createMiddlewareRouter.test.ts b/packages/vite/src/middleware/createMiddlewareRouter.test.ts index 8aa0fe4089cf..610d90f03333 100644 --- a/packages/vite/src/middleware/createMiddlewareRouter.test.ts +++ b/packages/vite/src/middleware/createMiddlewareRouter.test.ts @@ -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, } diff --git a/packages/vite/src/middleware/register.test.ts b/packages/vite/src/middleware/register.test.ts index 3f7a4031dbd4..e59a3a3e5836 100644 --- a/packages/vite/src/middleware/register.test.ts +++ b/packages/vite/src/middleware/register.test.ts @@ -1,4 +1,4 @@ -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 { @@ -6,8 +6,12 @@ import { 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() @@ -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] diff --git a/packages/vite/src/plugins/__tests__/remove-from-bundle.test.mts b/packages/vite/src/plugins/__tests__/remove-from-bundle.test.ts similarity index 70% rename from packages/vite/src/plugins/__tests__/remove-from-bundle.test.mts rename to packages/vite/src/plugins/__tests__/remove-from-bundle.test.ts index 9c69b9d79717..75c3656c5adc 100644 --- a/packages/vite/src/plugins/__tests__/remove-from-bundle.test.mts +++ b/packages/vite/src/plugins/__tests__/remove-from-bundle.test.ts @@ -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) }) diff --git a/packages/vite/src/plugins/__tests__/swap-apollo-provider.test.mts b/packages/vite/src/plugins/__tests__/swap-apollo-provider.test.ts similarity index 99% rename from packages/vite/src/plugins/__tests__/swap-apollo-provider.test.mts rename to packages/vite/src/plugins/__tests__/swap-apollo-provider.test.ts index 0ae53ac54d14..847e25de5659 100644 --- a/packages/vite/src/plugins/__tests__/swap-apollo-provider.test.mts +++ b/packages/vite/src/plugins/__tests__/swap-apollo-provider.test.ts @@ -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() diff --git a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-route-auto-loader.test.mts b/packages/vite/src/plugins/__tests__/vite-plugin-rsc-route-auto-loader.test.ts similarity index 82% rename from packages/vite/src/plugins/__tests__/vite-plugin-rsc-route-auto-loader.test.mts rename to packages/vite/src/plugins/__tests__/vite-plugin-rsc-route-auto-loader.test.ts index 90e71f4fae30..40c7a0253f19 100644 --- a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-route-auto-loader.test.mts +++ b/packages/vite/src/plugins/__tests__/vite-plugin-rsc-route-auto-loader.test.ts @@ -1,18 +1,28 @@ import path from 'node:path' import { vol } from 'memfs' +import type { TransformPluginContext } from 'rollup' import { normalizePath } from 'vite' - -import { afterAll, beforeAll, describe, it, expect, vi, Mock, beforeEach, afterEach } from 'vitest' +import { + afterAll, + beforeAll, + describe, + it, + expect, + vi, + afterEach, +} from 'vitest' import { processPagesDir } from '@redwoodjs/project-config' import type * as ProjectConfig from '@redwoodjs/project-config' -import { rscRoutesAutoLoader } from '../vite-plugin-rsc-routes-auto-loader' +import { rscRoutesAutoLoader } from '../vite-plugin-rsc-routes-auto-loader.js' vi.mock('fs', async () => ({ default: (await import('memfs')).fs })) +const TEST_RWJS_CWD = '/Users/mojombo/rw-app/' const RWJS_CWD = process.env.RWJS_CWD +process.env.RWJS_CWD = TEST_RWJS_CWD vi.mock('@redwoodjs/project-config', async (importOriginal) => { const originalProjectConfig = await importOriginal() @@ -27,41 +37,43 @@ vi.mock('@redwoodjs/project-config', async (importOriginal) => { }, } }, - processPagesDir: vi.fn(), + processPagesDir: vi.fn(() => pages), } }) +const id = path.join(TEST_RWJS_CWD, 'web', 'src', 'Routes.tsx') + +let pluginTransform: ReturnType + +function getPluginTransform() { + const plugin = rscRoutesAutoLoader() + if (typeof plugin.transform !== 'function') { + throw new Error('Expected plugin to have a `transform` function') + } + + // Calling `bind` to please TS https://stackoverflow.com/a/70463512/88106 + // Typecasting because we're only going to call transform, and we don't need + // anything provided by the context. + return plugin.transform.bind({} as TransformPluginContext) +} + beforeAll(() => { // Add a toml entry for getPaths et al. - process.env.RWJS_CWD = '/Users/mojombo/rw-app/' - vol.fromJSON({ - 'redwood.toml': '', - }, process.env.RWJS_CWD) + vol.fromJSON({ 'redwood.toml': '' }, TEST_RWJS_CWD) + pluginTransform = getPluginTransform() }) afterAll(() => { process.env.RWJS_CWD = RWJS_CWD }) -describe('rscRoutesAutoLoader', () => { - beforeEach(() => { - (processPagesDir as Mock).mockReturnValue(pages) - }) - - afterEach(() => { - vi.resetAllMocks() - }) +afterEach(() => { + vi.resetAllMocks() +}) +describe('rscRoutesAutoLoader', () => { it('should insert the correct imports for non-ssr', async () => { - const plugin = rscRoutesAutoLoader() - if (typeof plugin.transform !== 'function') { - return - } - - // Calling `bind` to please TS - // See https://stackoverflow.com/a/70463512/88106 - const id = path.join(process.env.RWJS_CWD!, 'web', 'src', 'Routes.tsx') - const output = await plugin.transform.bind({})( + const output = await pluginTransform( `import { jsx, jsxs } from "react/jsx-runtime"; import { Router, Route, Set } from "@redwoodjs/router"; import NavigationLayout from "./layouts/NavigationLayout/NavigationLayout"; @@ -89,7 +101,7 @@ describe('rscRoutesAutoLoader', () => { export default Routes;`, normalizePath(id), // Passing undefined here to explicitly demonstrate that we're not passing { ssr: true } - undefined + undefined, ) // What we are interested in seeing here is: @@ -170,15 +182,7 @@ describe('rscRoutesAutoLoader', () => { }) it('should insert the correct imports for ssr', async () => { - const plugin = rscRoutesAutoLoader() - if (typeof plugin.transform !== 'function') { - return - } - - // Calling `bind` to please TS - // See https://stackoverflow.com/a/70463512/88106 - const id = path.join(process.env.RWJS_CWD!, 'web', 'src', 'Routes.tsx') - const output = await plugin.transform.bind({})( + const output = await pluginTransform( `import { jsx, jsxs } from "react/jsx-runtime"; import { Router, Route, Set } from "@redwoodjs/router"; import NavigationLayout from "./layouts/NavigationLayout/NavigationLayout"; @@ -205,7 +209,7 @@ describe('rscRoutesAutoLoader', () => { }; export default Routes;`, normalizePath(id), - { ssr: true } + { ssr: true }, ) // What we are interested in seeing here is: @@ -287,18 +291,11 @@ describe('rscRoutesAutoLoader', () => { }) it('should throw for duplicate page import names', async () => { - (processPagesDir as Mock).mockReturnValue(pagesWithDuplicate) + vi.mocked(processPagesDir).mockReturnValue(pagesWithDuplicate) const getOutput = async () => { - const plugin = rscRoutesAutoLoader() - if (typeof plugin.transform !== 'function') { - return - } - - // Calling `bind` to please TS - // See https://stackoverflow.com/a/70463512/88106 - const id = path.join(process.env.RWJS_CWD!, 'web', 'src', 'Routes.tsx') - const output = await plugin.transform.bind({})( + const pluginTransform = getPluginTransform() + const output = await pluginTransform( `import { jsx, jsxs } from "react/jsx-runtime"; import { Router, Route, Set } from "@redwoodjs/router"; import NavigationLayout from "./layouts/NavigationLayout/NavigationLayout"; @@ -331,20 +328,12 @@ describe('rscRoutesAutoLoader', () => { } expect(getOutput).rejects.toThrowErrorMatchingInlineSnapshot( - "[Error: Unable to find only a single file ending in 'Page.{js,jsx,ts,tsx}' in the following page directories: 'AboutPage']" + "[Error: Unable to find only a single file ending in 'Page.{js,jsx,ts,tsx}' in the following page directories: 'AboutPage']", ) }) it('should handle existing imports in the routes file', async () => { - const plugin = rscRoutesAutoLoader() - if (typeof plugin.transform !== 'function') { - return - } - - // Calling `bind` to please TS - // See https://stackoverflow.com/a/70463512/88106 - const id = path.join(process.env.RWJS_CWD!, 'web', 'src', 'Routes.tsx') - const output = await plugin.transform.bind({})( + const output = await pluginTransform( `import { jsx, jsxs } from "react/jsx-runtime"; import { Router, Route, Set } from "@redwoodjs/router"; import NavigationLayout from "./layouts/NavigationLayout/NavigationLayout"; @@ -372,14 +361,13 @@ describe('rscRoutesAutoLoader', () => { }; export default Routes;`, normalizePath(id), - undefined + undefined, ) // We don't have to add calls for the AboutPage as it was already imported expect(output).not.toContain('renderFromDist("AboutPage")') expect(output).not.toContain('renderFromRscServer("AboutPage")') }) - }) const pages = [ @@ -388,60 +376,70 @@ const pages = [ constName: 'AboutPage', importPath: '/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage', path: '/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage.tsx', - importStatement: "const AboutPage = { name: 'AboutPage', loader: import('/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage') }" + importStatement: + "const AboutPage = { name: 'AboutPage', loader: import('/Users/mojombo/rw-app/web/src/pages/AboutPage/AboutPage') }", }, { importName: 'FatalErrorPage', constName: 'FatalErrorPage', - importPath: '/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage', + importPath: + '/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage', path: '/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage.tsx', - importStatement: "const FatalErrorPage = { name: 'FatalErrorPage', loader: import('/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage') }" + importStatement: + "const FatalErrorPage = { name: 'FatalErrorPage', loader: import('/Users/mojombo/rw-app/web/src/pages/FatalErrorPage/FatalErrorPage') }", }, { importName: 'HomePage', constName: 'HomePage', importPath: '/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage', path: '/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage.tsx', - importStatement: "const HomePage = { name: 'HomePage', loader: import('/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage') }" + importStatement: + "const HomePage = { name: 'HomePage', loader: import('/Users/mojombo/rw-app/web/src/pages/HomePage/HomePage') }", }, { importName: 'NotFoundPage', constName: 'NotFoundPage', importPath: '/Users/mojombo/rw-app/web/src/pages/NotFoundPage/NotFoundPage', path: '/Users/mojombo/rw-app/web/src/pages/NotFoundPage/NotFoundPage.tsx', - importStatement: "const NotFoundPage = { name: 'NotFoundPage', loader: import('/Users/mojombo/rw-app/web/src/pages/NotFoundPage/NotFoundPage') }" + importStatement: + "const NotFoundPage = { name: 'NotFoundPage', loader: import('/Users/mojombo/rw-app/web/src/pages/NotFoundPage/NotFoundPage') }", }, { importName: 'EmptyUserEditEmptyUserPage', constName: 'EmptyUserEditEmptyUserPage', - importPath: '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EditEmptyUserPage/EditEmptyUserPage', + importPath: + '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EditEmptyUserPage/EditEmptyUserPage', path: '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EditEmptyUserPage/EditEmptyUserPage.tsx', - importStatement: "const EmptyUserEditEmptyUserPage = { name: 'EmptyUserEditEmptyUserPage', loader: import('/Users/mojombo/rw-app/web/src/pages/EmptyUser/EditEmptyUserPage/EditEmptyUserPage') }" + importStatement: + "const EmptyUserEditEmptyUserPage = { name: 'EmptyUserEditEmptyUserPage', loader: import('/Users/mojombo/rw-app/web/src/pages/EmptyUser/EditEmptyUserPage/EditEmptyUserPage') }", }, { importName: 'EmptyUserEmptyUserPage', constName: 'EmptyUserEmptyUserPage', - importPath: '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUserPage/EmptyUserPage', + importPath: + '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUserPage/EmptyUserPage', path: '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUserPage/EmptyUserPage.tsx', - importStatement: "const EmptyUserEmptyUserPage = { name: 'EmptyUserEmptyUserPage', loader: import('/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUserPage/EmptyUserPage') }" + importStatement: + "const EmptyUserEmptyUserPage = { name: 'EmptyUserEmptyUserPage', loader: import('/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUserPage/EmptyUserPage') }", }, { importName: 'EmptyUserEmptyUsersPage', constName: 'EmptyUserEmptyUsersPage', - importPath: '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUsersPage/EmptyUsersPage', + importPath: + '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUsersPage/EmptyUsersPage', path: '/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUsersPage/EmptyUsersPage.tsx', - importStatement: "const EmptyUserEmptyUsersPage = { name: 'EmptyUserEmptyUsersPage', loader: import('/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUsersPage/EmptyUsersPage') }" + importStatement: + "const EmptyUserEmptyUsersPage = { name: 'EmptyUserEmptyUsersPage', loader: import('/Users/mojombo/rw-app/web/src/pages/EmptyUser/EmptyUsersPage/EmptyUsersPage') }", }, { importName: 'EmptyUserNewEmptyUserPage', constName: 'EmptyUserNewEmptyUserPage', - importPath: '/Users/mojombo/rw-app/web/src/pages/EmptyUser/NewEmptyUserPage/NewEmptyUserPage', + importPath: + '/Users/mojombo/rw-app/web/src/pages/EmptyUser/NewEmptyUserPage/NewEmptyUserPage', path: '/Users/mojombo/rw-app/web/src/pages/EmptyUser/NewEmptyUserPage/NewEmptyUserPage.tsx', - importStatement: "const EmptyUserNewEmptyUserPage = { name: 'EmptyUserNewEmptyUserPage', loader: import('/Users/mojombo/rw-app/web/src/pages/EmptyUser/NewEmptyUserPage/NewEmptyUserPage') }" + importStatement: + "const EmptyUserNewEmptyUserPage = { name: 'EmptyUserNewEmptyUserPage', loader: import('/Users/mojombo/rw-app/web/src/pages/EmptyUser/NewEmptyUserPage/NewEmptyUserPage') }", }, ] -const pagesWithDuplicate = [ - ...pages, - pages[0] -] +const pagesWithDuplicate = [...pages, pages[0]] diff --git a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.mts b/packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.ts similarity index 93% rename from packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.mts rename to packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.ts index 18f931821aaa..65db8f607e31 100644 --- a/packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.mts +++ b/packages/vite/src/plugins/__tests__/vite-plugin-rsc-transform-client.test.ts @@ -1,6 +1,7 @@ import path from 'node:path' import { vol } from 'memfs' +import type { TransformPluginContext } from 'rollup' import { normalizePath } from 'vite' import { afterAll, @@ -12,21 +13,31 @@ import { afterEach, } from 'vitest' -import { rscTransformUseClientPlugin } from '../vite-plugin-rsc-transform-client' +import { rscTransformUseClientPlugin } from '../vite-plugin-rsc-transform-client.js' vi.mock('fs', async () => ({ default: (await import('memfs')).fs })) const RWJS_CWD = process.env.RWJS_CWD +const TEST_RWJS_CWD = '/Users/tobbe/rw-app/' +process.env.RWJS_CWD = TEST_RWJS_CWD + +function getPluginTransform(clientEntryFiles: Record) { + const plugin = rscTransformUseClientPlugin(clientEntryFiles) + + if (typeof plugin.transform !== 'function') { + expect.fail('Expected plugin to have a transform function') + } + + // Calling `bind` to please TS + // See https://stackoverflow.com/a/70463512/88106 + // Typecasting because we're only going to call transform, and we don't need + // anything provided by the context. + return plugin.transform.bind({} as TransformPluginContext) +} beforeAll(() => { // Add a toml entry for getPaths et al. - process.env.RWJS_CWD = '/Users/tobbe/rw-app/' - vol.fromJSON( - { - 'redwood.toml': '', - }, - process.env.RWJS_CWD, - ) + vol.fromJSON({ 'redwood.toml': '' }, TEST_RWJS_CWD) }) afterAll(() => { @@ -41,7 +52,7 @@ describe('rscRoutesAutoLoader', () => { it('should handle CJS modules with exports.Link = ...', async () => { const id = normalizePath( path.join( - process.env.RWJS_CWD || '', + TEST_RWJS_CWD, 'node_modules', '@redwoodjs', 'router', @@ -50,17 +61,7 @@ describe('rscRoutesAutoLoader', () => { ), ) - const plugin = rscTransformUseClientPlugin({ - 'rsc-link.js-13': id, - }) - - if (typeof plugin.transform !== 'function') { - expect.fail('Expected plugin to have a transform function') - } - - // Calling `bind` to please TS - // See https://stackoverflow.com/a/70463512/88106 - const output = await plugin.transform.bind({})( + const output = await getPluginTransform({ 'rsc-link.js-13': id })( `"use strict"; 'use client'; @@ -119,7 +120,7 @@ describe('rscRoutesAutoLoader', () => { it('should handle CJS modules with module.exports = { ErrorIcon, ToastBar, ... }', async () => { const id = normalizePath( path.join( - process.env.RWJS_CWD || '', + TEST_RWJS_CWD, 'node_modules', 'react-hot-toast', 'dist', @@ -127,17 +128,7 @@ describe('rscRoutesAutoLoader', () => { ), ) - const plugin = rscTransformUseClientPlugin({ - 'rsc-index.js-15': id, - }) - - if (typeof plugin.transform !== 'function') { - expect.fail('Expected plugin to have a transform function') - } - - // Calling `bind` to please TS - // See https://stackoverflow.com/a/70463512/88106 - const output = await plugin.transform.bind({})( + const output = await getPluginTransform({ 'rsc-index.js-15': id })( `"use client"; "use strict";var Y=Object.create;var E=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var K=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty; var ee=(e,t)=>{for(var o in t)E(e,o,{get:t[o],enumerable:!0})},j=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of G(t))!Z.call(e,r)&&r!==o&&E(e,r,{get:()=>t[r],enumerable:!(s=q(t,r))||s.enumerable}); diff --git a/packages/vite/tsconfig.build.json b/packages/vite/tsconfig.build.json new file mode 100644 index 000000000000..969b8aca80b8 --- /dev/null +++ b/packages/vite/tsconfig.build.json @@ -0,0 +1,18 @@ +{ + "extends": "../../tsconfig.compilerOption.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "dist", + "moduleResolution": "NodeNext", + "module": "NodeNext" + }, + "include": ["src/**/*", "./ambient.d.ts", "./modules.d.ts"], + "references": [ + { "path": "../cookie-jar" }, + { "path": "../internal" }, + { "path": "../project-config" }, + { "path": "../router/tsconfig.build.json" }, + { "path": "../server-store" }, + { "path": "../web/tsconfig.build.json" } + ] +} diff --git a/packages/vite/tsconfig.json b/packages/vite/tsconfig.json index 969b8aca80b8..dff8d18fad00 100644 --- a/packages/vite/tsconfig.json +++ b/packages/vite/tsconfig.json @@ -1,14 +1,16 @@ { "extends": "../../tsconfig.compilerOption.json", "compilerOptions": { - "rootDir": "src", - "outDir": "dist", + "isolatedModules": true, "moduleResolution": "NodeNext", - "module": "NodeNext" + "module": "NodeNext", + "outDir": "dist" }, - "include": ["src/**/*", "./ambient.d.ts", "./modules.d.ts"], + "include": ["."], + "exclude": ["dist", "node_modules", "**/__mocks__", "**/__fixtures__"], "references": [ { "path": "../cookie-jar" }, + { "path": "../framework-tools" }, { "path": "../internal" }, { "path": "../project-config" }, { "path": "../router/tsconfig.build.json" },