[Issue][Configuration Nuxt3] Cannot find module '...' or its corresponding type declarations.
TwentyCCent opened this issue · comments
Describe the bug
Les modules de maz-ui ne sont pas reconnus en utilisant la syntaxe ESM
To Reproduce
"nuxt": "^3.7.3",
...
"maz-ui": "^3.11.4"
Dans mon package.json j'ai bien déclaré le type module
"type": "module",
Voici ma config de Nuxt comme conseillé il me semble :
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
srcDir: 'src/',
css: ['maz-ui/css/main.css', '@/assets/main.css'],
build: {
transpile: ['maz-ui'],
},
J'ai ajouté la déclaration du module, mais cela n'a rien changé :
declare module 'maz-ui' {
export * from 'maz-ui/modules'
}
Desktop (please complete the following information):
- OS: Mac OS Ventura
Merci du retour
Salut @TwentyCCent,
Effectivement j'ai fait quelques changements sur la déclaration des types.
Je vais revenir en arrière pour être compatible avec les anciennes stacks qui serait encore avec un "moduleResolution": "Node"
Sinon 2 solutions rapides :
1 - Dans ton tsconfig.json
, tu peux utiliser :
{
"compilerOptions": {
"moduleResolution": "Node16" // or "NodeNext"
}
}
2 - Étant donné que tu es un nuxt user, j'ai récemment sorti un module nuxt qui permet d'avoir l'auto-import des composants et quelques composables, plugins (plus à venir) et avoir la doc directement dans le devtools + les types seront automatiquement déduits :
Suis cette doc : Nuxt Module Documentation
EN
Hi @TwentyCCent,
Actually, I made some changes to the type declaration.
I will go back to be compatible with the old stacks that would still be with a "moduleResolution": "Node"`
Otherwise 2 quick fixes:
1 - In your `tsconfig.json', you can use:
{
"compilerOptions": {
"moduleResolution": "Node16" // or "NodeNext"
}
}
2 - You are a Nuxt user, so I recently released a Nuxt module that allows you to have the auto-import of components and some composables, plugins (more to come) and have the doc directly in the devtools:
Follow this doc: Nuxt Module Documentation
Solved in v3.12.0
Please let me know if it's good for you
Thanks, it works well for the components, both solutions were ok, I upgraded. The library looks excellent, bravo for your work! If I find a moment I'd be interested in contributing.
@TwentyCCent Nice! Thanks you, it's a pleasure to hear!
Yeees! of course, it’s with pleasure that you can contribute! If you some ideas of components, plugins, etc or something else to improve, it's really welcome.