#Bundle node modules into /dist on SSR build

9 messages · Page 1 of 1 (latest)

blissful oxide
#

Is there a way to include the required node modules in your /dist directly when running an SSR build?

#

I attempted to set Vite SSR no external to true, which I'd expect to bundle everything up nicely but I'm missing some Astro node modules when I try that:
│ ERR [GenerateContentTypesError] `astro sync` command failed to generate content collection types: module is not defined │ ERR Hint: │ ERR Check your `src/content/config.*` file for typos. │ ERR Error reference: │ ERR https://docs.astro.build/en/reference/errors/generate-content-types-error/ │ ERR Stack trace: │ ERR at syncInternal (file:///Users/jacoblaveroni/dev/fe/frontend/apps/markets-marketing/node_modules/astro/dist/core/sync/index.js:89:11) │ ERR at async AstroBuilder.run (file:///Users/jacoblaveroni/dev/fe/frontend/apps/markets-marketing/node_modules/astro/dist/core/build/index.js:163:23) │ ERR at async build (file:///Users/jacoblaveroni/dev/fe/frontend/apps/markets-marketing/node_modules/astro/dist/cli/build/index.js:20:3) │ ERR at async cli (file:///Users/jacoblaveroni/dev/fe/frontend/apps/markets-marketing/node_modules/astro/dist/cli/index.js:155:5) │ ERR Caused by: │ ERR module is not defined │ ERR at eval (/Users/jacoblaveroni/dev/fe/frontend/node_modules/cssesc/cssesc.js:112:1) │ ERR Process exited with code 1

#

As additional context, I am integrating DatoCMS into my application. In test, I'd like an SSR build to allow marketing to immediately see changes in the app. On production, I'd like to generate a static build. The issue comes when doing the SSR build. I am not able to do a simple npm install because some of the dependencies rely on a custom NEXUS package, and I'd rather not provide the NEXUS token to the docker container. So, I'd prefer to just bundle the dependencies and copy the node modules to the container so /dist can work properly

#

My attempt on the vite no-external true in astro.congif file:

#
      ssr: {
        noExternal: ['@astrojs', 'cookie'],
      },
    },
#

^^ Didn't work 😢

blissful oxide
#

Basically I'm asking why an npm install is required in a docker image. I'd expect the /dist to contain everything I need from the get-go

weary widget
blissful oxide
#

Holy crap