solidjs / vite-plugin-solid

A simple integration to run solid-js with vite
435 stars 51 forks source link

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

Open eknkc opened 6 months ago

eknkc commented 6 months ago

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 commented 6 months ago

Probably related to #116

eknkc commented 6 months ago

This also works:

resolve: {
  conditions: ["worker", "webworker"],
  mainFields: ["module"],
}
alexanderniebuhr commented 4 months ago

Astro users face the same issue, the package.json should be fixed in solid itself: https://publint.dev/solid-js@1.8.17

bluwy commented 4 months ago

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

deeprobin commented 1 month ago

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

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