redwood
redwood copied to clipboard
`rw build --side=api` ignores redwood.toml's [api] path configuration
Description
The command, yarn rw build --side=api
breaks on prisma schema loading when using a custom path for the API project. yarn rw build api
also fails the same way.
Reproduction Steps
- create a fresh redwood project with
yarn create redwood-app
- create a new directory in the root of the project,
apps
- Move the
api
directory created by redwood into the newapps
directory - Edit
redwood.toml
and set thepath
config option under[api]
to"./apps/api"
- Run
yarn rw build --side=api
Expected Output
Build succeeds
Actual Output
▶ yarn rw build --side=api
Skipping database and Prisma client generation, no `schema.prisma` file found: `/Users/jdoe/code/example/api/db/schema.prisma`
✖ Generating Prisma Client...
→ The "file" argument must be of type string. Received undefined
Verifying graphql schema...
Building API...
Command failed with ERR_INVALID_ARG_TYPE:
The "file" argument must be of type string. Received undefined
I'm also seeing this error when running yarn rw g sdl <Model>
without a root ./web
folder. redwood.toml
's [web]
path is set to the correct folder for the web project
▶ yarn rw g sdl Part -f
yarn run v1.22.19
$ <redacted>/node_modules/.bin/rw g sdl Part -f
✔ Generating SDL files...
✔ Successfully wrote file `./api/src/graphql/parts.sdl.ts`
✔ Successfully wrote file `./api/src/services/parts/parts.scen
arios.ts`
✔ Successfully wrote file `./api/src/services/parts/parts.test
.ts`
✔ Successfully wrote file `./api/src/services/parts/parts.ts`
✖ Generating types ...
→ The "path" argument must be of type string or an instance of
…
The "path" argument must be of type string or an instance of Buffer or URL. Received null
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
It seems to me that somewhere in the build tools with have the api path hardcoded, OR maybe the toml setting isn't being picked up.
@dthyresson ok to pick up?
Verbose output:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received null
at Object.openSync (node:fs:577:10)
at Object.readFileSync (node:fs:453:35)
at fileToAst (/Users/jdoe/code/redacted/node_modules/@redwoodjs/internal/dist/ast.js:36:28)
at generateTypeDefRouterRoutes (/Users/jdoe/code/redacted/node_modules/@redwoodjs/internal/dist/generate/typeDefinitions.js:177:34)
at generateTypeDefs (/Users/jdoe/code/redacted/node_modules/@redwoodjs/internal/dist/generate/typeDefinitions.js:64:148)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async generate (/Users/jdoe/code/redacted/node_modules/@redwoodjs/internal/dist/generate/generate.js:26:25)
at async run (/Users/jdoe/code/redacted/node_modules/@redwoodjs/internal/dist/generate/generate.js:37:17) {
code: 'ERR_INVALID_ARG_TYPE'
}
Thanks @mmmeff - I suspect this is one of those features we had originally planned - but then fell off our radar!
For now I don't believe Redwood supports customising the path to web and api folders (although I can totally understand why you would think we do). We'll look to fix this!
@mmmeff - could I ask that you give us an idea of why this feature would be important to you? This is definitely a bug/missing feature - but it would be very helpful to understand your reasoning behind this.
- It's listed as a feature/option in the Redwood.toml docs but does nothing
- I want to control the folder structure of my codebase. Specifically, I want to group both API and web under a common
./apps
directory - I only want to use Redwood's API and have set up a Next.js project in place of the
web
project.
For anyone else who runs into this, I've worked around it in the meantime by creating a few dummy files in a web
directory.
Create these files and the path exceptions should stop throwing in Redwood 2.x:
- web/src/App.ts
- web/src/index.html
- web/src/Routes.ts
They can all be empty
i have the same error
#27 [api_build 2/2] RUN yarn rw build api
#27 11.13 rw build [side..]
#27 11.13
#27 11.13 Build for production
#27 11.13
#27 11.13 Positionals:
#27 11.13 side Which side(s) to build
#27 11.13 [array] [choices: "web", "api"] [default: ["web","api"]]
#27 11.13
#27 11.13 Options:
#27 11.13 --help Show help [boolean]
#27 11.13 --version Show version number [boolean]
#27 11.13 --cwd Working directory to use (where `redwood.toml` is
#27 11.13 located.)
#27 11.13 --stats Use Webpack Bundle Analyzer (https://github.com/we
#27 11.13 bpack-contrib/webpack-bundle-analyzer)
#27 11.13 [boolean] [default: false]
#27 11.13 -v, --verbose Print more [boolean] [default: false]
#27 11.13 --prerender Prerender after building web
#27 11.13 [boolean] [default: true]
#27 11.13 --prisma, --db Generate the Prisma client[boolean] [default: true]
#27 11.13 --performance, --perf Measure build performance[boolean] [default: false]
#27 11.13
#27 11.13 Also see the Redwood CLI Reference
#27 11.13 ([https://redwoodjs.com/docs/cli-commands#build)](https://redwoodjs.com/docs/cli-commands#build%E2%80%8B))
#27 11.13
#27 11.15 TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received null
#27 11.15 at Object.openSync (node:fs:586:10)
#27 11.15 at Object.readFileSync (node:fs:462:35)
#27 11.15 at DefaultHost.readFileSync (/app/node_modules/@redwoodjs/structure/dist/hosts.js:35:15)
#27 11.15 at RWRouter.get text (/app/node_modules/@redwoodjs/structure/dist/ide.js:241:22)
#27 11.15 at Object.getterCommon (/app/node_modules/lazy-get-decorator/common.js:23:32)
#27 11.15 at RWRouter.get (/app/node_modules/lazy-get-decorator/legacy.js:19:29)
#27 11.15 at RWRouter.get sf (/app/node_modules/@redwoodjs/structure/dist/ide.js:253:21)
#27 11.15 at Object.getterCommon (/app/node_modules/lazy-get-decorator/common.js:23:32)
#27 11.15 at RWRouter.get (/app/node_modules/lazy-get-decorator/legacy.js:19:29)
#27 11.15 at RWRouter.get jsxNode (/app/node_modules/@redwoodjs/structure/dist/model/RWRouter.js:86:48) {
#27 11.15 code: 'ERR_INVALID_ARG_TYPE'
#27 11.15 }
#27 ERROR: executor failed running [/bin/sh -c yarn rw build api]: exit code: 1
------
> [api_build 2/2] RUN yarn rw build api:
#27 11.15 at DefaultHost.readFileSync (/app/node_modules/@redwoodjs/structure/dist/hosts.js:35:15)
#27 11.15 at RWRouter.get text (/app/node_modules/@redwoodjs/structure/dist/ide.js:241:22)
#27 11.15 at Object.getterCommon (/app/node_modules/lazy-get-decorator/common.js:23:32)
#27 11.15 at RWRouter.get (/app/node_modules/lazy-get-decorator/legacy.js:19:29)
#27 11.15 at RWRouter.get sf (/app/node_modules/@redwoodjs/structure/dist/ide.js:253:21)
#27 11.15 at Object.getterCommon (/app/node_modules/lazy-get-decorator/common.js:23:32)
#27 11.15 at RWRouter.get (/app/node_modules/lazy-get-decorator/legacy.js:19:29)
#27 11.15 at RWRouter.get jsxNode (/app/node_modules/@redwoodjs/structure/dist/model/RWRouter.js:86:48) {
#27 11.15 code: 'ERR_INVALID_ARG_TYPE'
#27 11.15 }
Hi @finalight thanks for letting us know. I have reproduced the issue and working on a fix. Thanks for your patiences while we resolve and also from using RedwoodJS.