-
Notifications
You must be signed in to change notification settings - Fork 990
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug?]: Build Error "[plugin:vite:esbuild] Transform failed" when Router Page placed in root "web/pages" directory #9658
Comments
Hi @swrichards Thanks much for the excellent details and example app repo! This really helps us triage issues. I used GitPod to launch your repo and did reproduce: Using "@redwoodjs/core": "6.5.1" I'll have to check in with the rest of the Core Team and Clerk to help track down what might be going on. |
@swrichards I just ad a glance at the code snippet in VSCode and it redlined:
Notice the I think that's the root cause of the error, but just a guess at the moment. But something to start investigating. |
Also, easily reproduces if Error: Command failed with exit code 1: node /workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/vite/bins/rw-vite-build.mjs --webDir="/workspace/redwoodjs-clerk-test/web"
[vite:esbuild] Transform failed with 1 error:
/workspace/redwoodjs-clerk-test/web/src/Routes.tsx:2:6: ERROR: Expected identifier but found "="
file: /workspace/redwoodjs-clerk-test/web/src/Routes.tsx:2:6
Expected identifier but found "="
1 | import { lazy } from "react";
2 | const = {
| ^
3 | name: "",
4 | prerenderLoader: name => ({
/workspace/redwoodjs-clerk-test/node_modules/vite/node_modules/esbuild/lib/main.js:1649
let error = new Error(`${text}${summary}`);
^
Error: Transform failed with 1 error:
/workspace/redwoodjs-clerk-test/web/src/Routes.tsx:2:6: ERROR: Expected identifier but found "="
at failureErrorWithLog (/workspace/redwoodjs-clerk-test/node_modules/vite/node_modules/esbuild/lib/main.js:1649:15)
at /workspace/redwoodjs-clerk-test/node_modules/vite/node_modules/esbuild/lib/main.js:847:29
at responseCallbacks.<computed> (/workspace/redwoodjs-clerk-test/node_modules/vite/node_modules/esbuild/lib/main.js:703:9)
at handleIncomingPacket (/workspace/redwoodjs-clerk-test/node_modules/vite/node_modules/esbuild/lib/main.js:762:9)
at Socket.readFromStdout (/workspace/redwoodjs-clerk-test/node_modules/vite/node_modules/esbuild/lib/main.js:679:7)
at Socket.emit (node:events:514:28)
at addChunk (node:internal/streams/readable:376:12)
at readableAddChunk (node:internal/streams/readable:349:9)
at Readable.push (node:internal/streams/readable:286:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
errors: [
{
detail: undefined,
id: '',
location: {
column: 6,
file: '/workspace/redwoodjs-clerk-test/web/src/Routes.tsx',
length: 1,
line: 2,
lineText: 'const = {',
namespace: '',
suggestion: ''
},
notes: [],
pluginName: '',
text: 'Expected identifier but found "="'
}
],
warnings: [],
frame: '\n' +
'Expected identifier but found "="\n' +
'1 | import { lazy } from "react";\n' +
'2 | const = {\n' +
' | ^\n' +
'3 | name: "",\n' +
'4 | prerenderLoader: name => ({\n',
loc: {
column: 6,
file: '/workspace/redwoodjs-clerk-test/web/src/Routes.tsx',
length: 1,
line: 2,
lineText: 'const = {',
namespace: '',
suggestion: ''
},
code: 'PLUGIN_ERROR',
plugin: 'vite:esbuild',
hook: 'transform',
id: '/workspace/redwoodjs-clerk-test/web/src/Routes.tsx',
watchFiles: [
'/workspace/redwoodjs-clerk-test/web/src/index.html',
'\x00vite/modulepreload-polyfill',
'/workspace/redwoodjs-clerk-test/web/src/entry.client.tsx',
'/workspace/redwoodjs-clerk-test/node_modules/react/jsx-runtime.js',
'/workspace/redwoodjs-clerk-test/node_modules/react-dom/client.js',
'/workspace/redwoodjs-clerk-test/web/src/App.tsx',
'/workspace/redwoodjs-clerk-test/node_modules/react/cjs/react-jsx-runtime.production.min.js',
'/workspace/redwoodjs-clerk-test/node_modules/react-dom/index.js',
'/workspace/redwoodjs-clerk-test/node_modules/react-dom/cjs/react-dom.production.min.js',
'/workspace/redwoodjs-clerk-test/web/package.json',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/index.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/apollo/index.js',
'/workspace/redwoodjs-clerk-test/web/src/pages/FatalErrorPage/FatalErrorPage.tsx',
'/workspace/redwoodjs-clerk-test/web/src/Routes.tsx',
'/workspace/redwoodjs-clerk-test/web/src/auth.tsx',
'/workspace/redwoodjs-clerk-test/web/src/index.css',
'/workspace/redwoodjs-clerk-test/node_modules/react/index.js',
'/workspace/redwoodjs-clerk-test/node_modules/@babel/runtime-corejs3/core-js/object/define-property.js',
'/workspace/redwoodjs-clerk-test/node_modules/@babel/runtime-corejs3/core-js/instance/for-each.js',
'/workspace/redwoodjs-clerk-test/node_modules/@babel/runtime-corejs3/core-js/object/keys.js',
'/workspace/redwoodjs-clerk-test/node_modules/@babel/runtime-corejs3/helpers/interopRequireDefault.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/global.web-auto-imports.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/config.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/assetImports.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/components/FatalErrorBoundary.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/components/FetchConfigProvider.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/components/GraphQLHooksProvider.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/components/CellCacheContext.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/components/createCell.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/graphql.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/components/RedwoodProvider.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/components/MetaTags.js',
'/workspace/redwoodjs-clerk-test/node_modules/react-helmet-async/lib/index.module.js',
'/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/web/dist/apollo/index.js',
'/workspace/redwoodjs-clerk-test/node_modules/react/cjs/react.production.min.js'
]
}
Node.js v20.9.0
vite v4.5.1 building for production...
transforming...
✓ 5 modules transformed.
✓ built in 363ms
at makeError (/workspace/redwoodjs-clerk-test/node_modules/execa/lib/error.js:60:11)
at handlePromise (/workspace/redwoodjs-clerk-test/node_modules/execa/index.js:118:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async _Task.task [as taskFn] (/workspace/redwoodjs-clerk-test/node_modules/@redwoodjs/cli/dist/commands/buildHandler.js:117:9)
at async _Task.run (/workspace/redwoodjs-clerk-test/node_modules/listr2/dist/index.cjs:2049:11) |
@dac09 Could you take a quick look at this issue? I'm not 100% sure it's Clerk related or not. I removed all Clerk packages and removed auth (in a GitPod build) and the error still presented itself on build. If it is auth/Clerk, then I can help diagnose and work with them, but just want a second look from a vite PoV. Thanks! |
Thanks for the prompt response @dthyresson. Just to clarify the context of my initial issue: the repo I shared contains no alterations to the generated code from |
@swrichards I just did the following steps:
When I run When I start the dev server: I get a different error: I assume when you are in dev you are using proper, valid api keys? Just checking. |
Note, my package versions appear to be same as yours:
|
@dthyresson Following the steps you've just outlined, I am indeed able to run both
The error appears as soon as I proceed to the next step in the docs, that is to create
With this file present, the error appears in both EDIT: The package versions match up too:
|
Wow! @swrichards That reproduces! If I don't have my page inside the folder:
I get the error:
I always create pages via
So I would never have thought to have the page elsewhere. And I was able to reproduce with Clerk at all:
And I get the error. Thanks for noticing that. Now with a reproducible case, I can direct the team to the router or site to see what's the case. And to fix that documentation as it is incorrect. |
@dthyresson thanks for clarifying, looks like it's a general issue unrelated to Clerk, but also perfectly avoidable using the proper paths / page scaffolding tool. I'll move on accordingly 👍 . |
@Tobbe This turned out not to be an auth issue, but a more general page/routing issue when a page is stored in just the I am not certain if this is a routing or a vite issue, but assigning you to delegate. Thanks. |
Thanks again for finding this. I just PR'd small docs fix so hopefully this won't trip people up in future: |
I also believe there is a small typo in the post-setup notes for Clerk: #9661. |
See issue #9658 In the issue above, @swrichards found that if one places a Page.tsx in just the `pages` directory (ie, not /pages/PageName/PageName.tsx` and routes to it, one gets the following error building web / starting dev: ![image](https://github.com/redwoodjs/redwood/assets/1051633/2246778f-424e-44f7-9e91-7c4ed10b2b89) The found this while following the Clerk auth documentation -- and that said to make the HomePage in just the `pages` directory: ![image](https://github.com/redwoodjs/redwood/assets/1051633/83bca047-0f31-4340-8ad3-bcf03000143f) While this perhaps worked in the past, it doesn't seem to with the new site builds. This PR updates the documentation to: * say to use the page generator * corrects filepath * removes outdated screenshot of old Clerk widget The issue of the error will be assigned and resolved in a future PR.
See issue #9658 In the issue above, @swrichards found that if one places a Page.tsx in just the `pages` directory (ie, not /pages/PageName/PageName.tsx` and routes to it, one gets the following error building web / starting dev: ![image](https://github.com/redwoodjs/redwood/assets/1051633/2246778f-424e-44f7-9e91-7c4ed10b2b89) The found this while following the Clerk auth documentation -- and that said to make the HomePage in just the `pages` directory: ![image](https://github.com/redwoodjs/redwood/assets/1051633/83bca047-0f31-4340-8ad3-bcf03000143f) While this perhaps worked in the past, it doesn't seem to with the new site builds. This PR updates the documentation to: * say to use the page generator * corrects filepath * removes outdated screenshot of old Clerk widget The issue of the error will be assigned and resolved in a future PR.
Sorry I didn't notice this one sooner. The notification got lost in the sea of other GH notifications... Redwood's automatic lazy loading of pages only works with pages that follow the That said, maybe error handling/messaging could be better here, but feels like pretty low priority right now. |
DT Edits:
See comments below for a reproducible case; does not require any Clerk or auth setup.
--
What's not working?
Following the steps outlined at https://redwoodjs.com/docs/auth/clerk I received the following error upon running
yarn rw dev
:How do we reproduce the bug?
nvm
:nvm use
yarn install
.env
with dummy values:yarn rw dev
What's your environment? (If it applies)
System: OS: macOS 13.6.2 Shell: 3.2.57 - /bin/bash Binaries: Node: 18.19.0 - /private/var/folders/s6/43kpdrt122s1y4_yt7rh8vzw0000gn/T/xfs-9da2b11b/node Yarn: 3.7.0 - /private/var/folders/s6/43kpdrt122s1y4_yt7rh8vzw0000gn/T/xfs-9da2b11b/yarn Databases: SQLite: 3.39.5 - /usr/bin/sqlite3 Browsers: Safari: 17.1.2 npmPackages: @redwoodjs/core: 6.5.1 => 6.5.1
Are you interested in working on this?
The text was updated successfully, but these errors were encountered: