#Why am I getting generate:importmap errors, even though it's in my repo?

60 messages · Page 1 of 1 (latest)

void pasture
#

I have run generate:importmap and committed the result to my repo. It's there during deployment, so why am I getting an error about it on recent versions of payload? This seems clearly broken. (It's also true that next.js has become hostile to self-hosting, so maybe that has something to do with it?)

lusty girderBOT
void pasture
#

Even if I run it at start up, I still get the error....

#

next build --experimental-build-mode generate && payload generate:importmap && next start

#

I'm regretting choosing next.js

#

If I don't scale payload passed 1 instance, I can try to do the full build at startup

#

What I don't understand is, why has no one else seen this issue?

manic nest
void pasture
#

Fresh deletes the entire database - am I do to that on a production payload instance, every time I update the version? Seems incorrect.

#

Note: This worked fine in an older version ...

void pasture
#

Just to make it clear - this is not a problem during development. It's only a problem during deployment.

manic nest
void pasture
#

It's definitely not a schema sync thing

#

The difference is an updated package.json file, with a newer version of payload in it

#

commit before that owrks fine. commit after that gets the error. Trying to run generate:importmap in the Dockerfile, does NOT fix it.

manic nest
#

try lock your payload version so it doesn't change?

faint ingot
lament glade
#

Can you share your package json?

void pasture
void pasture
void pasture
# lament glade Can you share your package json?
FROM node:22-alpine AS base
ENV NEXT_TELEMETRY_DISABLED=1

ARG GIT_HASH
ARG NEXT_PUBLIC_PAYLOAD_URL
ARG NEXT_PUBLIC_SITE_URL
ARG PAYLOAD_PUBLIC_SERVER_URL
ARG NEXT_PUBLIC_DEVELOPER_SITE_URL
ARG PAYLOAD_SECRET
ARG ASSETS_URL

ENV NEXT_PUBLIC_PAYLOAD_URL=$NEXT_PUBLIC_PAYLOAD_URL
ENV NEXT_PUBLIC_SITE_URL=$NEXT_PUBLIC_SITE_URL
ENV PAYLOAD_PUBLIC_SERVER_URL=$PAYLOAD_PUBLIC_SERVER_URL
ENV NEXT_PUBLIC_DEVELOPER_SITE_URL=$NEXT_PUBLIC_DEVELOPER_SITE_URL
ENV PAYLOAD_SECRET=$PAYLOAD_SECRET
ENV ASSETS_URL=$ASSETS_URL

WORKDIR /app
COPY package.json pnpm-lock.yaml* ./
RUN npm i -g pnpm && pnpm i --frozen-lockfile --no-store-dir

COPY . .

ENV NODE_ENV=production
ENV BUILD_ID=$GIT_HASH
RUN pnpm run compile

# RUN rm -rf node_modules && pnpm install --prod --frozen-lockfile

# RUN addgroup --system --gid 1001 nodejs
# RUN adduser --system --uid 1001 nextjs
# RUN chown -R nextjs:nodejs /app

# USER nextjs

EXPOSE 3000
CMD ["npm", "run", "prod"]
#

It worked at least up to 3.24

#

Also, because of the very persnickity package version requirements, it's not super easy to change versions of payload. You have to be super careful to change the version, install deps, then run it and test that you don't have a version mismatch for packages like pg and pino - which have to exactly match internal versions, which can for some reason only be deteremined at runtime, rather than a simply dependency map.

void pasture
#

anyone? 😄

faint ingot
void pasture
#

I both have the importmap in my source code, and also re-generate it at startup (and have tried re-generating it at compile time in the build environment)..

#

Nothing fixes this problem.

faint ingot
#

run the importmap manually and lets see, whats the error

void pasture
#

I don't get an error running that

#

I get the error when I run the build later

#

I can also run a build locally no problem, this only happens in deployment

#

If I got back to an older version, I have no problem

#

I wonder if something happened in the s3 plugin

#

maybe something changed there that I missed

#

I have found the errors in general with payload to be kind of baffling

faint ingot
#

you have feature flag there? In the plugin so you get it only on prod?

#

can you share the plugin config, how it looks like?

void pasture
#

I do have a config flag there, yeah

faint ingot
#

can you disable it just to run the importmap manually, so we can see what the actual error

void pasture
#
> NODE_OPTIONS=--no-deprecation payload generate\:importmap

Generating import map
No new imports found, skipping writing import map
#

no error when disabled, let me try it when enabled

#

config is dependant on defined env var

#

okay, well it did add something to the importMap.js file (no error)

#

maybe that's all I need?

faint ingot
#

I have the s3storage enable in dev because of that actually. You probably better use disabled field instead of doing this ninja check

void pasture
#

so the error wasn't

You may need to run the `payload generate:importmap` command to generate the importMap ahead of runtime
#

It was more like:

A component is missing from your importmap - did you disable that for development purposes?
#

It's not super clear how to work around that - when running locally, I definitely don't want the S3 bucket enabled

faint ingot
#

you first of all better use disabled, so theoretically it should add all necessary field in db and importmap. Currently its not working properly

void pasture
#

okay, that makes sense

faint ingot
#

we can walk around this by adding generator in admin importMap.generator, but i not tried it yet

void pasture
#

enabled field (for anyone who comes along - it's enabled, not disabled)

faint ingot
void pasture
#

This worked - thanks!!

#

I can't seem to mark anything as the answer - but this is answered

#

I guess it's just global - thanks again!