Skip to content

Conversation

@jchartrand
Copy link
Contributor

Ran into various problems when trying to enable prod build:

  • on first attempt, 'payload build' step was loading the payload
    config file, and that config file in turn loaded the queue.server.ts file, which initialized
    a couple of bullmq queues, which in turn tried to make a connection to redis. Because redis
    isn't running during the build, the call fails and so too therefore did the build.
  • So, made the queue initialization lazy, only loading the queue when first
    used at the time of mailing. The build then completed, but when trying to run the whole thing,
    the start script couldn't find the dist/server.js
  • Turns out the npm build target didn't include the tsc compile step, which compiles that
    server.js (and 98 other files) to the dist directory.
  • so added in a build-server step to invoke tsc
  • that broke the build because there were a whole lot of typescript errors
  • discovered that the dev build had worked because it was set to use scw instead of tsc. scw
    does no typechecking (so doesn't throw type errors)
  • so, switched the tsc to scw which allowed the build:server step to finish
  • that introduced errors because seemingly 'payload build' also uses @scw/core and ts-node under the hood
    but an older version of both
  • So, pinned @swc/core to 1.3.75 and ts-node to 10.9.1 which got the 'payload build' step compiling
  • and now it all seems to be working
  • along the way, also changed all pnpm calls to use yarn so as to follow the examples in the payload docs.
  • in the end, though, it doesn't seem to have made much difference with image size, and indeed this post in the payload repo pretty much says wait for version 3.0 of payload:
  • Payload size is big payloadcms/payload#332
  • It sounds, however, like version 3 of payload is likely so different from 1.0 (e.g., moving to nextjs) as to make an upgrade too difficult to be practical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant