Current behavior
When a component imports a component that uses vue-i18n in SFC mode the imported component is not rendered instead a comment is shown. I used the Vuetify+i18n example as reference.
To reproduce
See the repository CC Vocabulary and the styleguide.
Here Index imports Hello and Footer both of which are not rendered after I added vue-i18n to them. The components without vue-i18n are working fine. The component Index also works fine when rendered actually on the page indicating that the issue is with Styleguidist in some way. Also I observed that adding Hello or Footer to the code in preview (without having imported Hello or Footer in the .vue file) renders them correctly, indicating that the issue is with import statement.
I am using the Vue CLI plugin for both Vue-i18n and Vue Styleguidist.
"vue-cli-plugin-i18n": "^0.6.0",
"vue-cli-plugin-styleguidist": "^3.13.7"
Expected behavior
The imported component should be shown normally.
Hey @dhruvkb
I checked out your repo and will debug this afternoon,
I hope to find a solution soon.
I found the issue and has some to do with styleguidist and some to do with cc-vocabulary.
// this is how you import the Hello Component
import Hello from '@/path/Hello/Hello'
You intend this instruction to import Hello.vue. Instead it loads Hello.json. This is because the vue-cli has a webpack config that resolves json and vue components all the same.
const webpackConfig = {
resolve: { extensions:
[ '.js',
'.jsx',
'.ts',
'.tsx',
'.json',
'.mjs',
'.js',
'.jsx',
'.vue',
'.json',
'.wasm' ]
}
}
Having files names only differ by their extensions is not a good practice overall.
You have 2 ways of fixing this:
import Hello from '@/path/Hello/Hello.vue'Hello.json to lang.json or lg.jsonI even made a quick PR to illustrate my favourite fix.
Thank you so much!
Most helpful comment
I found the issue and has some to do with styleguidist and some to do with cc-vocabulary.
You intend this instruction to import
Hello.vue. Instead it loadsHello.json. This is because the vue-cli has a webpack config that resolves json and vue components all the same.Having files names only differ by their extensions is not a good practice overall.
You have 2 ways of fixing this:
import Hello from '@/path/Hello/Hello.vue'Hello.jsontolang.jsonorlg.json