Skip to content

Cannot import message files as ?raw or ?url in Vite #505

@jpritzkau-eepos

Description

@jpritzkau-eepos

Reporting a bug?

For use in a translation tool, I need to import the message files as strings without preprocessing, however this plugin tries to interpret the generated export default ... statement as JSON/YAML/etc.

Expected behavior

As the Vite docs would suggest, it should just import the file contents as a string without any errors.

Reproduction

const messages: Record<string, string> = import.meta.glob("./*.yaml", {
  eager: true,
  base: "./locales",
  query: "?raw",
  import: "default",
});
// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), vueDevTools(), vueI18n({ include: "src/locales/**" }), tailwindcss()],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
});

The resulting error:

4:50:15 PM [vite] Internal server error: Nested mappings are not allowed in compact mappings
  Plugin: unplugin-vue-i18n:resource
  File: /Users/j.pritzkau/dev/playground/vue-i18n/src/locales/jp.yaml?raw
      at Context.throwError (/Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/[email protected]/node_modules/yaml-eslint-parser/lib/context.js:77:15)
      at processDoc (/Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/[email protected]/node_modules/yaml-eslint-parser/lib/yaml-cst-parse.js:16:23)
      at parseAllDocsToCST (/Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/[email protected]/node_modules/yaml-eslint-parser/lib/yaml-cst-parse.js:31:9)
      at parseForESLint (/Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/[email protected]/node_modules/yaml-eslint-parser/lib/parser.js:13:57)
      at parseYAML (/Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/[email protected]/node_modules/yaml-eslint-parser/lib/index.js:57:40)
      at generate (file:///Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/@[email protected][email protected][email protected][email protected]___vue-_16c0f19ce239c6c38c52816c476bcccc/node_modules/@intlify/bundle-utils/lib/index.mjs:853:13)
      at TransformPluginContext.handler (file:///Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]__pe_5bf3e43d53489ca6742509fc90208fd7/node_modules/@intlify/unplugin-vue-i18n/lib/index.mjs:438:54)
      at async file:///Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/[email protected][email protected]_@[email protected][email protected][email protected][email protected]_/node_modules/vite-plugin-inspect/dist/shared/vite-plugin-inspect.BzUKaD4x.mjs:403:17
      at async EnvironmentPluginContainer.transform (file:///Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-C6pp_iVS.js:31320:14)
      at async loadAndTransform (file:///Users/j.pritzkau/dev/playground/vue-i18n/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/vite/dist/node/chunks/dep-C6pp_iVS.js:26407:26)

Issue Package

unplugin-vue-i18n

System Info

System:
    OS: macOS 15.5
    CPU: (8) arm64 Apple M2
    Memory: 200.25 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.3.0 - ~/.nvm/versions/node/v24.3.0/bin/node
    npm: 11.4.2 - ~/.nvm/versions/node/v24.3.0/bin/npm
    pnpm: 10.15.1 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 139.0.7258.155
    Safari: 18.5
  npmPackages:
    vite: ^7.0.6 => 7.1.4 
    vue: ^3.5.18 => 3.5.21 
    vue-i18n: ^11.1.12 => 11.1.12

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions