{"id":177,"hash":"4688d39945467e0a22f6ed615153c88649a6ada0bb26b99ec283ecb781a535d0","pattern":"plugin:vite:import-analysis - Failed to parse source for import analysis because the content contains invalid JS syntax. - Vue 3","full_message":"I've updated my project from Vite 2.x to Vite 3.0.2 and suddenly i got this error:\n\n[plugin:vite:import-analysis] Failed to parse source for import\nanalysis because the content contains invalid JS syntax. If you are\nusing JSX, make sure to name the file with the .jsx or .tsx extension.\n\n/Volumes/Disk/Web/wce-system/src/i18n.js:51:20\n\nThere's nothing wrong in i18n.js file as it was working fine with Vite 2.x but im putting codes in here just in case you need:\n\nimport { nextTick } from \"vue\"\nimport { createI18n } from \"vue-i18n\"\nimport axios from \"axios\"\nimport tr from \"@/locales/tr.json\"\nimport en from \"@/locales/en.json\"\n\nexport const SUPPORT_LOCALES = [\"tr\", \"en\"]\n\nexport function setupI18n(options = { locale: \"tr\" }) {\nconst i18n = createI18n(options)\nsetI18nLanguage(i18n, options.locale)\n  return i18n\n}\n\nexport function setI18nLanguage(i18n, locale, url) {\n  if (i18n.mode === \"legacy\") {\n  i18n.global.locale = locale\n} else {\n  i18n.global.locale.value = locale\n}       \naxios.defaults.headers.common[\"Accept-Language\"] = locale\ndocument.querySelector(\"html\").setAttribute(\"lang\", locale)\n}\n\nexport async function loadLocaleMessages(i18n, locale) {\n const messages = await import(\n/* webpackChunkName: \"locale-[request]\" */ `./locales/${locale}.json`\n)\n\ni18n.global.setLocaleMessage(locale, messages.default)\n return nextTick()\n}\n\nconst i18n = createI18n({\n  legacy: false,\n  locale: \"tr\",\n  fallbackLocale: \"tr\",\n  globalInjection: true,\n  messages: {\n    tr,\n    en,\n  },\n})\n\nexport default i18n","ecosystem":"npm","package_name":"vuejs3","package_version":null,"solution":"So i figured it out. This line:\n\nconst messages = await import(\n  /* webpackChunkName: \"locale-[request]\" */ `./locales/${locale}.json`\n)\n\nshould have been:\n\n const messages = await import(`./locales/${locale}.json`)\n\nI cant explain why it is so but im leaving links below about issue.\n\nVite dynamic imports\n\nThis may help for further investigation","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/73033899/pluginviteimport-analysis-failed-to-parse-source-for-import-analysis-because","votes":36,"created_at":"2026-04-19T04:41:28.221513+00:00","updated_at":"2026-04-19T04:51:09.962044+00:00"}