fix(docker): update drizzle-migration build process to prevent virtual import issues
This commit is contained in:
@@ -9,5 +9,6 @@ export default defineConfig([
|
||||
plugins: {
|
||||
js: jsPlugin,
|
||||
},
|
||||
ignores: ['**/node_modules/**'],
|
||||
},
|
||||
])
|
||||
|
||||
@@ -17,23 +17,14 @@ RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \
|
||||
pnpm install --frozen-lockfile --ignore-scripts
|
||||
|
||||
# NOTICE:
|
||||
# Force a fresh build of drizzle-migration and assert that
|
||||
# unplugin-drizzle-orm-migrations actually replaced the `virtual:drizzle-migrations.sql`
|
||||
# import. Without this guard a layer built when the rolldown plugin silently
|
||||
# no-op'd (intermittently observed on Railway with tsdown 0.21.9 + rolldown
|
||||
# 1.0.0-rc.16) ships a dist/index.mjs that re-exports the literal `virtual:`
|
||||
# specifier, which crashes at runtime under tsx with
|
||||
# ERR_UNSUPPORTED_ESM_URL_SCHEME. `rm -rf dist` keeps this RUN's command-string
|
||||
# distinct from earlier cached variants and prevents a stale dist from masking
|
||||
# a failed transform.
|
||||
# The Rolldown adapter of unplugin-drizzle-orm-migrations intermittently left
|
||||
# the virtual import in the output on Railway. The Rollup adapter is compatible
|
||||
# with tsdown and inlines the migration data. Import the output to verify the
|
||||
# runtime contract. Do not check a generated chunk name because adapters use
|
||||
# different output layouts.
|
||||
RUN rm -rf server/packages/drizzle-migration/dist \
|
||||
&& pnpm -F @proj-airi/drizzle-migration run build \
|
||||
&& if grep -qE "from ['\"]virtual:" server/packages/drizzle-migration/dist/index.mjs; then \
|
||||
echo "ERROR: drizzle-migration dist/index.mjs still references a virtual: specifier — unplugin-drizzle-orm-migrations transform did not run." >&2; \
|
||||
cat server/packages/drizzle-migration/dist/index.mjs >&2; \
|
||||
exit 1; \
|
||||
fi \
|
||||
&& ls server/packages/drizzle-migration/dist/virtual_drizzle-migrations-*.mjs >/dev/null
|
||||
&& node --input-type=module -e "import('./server/packages/drizzle-migration/dist/index.mjs').then(({ migrations }) => { if (!Array.isArray(migrations) || migrations.length === 0) throw new Error('drizzle-migration did not export migrations') })"
|
||||
|
||||
RUN pnpm -F @proj-airi/server-sdk-shared run build
|
||||
RUN pnpm -F @proj-airi/api-server run build
|
||||
|
||||
@@ -16,23 +16,14 @@ COPY packages/server-sdk-shared packages/server-sdk-shared
|
||||
RUN pnpm install --frozen-lockfile --ignore-scripts
|
||||
|
||||
# NOTICE:
|
||||
# Force a fresh build of drizzle-migration and assert that
|
||||
# unplugin-drizzle-orm-migrations actually replaced the `virtual:drizzle-migrations.sql`
|
||||
# import. Without this guard a layer built when the rolldown plugin silently
|
||||
# no-op'd (intermittently observed on Railway with tsdown 0.21.9 + rolldown
|
||||
# 1.0.0-rc.16) ships a dist/index.mjs that re-exports the literal `virtual:`
|
||||
# specifier, which crashes at runtime under tsx with
|
||||
# ERR_UNSUPPORTED_ESM_URL_SCHEME. `rm -rf dist` keeps this RUN's command-string
|
||||
# distinct from earlier cached variants and prevents a stale dist from masking
|
||||
# a failed transform.
|
||||
# The Rolldown adapter of unplugin-drizzle-orm-migrations intermittently left
|
||||
# the virtual import in the output on Railway. The Rollup adapter is compatible
|
||||
# with tsdown and inlines the migration data. Import the output to verify the
|
||||
# runtime contract. Do not check a generated chunk name because adapters use
|
||||
# different output layouts.
|
||||
RUN rm -rf server/packages/drizzle-migration/dist \
|
||||
&& pnpm -F @proj-airi/drizzle-migration run build \
|
||||
&& if grep -qE "from ['\"]virtual:" server/packages/drizzle-migration/dist/index.mjs; then \
|
||||
echo "ERROR: drizzle-migration dist/index.mjs still references a virtual: specifier — unplugin-drizzle-orm-migrations transform did not run." >&2; \
|
||||
cat server/packages/drizzle-migration/dist/index.mjs >&2; \
|
||||
exit 1; \
|
||||
fi \
|
||||
&& ls server/packages/drizzle-migration/dist/virtual_drizzle-migrations-*.mjs >/dev/null
|
||||
&& node --input-type=module -e "import('./server/packages/drizzle-migration/dist/index.mjs').then(({ migrations }) => { if (!Array.isArray(migrations) || migrations.length === 0) throw new Error('drizzle-migration did not export migrations') })"
|
||||
|
||||
RUN pnpm -F @proj-airi/server-sdk-shared run build
|
||||
RUN pnpm -F @proj-airi/api-server run build
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import DrizzleORMMigrations from '@proj-airi/unplugin-drizzle-orm-migrations/rolldown'
|
||||
import DrizzleORMMigrations from '@proj-airi/unplugin-drizzle-orm-migrations/rollup'
|
||||
|
||||
import { defineConfig } from 'tsdown'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user