Skip to content

identifier "__worker_exports__" has already been declared #191

Open

Description

@noxz-dev

📚 What are you trying to do?

Whenever I try to call a function exported by the file in the Workers directory, I get a build error. It works fine in dev, but fails during the build process. Since i tried to build the playground which works just fine, im curios if if did something wrong.

its company code so its hard to give a full repro

im using Nuxt 4.2.0

🔍 What have you tried?

i tried to just have a function like the hi example from the playground

export function fetchHeaders() {
return "success";
}

ℹ️ Additional context

[nuxi 12:08:01 AM] ERROR Nuxt Build Error: [vite:worker-import-meta-url] app/workers/fetchHeaders.ts (61:6): Identifier "worker_exports" has already been declared
file: /app/workers/fetchHeaders.ts:61:6 (virtual:nuxt-workers.mjs?source=2Fapp%2Fworkers%2FfetchHeaders.ts)

59: }
60: }
61: const worker_exports = { fetchHeaders: fetchHeaders }
^
62: self.onmessage = async (e) => {
63: const { name, args, id } = e.data

at getRollupError (node_modules/rollup/dist/es/shared/parseAst.js:401:41)
at error (node_modules/rollup/dist/es/shared/parseAst.js:397:42)
at Module.error (node_modules/rollup/dist/es/shared/node-entry.js:16939:16)
at ModuleScope.addDeclaration (node_modules/rollup/dist/es/shared/node-entry.js:5540:21)
at ModuleScope.addDeclaration (node_modules/rollup/dist/es/shared/node-entry.js:15040:22)
at Identifier.declare (node_modules/rollup/dist/es/shared/node-entry.js:5425:35)
at VariableDeclarator.declareDeclarator (node_modules/rollup/dist/es/shared/node-entry.js:13042:17)
at VariableDeclaration.initialise (node_modules/rollup/dist/es/shared/node-entry.js:15397:24)
at convertNode (node_modules/rollup/dist/es/shared/node-entry.js:16337:10)
at convertNodeList (node_modules/rollup/dist/es/shared/node-entry.js:16347:38)

Activity

  1. yan-yanishevsky commented on Jan 23, 2026

    @yan-yanishevsky

    A similar error for Rolldown happened to me when I tried compatibilityVersion: 5 in nuxt config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions