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: {
|
plugins: {
|
||||||
js: jsPlugin,
|
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
|
pnpm install --frozen-lockfile --ignore-scripts
|
||||||
|
|
||||||
# NOTICE:
|
# NOTICE:
|
||||||
# Force a fresh build of drizzle-migration and assert that
|
# The Rolldown adapter of unplugin-drizzle-orm-migrations intermittently left
|
||||||
# unplugin-drizzle-orm-migrations actually replaced the `virtual:drizzle-migrations.sql`
|
# the virtual import in the output on Railway. The Rollup adapter is compatible
|
||||||
# import. Without this guard a layer built when the rolldown plugin silently
|
# with tsdown and inlines the migration data. Import the output to verify the
|
||||||
# no-op'd (intermittently observed on Railway with tsdown 0.21.9 + rolldown
|
# runtime contract. Do not check a generated chunk name because adapters use
|
||||||
# 1.0.0-rc.16) ships a dist/index.mjs that re-exports the literal `virtual:`
|
# different output layouts.
|
||||||
# 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.
|
|
||||||
RUN rm -rf server/packages/drizzle-migration/dist \
|
RUN rm -rf server/packages/drizzle-migration/dist \
|
||||||
&& pnpm -F @proj-airi/drizzle-migration run build \
|
&& pnpm -F @proj-airi/drizzle-migration run build \
|
||||||
&& if grep -qE "from ['\"]virtual:" server/packages/drizzle-migration/dist/index.mjs; then \
|
&& 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') })"
|
||||||
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
|
|
||||||
|
|
||||||
RUN pnpm -F @proj-airi/server-sdk-shared run build
|
RUN pnpm -F @proj-airi/server-sdk-shared run build
|
||||||
RUN pnpm -F @proj-airi/api-server 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
|
RUN pnpm install --frozen-lockfile --ignore-scripts
|
||||||
|
|
||||||
# NOTICE:
|
# NOTICE:
|
||||||
# Force a fresh build of drizzle-migration and assert that
|
# The Rolldown adapter of unplugin-drizzle-orm-migrations intermittently left
|
||||||
# unplugin-drizzle-orm-migrations actually replaced the `virtual:drizzle-migrations.sql`
|
# the virtual import in the output on Railway. The Rollup adapter is compatible
|
||||||
# import. Without this guard a layer built when the rolldown plugin silently
|
# with tsdown and inlines the migration data. Import the output to verify the
|
||||||
# no-op'd (intermittently observed on Railway with tsdown 0.21.9 + rolldown
|
# runtime contract. Do not check a generated chunk name because adapters use
|
||||||
# 1.0.0-rc.16) ships a dist/index.mjs that re-exports the literal `virtual:`
|
# different output layouts.
|
||||||
# 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.
|
|
||||||
RUN rm -rf server/packages/drizzle-migration/dist \
|
RUN rm -rf server/packages/drizzle-migration/dist \
|
||||||
&& pnpm -F @proj-airi/drizzle-migration run build \
|
&& pnpm -F @proj-airi/drizzle-migration run build \
|
||||||
&& if grep -qE "from ['\"]virtual:" server/packages/drizzle-migration/dist/index.mjs; then \
|
&& 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') })"
|
||||||
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
|
|
||||||
|
|
||||||
RUN pnpm -F @proj-airi/server-sdk-shared run build
|
RUN pnpm -F @proj-airi/server-sdk-shared run build
|
||||||
RUN pnpm -F @proj-airi/api-server 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'
|
import { defineConfig } from 'tsdown'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user