danielroe / danielroe/nuxt-workers

identifier "__worker_exports__" has already been declared

Open
#191 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
447
Forks
9
Avg merge
21h 19m
Merged PRs (30d)
23

Description

### 📚 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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.