vite icon indicating copy to clipboard operation
vite copied to clipboard

Improve error message for worker format errors

Open PythonCoderAS opened this issue 1 year ago • 2 comments

Description

If using code splitting, vite does not allow using 'iife' for workers. However, googling the message directs me to the wrong place for fixing it.

The error message is:

error during build:
[vite:worker] Invalid value "iife" for option "output.format" - UMD and IIFE output formats are not supported for code-splitting builds.

However, googling this will mention build.rollupOptions.output.format, which is not the offending value. Rather, I need to set build.worker.format, but the error message does not mention worker.format in any form.

Suggested solution

The error message should say

[vite:worker] Invalid value "iife" for option "worker.format" - IIFE output format is not supported for code-splitting builds.

Alternative

We can leave it as is and maybe include an entry in the documentation about worker.format.

Additional context

No response

Validations

PythonCoderAS avatar Jun 14 '24 17:06 PythonCoderAS

It should be a error throwed by Rollup. I have improved the report message in Rolldown btw.

7086cmd avatar Sep 07 '24 05:09 7086cmd

Stumbling upon this issue after 1.5 hours of Googling and leading to the wrong path. I appreciate you!

In my case i was getting error

ERROR  [vite-plugin-pwa:build] Invalid value "iife" for option "output.format" - UMD and IIFE output formats are not supported for code-splitting builds.

I'm using vite-plugin-pwa and using web workers using ?worker import. Fix:

// vite.config.ts
worker: {
      format: "es",
},

Or, if using Vinxi

plugins: () => [
        config("custom", {
          worker: {
            format: "es",
          },
        }),

avarayr avatar Sep 20 '24 16:09 avarayr