fix(migrator): use tsx as runner instead of hook to fix Node.js v22 ESM interop
NODE_OPTIONS="--import tsx/esm" registers tsx as a hook, which exposes the tsx@4.21.0 + Node.js v22 importSyncForRequire bug (named export not found). Running tsx directly as the process runner handles TypeScript module loading at a higher level, avoiding the CJS/ESM interop conflict. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
cff1baa871
commit
a26a9c05ae
1 changed files with 4 additions and 6 deletions
|
|
@ -1,8 +1,7 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
# Migrator image — runs `payload migrate` / `payload migrate:create`
|
||||
# Requires node:22 for pnpm 11 (node:sqlite).
|
||||
# tsx 4.x ESM loader must be preloaded via NODE_OPTIONS so bare
|
||||
# specifiers (.ts extensions) resolve before any module is imported.
|
||||
# tsx is used as the RUNNER (not as a hook) to avoid the Node.js v22
|
||||
# importSyncForRequire bug that breaks --import tsx/esm hook mode.
|
||||
|
||||
FROM node:22-alpine AS base
|
||||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||||
|
|
@ -13,6 +12,5 @@ RUN pnpm install --frozen-lockfile
|
|||
|
||||
COPY . .
|
||||
|
||||
ENV NODE_OPTIONS="--import tsx/esm"
|
||||
ENTRYPOINT ["pnpm", "payload"]
|
||||
CMD ["migrate"]
|
||||
ENTRYPOINT ["pnpm", "exec", "tsx"]
|
||||
CMD ["node_modules/payload/bin.js", "migrate"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue