Skip to content

Config file not loading correctly when using "type": "module" in package.json #225

@QbDesu

Description

@QbDesu

Let's keep this brief. When in module mode the config doesn't work as expected. This has 2 problems to be more specific.

  1. The init command still generates a config in CJS format, which just means it just appears as an empty config when loaded. The config object it loads will just look like this:
{
  "--": [],
  "exclude": [
    null
  ]
}
  1. The script doesn't select the default export so it won't read any of the options as you may expect. The expected way will not work:
export default {
  "vueFiles": "./src/**/*.?(js|vue)",
  "languageFiles": "./lang/**/*.?(json|yaml|yml|js)",
  "exclude": [],
  "output": false,
  "add": false,
  "remove": false,
  "ci": false,
  "separator": ".",
  "noEmptyTranslation": ""
}
// the loaded config looks like this
{
  "__esModule": true,
  "default": {
    "vueFiles": "./src/**/*.?(js|vue)",
    "languageFiles": "./lang/**/*.?(json|yaml|yml|js)",
    "exclude": [],
    "output": false,
    "add": false,
    "remove": false,
    "ci": false,
    "separator": ".",
    "noEmptyTranslation": ""
  },
  "--": [],
  "exclude": [
    null
  ]
}

Instead you'll have to write it like this:

export const vueFiles = './src/**/*.?(js|vue)'
export const languageFiles = './src/lang/**/*.?(json|yaml|yml|js)'
export const exclude = []
export const output = false
export const add = false
export const remove = false
export const ci = false
export const separator = '.'
export const noEmptyTranslation = ''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions