\r\n\r\nself.addEventListener(\r\n 'message',\r\n (\r\n evt: MessageEvent\u003C{\r\n message: string\r\n }>,\r\n ) => {\r\n const { message } = evt.data\r\n const greeting = `Hello ${upperCase(message)} from assets!`\r\n\r\n postMessage({ greeting })\r\n },\r\n)\r\n```\r\n\r\nCreate a app.vue file\r\n\r\n```vue\r\n\u003Cscript setup lang=\"ts\">\r\nimport Runner from './utils/workers/index?worker'\r\n\r\nconst message = ref('Nuxt')\r\n\r\nfunction sayHello(from: 'workers' | 'composable') {\r\n if (from === 'workers') {\r\n const worker = new Runner()\r\n worker.postMessage({ message: message.value })\r\n worker.addEventListener(\r\n 'message',\r\n (\r\n evt: MessageEvent\u003C{\r\n greeting: string\r\n }>,\r\n ) => {\r\n const { greeting } = evt.data\r\n alert(greeting)\r\n },\r\n )\r\n } else {\r\n sayHelloFromComposable(message.value)\r\n }\r\n}\r\n\u003C/script>\r\n\r\n\u003Ctemplate>\r\n \u003Ch1>Demo with auto imports\u003C/h1>\r\n \u003CCustomInput v-model=\"message\" />\r\n \u003Cbutton type=\"submit\" @click=\"sayHello('composable')\">\r\n Hello from composable\r\n \u003C/button>\r\n \u003Cbutton type=\"submit\" @click=\"sayHello('workers')\">Hello from workers\u003C/button>\r\n\u003C/template>\r\n./assets/workers\r\n```\r\n\r\n### Describe the bug\r\n\r\n## Actual Behavior\r\n\r\nIn development mode, the utils/ directory is auto imported, so the upperCase function is available on the assets/index.ts file.\r\n\r\nIn production mode, we have this error:\r\n\r\n```txt\r\nUncaught ReferenceError: upperCase is not defined\r\n at index-8e797b43.js:1:88\r\n```\r\n\r\n## Expected Behavior\r\n\r\nThis should work with the same behavior in development and production mode.\r\n\r\n\r\n### Additional context\r\n\r\n\r\nI call the utils to function in `worker` file\r\n\r\n### Logs\r\n\r\n_No response_",[1984,1987,1990,1993],{"name":1985,"color":1986},"workaround available","11376d",{"name":1988,"color":1989},"bug","d73a4a",{"name":1991,"color":1992},"vite","3574D1",{"name":1994,"color":1995},"🍰 p2-nice-to-have","0E8A16",24590,"nuxt","open","Utils folder is not auto imported on production mode when using in worker file","2024-11-19T11:52:00Z","https://github.com/nuxt/nuxt/issues/24590",0.6725791,{"description":2004,"labels":2005,"number":2014,"owner":1997,"repository":1997,"state":1998,"title":2015,"updated_at":2016,"url":2017,"score":2018},"### Environment\n\n\r\n------------------------------\r\n- Operating System: `Linux`\r\n- Node Version: `v16.19.0`\r\n- Nuxt Version: `3.2.2`\r\n- Nitro Version: `2.2.3`\r\n- Package Manager: `npm@8.19.3`\r\n- Builder: `vite`\r\n- User Config: `devServer`, `css`, `modules`, `alias`, `vite`\r\n- Runtime Modules: `@nuxtjs/i18n@8.0.0-beta.10`\r\n- Build Modules: `-`\r\n------------------------------\r\n\n\n### Reproduction\n\nhttps://github.com/michaelzangl/nuxt-bug-linked-lib\r\n\r\nSome notes:\r\n* The Library defines a variable 'h' in it's file (also works with the other auto-imported names, but due to minify, 'h' was the first one I found)\r\n* That variable may not be defined directly as `var h`, so that unimport does not find it (=> this seems to be a bug in unimport - but this is not the real issue here, it just triggers the error easily)\n\n### Describe the bug\n\nWhen building an application, files imported as node module that are linked on the file system are not excluded from auto imports.\r\n\r\n```\r\n/linked-lib // \u003C Auto-Imports will be done here\r\n/nuxt-project\r\n /package.json // \u003C contains \"linked-lib\": \"file:../linked-lib\" \r\n```\r\n\r\nI think, that auto-imports should not be resolved even when symlinking a library\r\n\r\nThe exclusion should have happened in https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/imports/transform.ts\r\n\r\nIs it possible to exclude all files that do not start with the project root directory there? Or will this cause issues?\r\n\r\nWorkaround: I did not find one yet (except for patching that file).\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell-script\n/nuxt-project$ npm run build\r\n\r\n> build\r\n> nuxt build\r\n\r\nNuxi 3.2.3 12:29:01\r\nNuxt 3.2.3 with Nitro 2.2.3 12:29:01\r\nℹ Building client... 12:29:02\r\nvite v4.1.4 building for production...\r\n✓ 41 modules transformed.\r\nIdentifier 'h' has already been declared (Note that you need plugins to import files that are not JavaScript)\r\nfile: /.../nuxt-bug-linked-lib/linked-lib/lib.mjs:2:0\r\n1: // We need var x here, since this triggers unimport to not find the declaration of 'h'\r\n2: var x = 'text', h = 'text';\r\n ^\r\n3: \r\n4: console.log(h());\r\n\r\n ERROR Identifier 'h' has already been declared (Note that you need plugins to import files that are not JavaScript) 12:29:03\r\n\r\n at error (node_modules/rollup/dist/es/shared/node-entry.js:2105:30)\r\n at Module.error (node_modules/rollup/dist/es/shared/node-entry.js:13174:16)\r\n at Module.tryParse (node_modules/rollup/dist/es/shared/node-entry.js:13851:25)\r\n at Module.setSource (node_modules/rollup/dist/es/shared/node-entry.js:13461:39)\r\n at ModuleLoader.addModuleSource (node_modules/rollup/dist/es/shared/node-entry.js:23422:20)\r\n\r\n\r\n```\n```\n",[2006,2007,2010,2011],{"name":1985,"color":1986},{"name":2008,"color":2009},"dx","C39D69",{"name":1988,"color":1989},{"name":2012,"color":2013},"🔨 p3-minor","FBCA04",19525,"Auto import attempted for linked library","2024-11-19T16:20:24Z","https://github.com/nuxt/nuxt/issues/19525",0.67512953,{"description":2020,"labels":2021,"number":2025,"owner":1997,"repository":1997,"state":2026,"title":2027,"updated_at":2028,"url":2029,"score":2030},"### Environment\n\n- Operating System: Linux\n- Node Version: v18.20.3\n- Nuxt Version: 3.14.1592\n- CLI Version: 3.16.0\n- Nitro Version: -\n- Package Manager: pnpm@8.15.6\n- Builder: -\n- User Config: default\n- Runtime Modules: -\n- Build Modules: -\n\n### Reproduction\n\nhttps://stackblitz.com/edit/github-9548wjk1?file=app.vue\n\n### Describe the bug\n\nThe [documentation](https://nuxt.com/docs/guide/directory-structure/shared#auto-imports) says: _\"...files in the shared/utils/ and shared/types/ directories will be auto-imported.\"_\n\nHowever, in fact, files in the `shared/utils/` are not being auto imported unless `compatibilityVersion: 4` is enabled. This is not covered in the documentation (only something about `app/` is).\n\nEither the documentation should make it clear that shared utils is for Nuxt 4 layout only, or auto import should be fixed.\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell-script\n\n```",[2022],{"name":2023,"color":2024},"documentation","5319e7",30286,"closed","shared/utils/ auto import documentation is misleading","2025-02-08T21:22:19Z","https://github.com/nuxt/nuxt/issues/30286",0.5969773,{"description":2032,"labels":2033,"number":2039,"owner":1997,"repository":1997,"state":2026,"title":2040,"updated_at":2041,"url":2042,"score":2043},"### Environment\n\n------------------------------\n- Operating System: Linux\n- Node Version: v18.20.5\n- Nuxt Version: 3.14.159\n- CLI Version: 3.15.0\n- Nitro Version: 2.10.4\n- Package Manager: bun@1.1.34\n- Builder: -\n- User Config: default\n- Runtime Modules: -\n- Build Modules: -\n------------------------------\n\n### Reproduction\n\nWhen defining `shared/types/test.ts` with:\n```ts\nexport type Test = string;\n```\nI have, from `app.vue`:\n\nAnd if I press `\u003Ctab>`, vscode inserts:\n```ts\nimport type { Test } from '~~/shared/types/test';\n```\nWhich defeats the point of autoimports.\n\n### Describe the bug\n\nAlso the behavior is not always the same, sometimes (although not often) I see the alias instead and it doesn't insert the extra line.\n\nWhat's wrong?\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell-script\n\n```",[2034,2037],{"name":2035,"color":2036},"pending triage","E99695",{"name":2038,"color":2013},"needs reproduction",29963,"Shared folder - Autoimports not working","2025-03-24T23:00:22Z","https://github.com/nuxt/nuxt/issues/29963",0.6145299,{"description":2045,"labels":2046,"number":2048,"owner":1997,"repository":1997,"state":2026,"title":2049,"updated_at":2050,"url":2051,"score":2052},"### Environment\n\n- Operating System: Linux\n- Node Version: v18.20.3\n- Nuxt Version: 3.15.4\n- CLI Version: 3.22.2\n- Nitro Version: 2.10.4\n- Package Manager: npm@10.2.3\n- Builder: -\n- User Config: future, compatibilityDate, devtools, srcDir, serverDir, dir\n- Runtime Modules: -\n- Build Modules: -\n\n### Reproduction\n\nhttps://stackblitz.com/edit/github-c3zbe4c6-cpg2sv8f\n\n### Describe the bug\n\nIntended Directory Structure:\n\n```\n.\n├── nuxt.config.ts\n└── src\n ├── app ✅ works\n │ ├── app.vue\n │ └── utils ✅ auto-import works\n │ └── app-utils.ts\n ├── public ✅ works\n │ └── public.txt\n ├── server ✅ works\n │ └── utils ✅ auto-import works\n │ └── server-utils.ts\n └── shared 🚫 auto-import fail\n └── shared-utils.ts\n```\n\nNuxt Config:\n\n```typescript\nexport default defineNuxtConfig({\n future: { compatibilityVersion: 4 },\n compatibilityDate: '2024-11-01',\n devtools: { enabled: true },\n\n srcDir: 'src/app',\n serverDir: 'src/server',\n dir: {\n public: 'src/public',\n shared: 'src/shared', // 🚫 this got ignored\n },\n});\n```\n\nThere is no viable workarounds (i.e. imports.dir works for `srcDir` but not `serverDir`), other than doing manual imports.\n\n### Additional context\n\nInspecting the generated types in .nuxt suggests `options.dir.shared` is ignored during auto-import.\n\nFrom reproduction\n\napp.vue\n\n```vue\n\u003Ctemplate>\n \u003Cdiv>\n \u003Cul>\n \u003Cli>Function from app/utils: {{ appUtilsFunction() }}\u003C/li>\n \u003Cli>\n Function from shared/utils: {{ catchWrapper(sharedUtilsFunction) }}\n \u003C/li>\n \u003C/ul>\n \u003C/div>\n\u003C/template>\n\n\u003Cscript setup>\nconst catchWrapper = (fn) => {\n try {\n return fn();\n } catch {\n return 'Unable to access this function';\n }\n};\n\u003C/script>\n```\n\nshows\n```\nFunction from app/utils: This works!\nFunction from shared/utils: Unable to access this function\n```\n\nroutes/server.js\n\n```javascript\nexport default defineEventHandler(() => {\n const outputFromServerUtils = serverUtilsFunction();\n\n let outputFromSharedUtils;\n try {\n outputFromSharedUtils = sharedUtilsFunction();\n } catch {}\n\n return {\n serverUtilsFunction: outputFromServerUtils,\n sharedUtilsFunction: outputFromSharedUtils ?? '',\n };\n});\n```\n\nshows\n\n```json\n{\n \"serverUtilsFunction\": \"This works!\",\n \"sharedUtilsFunction\": \"\"\n}\n```\n\n### Logs\n\n```shell-script\n\n```",[2047],{"name":2035,"color":2036},31082,"Nuxt config's `dir.shared` is ignored in auto-imports","2025-02-23T09:31:41Z","https://github.com/nuxt/nuxt/issues/31082",0.6381111,{"description":2054,"labels":2055,"number":2060,"owner":1997,"repository":1997,"state":2026,"title":2061,"updated_at":2062,"url":2063,"score":2064},"### Environment\n\nNuxt project info: 10:36:49 AM\r\n\r\n------------------------------\r\n- Operating System: Linux\r\n- Node Version: v20.14.0\r\n- Nuxt Version: 3.12.3-28642550.8578e2bd\r\n- CLI Version: 3.11.2-1718100309.03d4a54\r\n- Nitro Version: 2.9.6\r\n- Package Manager: bun@1.1.13\r\n- Builder: -\r\n- User Config: app, typescript, imports, modules, runtimeConfig, devtools, future, compatibilityDate\r\n- Runtime Modules: @nuxt/fonts@0.7.0, @nuxt/image@1.7.0, @nuxt/test-utils@3.13.1, @nuxtjs/html-validator@1.8.2, @vueuse/nuxt@10.11.0, dayjs-nuxt@2.1.9, nuxt-aos@1.2.4, @pinia/nuxt@0.5.1, vuetify-nuxt-module@0.14.1\r\n- Build Modules: -\r\n------------------------------\r\n\n\n### Reproduction\n\nhttps://stackblitz.com/edit/github-jwxut5?file=app%2Fapp.vue\n\n### Describe the bug\n\nTrying to use `~/utils/rootTest.ts` or `~/utils/services/test.ts` is not working in script tag, only in template.\r\n\r\n```html\r\n\u003Cscript setup lang=\"ts\">\r\n\r\n//These will throw a 500 Error.\r\n//can't access lexical declaration [CONST_NAME] before initialization\r\nconst test = test();\r\nconst rootTest = rootTest();\r\n\r\n\u003C/script>\r\n\r\n\u003Ctemplate>\r\n \u003Cdiv>\r\n \u003C!--This works!-->\r\n \u003Cp>{{ test() }}\u003C/p>\r\n\r\n \u003C!--This works!-->\r\n \u003Cp>{{ rootTest() }}\u003C/p>\r\n \u003C/div>\r\n\u003C/template>\r\n```\n\n### Additional context\n\nUsing Nuxt in compatibilityMode 4\n\n### Logs\n\n```shell-script\nERROR [nitro] [unhandledRejection] $setup.test is not a function\r\n\r\n renderComponentSubTree@node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:693:18\r\n renderComponentVNode@node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:637:12\r\n ssrRenderComponent@node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:84:10\r\n default@node_modules/nuxt/dist/app/components/nuxt-root.vue:102:38\r\n ssrRenderSuspense@node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:466:5\r\n _sfc_ssrRender@node_modules/nuxt/dist/app/components/nuxt-root.vue:91:26\r\n renderComponentSubTree@node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:693:18\r\n renderComponentVNode@node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:637:12\r\n renderToString@node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:911:24\r\n renderToString$1@.nuxt/dev/index.mjs:1134:101\r\n renderToString@node_modules/vue-bundle-renderer/dist/runtime.mjs:200:40\r\n```\n```\n",[2056,2059],{"name":2057,"color":2058},"3.x","29bc7f",{"name":2035,"color":2036},27763,"Utils Dir in compatibility Mode not auto-imported","2024-06-23T13:58:02Z","https://github.com/nuxt/nuxt/issues/27763",0.64287394,{"description":2066,"labels":2067,"number":2071,"owner":1997,"repository":1997,"state":2026,"title":2072,"updated_at":2073,"url":2074,"score":2075},"### Environment\n\n------------------------------\r\n- Operating System: Windows_NT\r\n- Node Version: v18.17.1\r\n- Nuxt Version: 3.10.2\r\n- CLI Version: 3.10.1\r\n- Nitro Version: 2.8.1\r\n- Package Manager: yarn@1.22.21\r\n- Builder: -\r\n- User Config: ssr, runtimeConfig, build, devtools, routeRules, modules, vite, \r\ncss, sourcemap\r\n- Runtime Modules: (), @pinia/nuxt@0.5.1\r\n- Build Modules: -\r\n------------------------------\n\n### Reproduction\n\n.\r\n\n\n### Describe the bug\n\ncustom components inside components directory are imported automatically but not fuctions in utils directory.\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell-script\nReferenceError: XXX is not defined\n```\n",[2068,2069,2070],{"name":2057,"color":2058},{"name":2035,"color":2036},{"name":2038,"color":2013},27257,"autoImport for utils directory doesn't work correctly.","2024-05-24T13:28:33Z","https://github.com/nuxt/nuxt/issues/27257",0.65059316,{"description":2077,"labels":2078,"number":2080,"owner":1997,"repository":1997,"state":2026,"title":2081,"updated_at":2082,"url":2083,"score":2084},"### Environment\n\nwhen I try to use functionality in utils folders of a nuxt project in tests, they don't get auto-imported\n\n\n``` ❯ test/auto.test.ts (1 test | 1 failed) 4052ms\n × auto test > test import 1ms\n → serverUtilsTest is not defined\n\n⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯\n\n FAIL test/auto.test.ts > auto test > test import\nReferenceError: serverUtilsTest is not defined\n ❯ test/auto.test.ts:8:20\n 6|\n 7| it('test import', () => {\n 8| const result = serverUtilsTest()\n | ^\n 9| expect(result).toBe('serverUtilsTest')\n 10| })\n```\n\nhere is my `server/utils/test.ts` file\n```ts\nexport function serverUtilsTest() {\n return 'serverUtilsTest'\n}\n```\n\nand here is my `test/auto.test.ts` file\n```ts\nimport { describe, it, expect } from 'vitest'\nimport { setup } from '@nuxt/test-utils'\n\ndescribe('auto test', async () => {\n await setup({ dev: true })\n\n it('test import', () => {\n const result = serverUtilsTest()\n expect(result).toBe('serverUtilsTest')\n })\n})\n```\n\nrepo for reproduction https://github.com/acidjazz/auto-import-test\n\n### Reproduction\n\nrun `pnpm run test` in repo https://github.com/acidjazz/auto-import-test\n\n### Describe the bug\n\n@nuxt/test-utils setup() should take care of all auto-imports in utils folders\n\n### Additional context\n\n_No response_\n\n### Logs\n\n```shell-script\n\n```",[2079],{"name":2035,"color":2036},30699,"auto-imports of utils folders not working in tests using @nuxt/test-utils","2025-01-22T17:53:23Z","https://github.com/nuxt/nuxt/issues/30699",0.6551337,{"description":2086,"labels":2087,"number":2090,"owner":1997,"repository":1997,"state":2026,"title":2091,"updated_at":2092,"url":2093,"score":2094},"### Environment\n\n- Operating System: `Darwin`\r\n- Node Version: `v18.12.1`\r\n- Nuxt Version: `3.0.0-rc.11`\r\n- Nitro Version: `0.5.4`\r\n- Package Manager: `npm@8.19.2`\r\n- Builder: `vite`\r\n- User Config: `-`\r\n- Runtime Modules: `-`\r\n- Build Modules: `-`\r\n\n\n### Reproduction\n\n1. Create a file named `general.ts` in `utils/` directory.\r\n2. Not being auto-imported for usage in components. \r\n\r\n\n\n### Describe the bug\n\nAuto-import is enabled for `utils/` directory - as mentioned in the documentation: https://v3.nuxtjs.org/guide/directory-structure/utils . Still, it isn't working. Please let me know where am I going wrong.\n\n### Additional context\n\n_No response_\n\n### Logs\n\n_No response_",[2088,2089],{"name":2057,"color":2058},{"name":2035,"color":2036},15477,"`utils/` are not being auto-imported","2023-01-19T17:51:29Z","https://github.com/nuxt/nuxt/issues/15477",0.6562161,{"description":2096,"labels":2097,"number":2103,"owner":1997,"repository":1997,"state":2026,"title":2104,"updated_at":2105,"url":2106,"score":2107},"### Environment\r\n\r\n- Operating System: `Windows_NT`\r\n- Node Version: `v16.19.0`\r\n- Nuxt Version: `3.3.1`\r\n- Nitro Version: `2.3.1`\r\n- Package Manager: `yarn@1.22.19`\r\n- Builder: `vite`\r\n- User Config: `alias`, `build`, `css`, `components`, `imports`, `modules`, `reactivityTransform`, `runtimeConfig`, `ssr`, `vite`\r\n- Runtime Modules: `@pinia/nuxt@0.4.6`, `@vue-macros/nuxt@1.2.1`\r\n- Build Modules: `-`\r\n\r\n### Reproduction\r\n\r\nhttps://stackblitz.com/edit/github-mkumh3\r\n\r\n### Describe the bug\r\n\r\nUtility functions (inside `utils` directory) that includes `$` not working directly inside templates without explicit import (i.e. with auto-import).\r\n\r\nI'm not sure if it's intended or not, but at least it should be mentioned in the docs.\r\n\r\n### Additional context\r\n\r\nThe repro tests utils just starting with `$`, but utilities with `$` in the middle don't work either.\r\n\r\n### Logs\r\n\r\n_No response_",[2098,2099,2100],{"name":2057,"color":2058},{"name":2035,"color":2036},{"name":2101,"color":2102},"upstream","E8A36D",19718,"auto-imported utils starting with $ not available inside template","2023-03-23T13:08:39Z","https://github.com/nuxt/nuxt/issues/19718",0.6570848,["Reactive",2109],{},["Set"],["ShallowReactive",2112],{"TRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"d6RIR6MYT7n4MV7nZlnlzNqEF-G4SpW5PTkO7Q5xpA0":-1},"/nuxt/nuxt/30482"]