-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[eslint-plugin-import:resolver:vite] require() of ES Module vite.config.js #12
Comments
I think the error was clear. with |
With the latest settings: {
'import/resolver': {
vite: { viteConfig: require('import-sync')('./vite.config.js or ts').default },
},
}, |
that's good info! Thanks. I'm hoping the |
This will trigger warning about
|
It's completely broken after upgrade
We might need https://github.com/dividab/tsconfig-paths to compliant with https://www.typescriptlang.org/tsconfig#paths in vitejs/vite@b20d542#diff-c939fb298531661c9de72b988f28de92c0d8f1d7d5e6a8926ba640052af4f4c1R9. |
$ yarn set version latest * pin `[email protected]` due to pzmosquito/eslint-import-resolver-vite#12 (comment) - `vue.vscode-typescript-vue-plugin` in favor of `Vue.volar^2.0.0` behind `@vue/language-server^2.0.0` @ .vscode/extensions.json @ fe
found something interesting but I haven't tried it. |
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -527,2 +527,2 @@
-module.exports = {
+module.exports = (async () => ({
@@ -553,3 +553,2 @@ module.exports = {
- vite: { viteConfig: require('import-sync')('./vite.config.ts').default },
+ vite: { viteConfig: (await import('./vite.config.ts')).default },
@@ -594 +593 @@ module.exports = {
-};
+}))();
https://github.com/privatenumber/ts-runtime-comparison might be helpful |
- vite: { viteConfig: require('import-sync')('./vite.config.ts').default },
+ vite: { viteConfig: require('./vite.config.ts').default }, $ yarn add -D tsx
$ yarn run tsx node_modules/eslint/bin/eslint src
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details. works but still using the cjs - vite: { viteConfig: require('./vite.config.ts').default },
+ vite: { viteConfig: import('./vite.config.ts') }, thanks to |
$ yarn add -D tsx $ yarn up vite * using esm `import()` without awaiting it since pzmosquito/eslint-import-resolver-vite#12 (comment) * ignore `.js` extension for rule `import/extensions` @ .eslintrc.cjs @ fe
For convenience adding --- a/package.json
+++ b/package.json
@@ -9 +9,2 @@ "scripts": {
+ "eslint": "tsx node_modules/eslint/bin/eslint" when using yarn pnp: $ yarn unplug eslint + "eslint": "tsx .yarn/unplugged/eslint-npm-*/node_modules/eslint/bin/eslint.js" |
…to/eslint-import-resolver-vite#12 (comment) @ package.json $ yarn unplug eslint $ yarn dlx @yarnpkg/sdks vscode $ yarn upgrade-interactive @ fe
When using flat config, we can use static import to import vite config as esm to + import viteConfig from './vite.config.ts';
- vite: { viteConfig: import('./vite.config.ts') },
+ vite: { viteConfig }, but |
When using vscode extension
we can use import { tsImport } from 'tsx/esm/api'
const viteConfig = await tsImport('./vite.config.ts', import.meta.url); import { require } from 'tsx/cjs/api'
const viteConfig = require('./vite.config.ts', import.meta.url); but it will trigger #12 (comment)
|
When using api provided by --- a/package.json
- "dependenciesMeta": {
- "[email protected]": {
- "unplugged": true
- }
- } - "eslint": "tsx .yarn/unplugged/eslint-npm-*/node_modules/eslint/bin/eslint.js" |
* fix `Parse errors in imported module '': parserPath or languageOptions.parser is required!`: un-ts/eslint-plugin-import-x#85 (comment) @ eslint.config.js * re-plug eslint: pzmosquito/eslint-import-resolver-vite#12 (comment) @ package.json * fix some violations of eslint rules @ fe
* merge two settings for `import-x/resolver` from `*.{ts,vue}` to globalwide * rename import `stylisticMigrate` to `pluginStylisticMigrate` @ eslint.config.js * re-plug eslint: pzmosquito/eslint-import-resolver-vite#12 (comment) @ package.json * fix some violations of eslint rules @ fe
Hi,
I get this error in eslint console :
In package.json "type": "module" and I've created this file .eslintrc.cjs (cjs) file :
If I understand correctly, the vite plugin is required as cjs because of cjs eslint. But then it cannot require the esm vite config...
What could I do please ?
The text was updated successfully, but these errors were encountered: