Skip to content

Empty .yml files throw a warnings #202

@Vannsl

Description

@Vannsl

Reporting a bug?

When an empty .yml file gets loaded, the Loader throws a warning when using the webpack loader.

An empty .yml file looking like this:

---

The thrown warning is:

WARNING in ./app/javascript/src/apps/LearningResource/locales/de-DE.yml 1:15
Module parse failed: Unexpected token (1:15)
File was processed with these loaders:
 * ./node_modules/@intlify/vue-i18n-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
> export default 

Expected behavior

There is no warning thrown, but the file is loaded, compiled the yml file to an empty javascript object

Reproduction

  1. Add the vue-i18n-loader via webpack with:
var path = require("path");

module.exports = {
  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, "..", "..", [INSERT YOUR PATH]),
  ],
};
  1. Add an empty yaml file
  2. Run the loader

System Info

Webpack 4 with:

  System:
    OS: macOS 11.5.2
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 2.77 GB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.1 - ~/.nvm/versions/node/v14.17.1/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.13 - ~/.nvm/versions/node/v14.17.1/bin/npm
  Browsers:
    Brave Browser: 93.1.29.76
    Edge: 93.0.961.38
    Firefox: 90.0.2
    Safari: 14.1.2
  npmPackages:
    @intlify/vue-i18n-loader: ^3.0.0 => 3.0.0 
    vue: ^3.2.6 => 3.2.6 
    vue-i18n: ^9.1.7 => 9.1.7

Screenshot

No response

Additional context

No response

Validations

  • Read the Contributing Guidelines
  • Read the README
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions