bundle-tools icon indicating copy to clipboard operation
bundle-tools copied to clipboard

vite:eslint throws error with messages

Open bokuns opened this issue 4 years ago • 6 comments

I add eslintPlugin() in vite.config.js as following:

export default defineConfig({
	plugins: [
		vue(),
		eslintPlugin({
			fix: true,
			exclude: path.resolve(__dirname, './src/main.js'), // still throw the error even I excluded main.js from here
		}),
		vueI18n({
			include: path.resolve(__dirname, './src/i18n/**'),
		}),
	],
});

and it throws an error:

[vite] Internal server error: No files matching '@intlify/vite-plugin-vue-i18n/messages' were found.
Plugin: vite:eslint
File: @intlify/vite-plugin-vue-i18n/messages

Here's my main.js:

import { createApp } from 'vue';
import { createI18n } from 'vue-i18n';
import messages from '@intlify/vite-plugin-vue-i18n/messages';
import App from './App.vue';

const i18n = createI18n({
	messages,
});

createApp(App).use(i18n).mount('#app');

Note: Removing eslintPlugin() from vite.config.js would get rid of the error, but I do want to keep EsLint functionality though...

I'm not sure this is caused by vite-plugin-eslint or vite-plugin-vue-i18n. Let me know if I should turn it to vite-plugin-eslint instead.

Versions:

  • vite: ^2.3.3
  • vite-plugin-vue-i18n: ^2.1.2
  • vite-plugin-eslint: ^1.1.0
  • eslint: ^7.27.0

bokuns avatar May 25 '21 06:05 bokuns

Same here with vite-ssr plugin

tsconfig.json

{
  "compilerOptions": {
    "target": "esnext",
    "useDefineForClassFields": true,
    "module": "esnext",
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "lib": [
      "esnext",
      "dom"
    ],
    "types": ["@intlify/vite-plugin-vue-i18n/client"]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.d.ts",
    "src/**/*.tsx",
    "src/**/*.vue"
  ]
}

main.ts

import { createI18n } from 'vue-i18n'
import messages from '@intlify/vite-plugin-vue-i18n/messages'

const i18n = createI18n({
  locale: 'en',
  fallbackLocale: 'en',
  messages,
  legacy: false,
})
app.use(i18n)

pnpm vite-ssr

[vite] Error when evaluating SSR module …/src/main.ts:
Error: Cannot find module '@intlify/vite-plugin-vue-i18n/messages' from '…/src'

Looks like it tried to find virtual module in source dir.

imShara avatar Nov 02 '21 00:11 imShara

also failing on vite-ssg: ./messages subpkg missing on package exports entry

EDIT: with latest vite plugin, 3.3.1

userquin avatar Mar 10 '22 12:03 userquin

I think thats related (eslint error): Resolve error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './messages' is not defined by "exports" in \node_modules@intlify\vite-plugin-vue-i18n\package.json

mitow7821 avatar Apr 26 '22 14:04 mitow7821

Cannot find module '@intlify/vite-plugin-vue-i18n/messages' or its corresponding type declarations.ts(2307)

productdevbook avatar May 01 '22 19:05 productdevbook

Use this instead for SSG/SSR

const messages = Object.fromEntries(
  Object.entries(import.meta.globEager("../locales/*.yaml")).map(
    ([key, value]) => [key.slice(11, -5), value.default]
  )
);

imShara avatar May 03 '22 09:05 imShara

Just ignore it

eslintrc.json

{
  "settings": {
    "import/core-modules": [
      "@intlify/vite-plugin-vue-i18n/messages",
      ...
    ]
  },
  ...
}

trylovetom avatar Oct 18 '22 09:10 trylovetom