vite-plugin-solid icon indicating copy to clipboard operation
vite-plugin-solid copied to clipboard

Vite does not load proper build (server) on ssr webworker build

Open eknkc opened this issue 11 months ago • 5 comments

While building the ssr bundle with ssr.target = "webworker", it looks like the default web builds of vite is being bundled. I have these in my vite config but it is no help.

resolve: {
  conditions: ["worker", "webworker"],
},

Only when I add aliases to correct builds, then it works:

resolve: {
  conditions: ["worker", "webworker"],
  alias: {
    "solid-js/web": "solid-js/web/dist/server",
    "solid-js": "solid-js/dist/server",
  },
},

Here's my complete config:

Details

{
  appType: "custom",
  resolve: {
    conditions: ["worker", "webworker"],
    alias: {
      "solid-js/web": "solid-js/web/dist/server",
      "solid-js": "solid-js/dist/server",
    },
  },
  build: {
    outDir: "dist",
    manifest: false,
    chunkSizeWarningLimit: 1024 * 1024,
    emptyOutDir: false,
    ssrEmitAssets: false,
    copyPublicDir: false,
    assetsDir: ".worker",
    rollupOptions: {
      input: "virtual:worker-entry",
      output: {
        entryFileNames: "_worker.js",
        inlineDynamicImports: false,
      },
    },
    ssr: true,
  },
  ssr: {
    target: "webworker",
    noExternal: true,
  },
};

eknkc avatar Mar 11 '24 16:03 eknkc

Probably related to #116

eknkc avatar Mar 11 '24 16:03 eknkc

This also works:

resolve: {
  conditions: ["worker", "webworker"],
  mainFields: ["module"],
}

eknkc avatar Mar 11 '24 16:03 eknkc

Astro users face the same issue, the package.json should be fixed in solid itself: https://publint.dev/[email protected]

alexanderniebuhr avatar May 17 '24 09:05 alexanderniebuhr

Also related: https://github.com/solidjs/solid-start/issues/263

bluwy avatar May 17 '24 09:05 bluwy

@ryansolid Is this adapter dead? Last commit 5 months ago?

I require the astro cloudflare integration which works only with fixing this issue.

deeprobin avatar Aug 06 '24 15:08 deeprobin