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

Failed to load .yaml

Open tarkhil opened this issue 5 years ago • 2 comments

According to manual, I've set up webpack as

  rules: [
    {
      test: /\.(json5?|ya?ml)$/, // target json, json5, yaml and yml files
      type: "javascript/auto",
      loader: "@intlify/vue-i18n-loader",
      include: [
        // Use `Rule.include` to specify the files of locale messages to be pre-compiled
        path.resolve(__dirname, "./src/locale")
      ]
    }
  ]

and json files are loaded just fine, but attempt to load yaml yields

TS2307: Cannot find module './locale/en.yaml' or its corresponding type declarations.

Of course I can stick with json or even js for locales, buy yaml is just much simpler to write...

tarkhil avatar Dec 24 '20 21:12 tarkhil

This is a TypeScript error, not a runtime one. Create a shim file. Eg.

declare module '*.yaml' {
  const json: Record<string, string>;
  export default json;
}

IlCallo avatar Jun 21 '21 16:06 IlCallo

@tarkhil Thank you for your feedback!

Unfortunately, I could not reproduce your reporting info. We need more of your environment (e.g Vue.js version, Vue I18n version, and more..) info to reproduce it.

Could you give us the reproduction code or repo, please?

PeterAlfredLee avatar Aug 16 '21 08:08 PeterAlfredLee

vue-i18n-loader will be deprecated near the future We can use unplugin-vue-i18n Thanks

kazupon avatar Nov 16 '22 01:11 kazupon