Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for worker format errors #17483

Open
4 tasks done
PythonCoderAS opened this issue Jun 14, 2024 · 2 comments · May be fixed by #18165
Open
4 tasks done

Improve error message for worker format errors #17483

PythonCoderAS opened this issue Jun 14, 2024 · 2 comments · May be fixed by #18165
Labels
contribution welcome feat: web workers p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@PythonCoderAS
Copy link

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

@7086cmd
Copy link

7086cmd commented Sep 7, 2024

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

@avarayr
Copy link

avarayr commented Sep 20, 2024

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",
          },
        }),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome feat: web workers p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants