-
Notifications
You must be signed in to change notification settings - Fork 410
Closed
Description
IS: During npm run build the start-node adapter currently runs three build processes, one if them is a pure rollup build.
- That rollup build doesn't have vite's external-dependency detection magic
- it also ignores vites config
ssr.external(code).
SHOULD:
- Ideallly that rollup build should have the same external dependency detection as vite (its a bad dev workflow if the dev/prod builds behave inconsistent)
- Atleast there should be a way for the user to manually set node externals consistently across dev and prod builds.
REPRODUCTION:
- Essentially: use a node-only package (like
redis) and runnpm run build - Example
MY WORKAROUND:
I locally cloned start-node and made the following changes. This allows me to set externals in vite's ssr.external config consistently across dev/build.
diff --git a/packages/start-node/index.js b/packages/start-node/index.js
index 599c4bc..c1a189c 100644
--- a/packages/start-node/index.js
+++ b/packages/start-node/index.js
@@ -13,6 +13,7 @@ export default function () {
import(pathToFileURL(join(config.root, "dist", "index.js")));
},
async build(config) {
+ const ssrExternal = config?.ssr?.external || [];
const __dirname = dirname(fileURLToPath(import.meta.url));
const appRoot = config.solidOptions.appRoot;
await vite.build({
@@ -33,6 +34,7 @@ export default function () {
outDir: "./.solid/server",
rollupOptions: {
input: resolve(join(config.root, appRoot, `entry-server`)),
+ external: ssrExternal,
output: {
format: "esm"
}
@@ -54,7 +56,7 @@ export default function () {
}),
common()
],
- external: ["undici", "stream/web", "@prisma/client"]
+ external: ["undici", "stream/web", "@prisma/client", ...ssrExternal]
});
// or write the bundle to disk
await bundle.write({ format: "esm", dir: join(config.root, "dist") });
Somewhat related: #95
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working