pzmosquito / eslint-import-resolver-vite

Vite module resolution plugin for eslint-plugin-import.
MIT License
16 stars 4 forks source link

fix: use `import` instead of `require` for `vite.config.js` #8

Closed musjj closed 1 year ago

musjj commented 1 year ago

I'm getting [ERR_REQUIRE_ESM]: require() of ES Module from not supported. errors if vite.config.js is required. Using import fixes this. Not sure if this is a good general solution though, so let me know if it has any unwanted side effects.

musjj commented 1 year ago

Never mind this does not do what I thought it does, I'll think of something else.

pzmosquito commented 1 year ago

ESM is not supported by eslint-import-plugin right now, so the plugin must be written using CJS. There's no way around it.

musjj commented 1 year ago

Yeah, just looked through the repo issues, shame.

nerdchanii commented 1 year ago

@musjj Have you solved this issue? I'm also facing the same problem.

In my case, I configured vite config as ESM and eslint as CJS. When using the vite.config.ts(js) file written in ESM for this plugin, I encounter an "out of module" error.

@pzmosquito I saw that you are using without any problem, do you happen to have a publicly accessible repository I can refer to?

Additionally, it would be great to have best practices or examples included in the package as well. :)

pzmosquito commented 1 year ago

@musjj Have you solved this issue? I'm also facing the same problem.

In my case, I configured vite config as ESM and eslint as CJS. When using the vite.config.ts(js) file written in ESM for this plugin, I encounter an "out of module" error.

@pzmosquito I saw that you are using without any problem, do you happen to have a publicly accessible repository I can refer to?

Additionally, it would be great to have best practices or examples included in the package as well. :)

The How to use section in the README file is pretty much the simplifed version of my set up. I'd suggest that you set up an empty project with no other packages except eslint related ones. If you still see problem, please let me know; otherwise, gradually add more packages and see where the problem is.

nerdchanii commented 1 year ago

The How to use section in the README file is pretty much the simplifed version of my set up. I'd suggest that you set up an empty project with no other packages except eslint related ones. If you still see problem, please let me know; otherwise, gradually add more packages and see where the problem is.

I'll retry soon. And if I can't solve the problem, I'll leave a message. Thanks to your kindness and your works.