Skip to content

Unexpected token error after 0.9.0 @intlify/unplugin-vue-i18n  #245

Open
@MinatoHikari

Description

@MinatoHikari

Reporting a bug?

when I use function like

pagination: {
    pages: ({ named }: Parameters<MessageFunction>[0]) => `${named('number')}/page`,
    total: ({ named }: Parameters<MessageFunction>[0]) => `${named('number')} records in total`,
},
confirm: {
    confirm_deletion: 'confirm deletion?',
    confirm_void: 'confirm void?',
    confirm_release: 'confirm release?',
    ack: 'ack',
    cancel: 'cancel',
    non_records: 'Please choose at least one record',
},

I get an error when run vite build:

Unexpected token (Note that you need plugins to import files that are not JavaScript)
file: /xxx/locales/en-US.ts:116:3
114:   "pagination": {
115:     
116:   }"confirm": {
        ^
117:     "confirm_deletion": (ctx) => {const { normalize: _normalize } = ctx;return _normalize(["confirm deletion?"])},
118:     "confirm_void": (ctx) => {const { normalize: _normalize } = ctx;return _normalize(["confirm void?"])},
error during build:
RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript)
    at error (file:///xxx/node_modules/.pnpm/rollup@3.18.0/node_modules/rollup/dist/es/shared/node-entry.js:2105:30)
    at Module.error (file:///xxx/node_modules/.pnpm/rollup@3.18.0/node_modules/rollup/dist/es/shared/node-entry.js:13174:16)
    at Module.tryParse (file:///xxx/node_modules/.pnpm/rollup@3.18.0/node_modules/rollup/dist/es/shared/node-entry.js:13851:25)
    at Module.setSource (file:///xxx/node_modules/.pnpm/rollup@3.18.0/node_modules/rollup/dist/es/shared/node-entry.js:13461:39)
    at ModuleLoader.addModuleSource (file:///xxx/node_modules/.pnpm/rollup@3.18.0/node_modules/rollup/dist/es/shared/node-entry.js:23422:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)ELIFECYCLECommand failed with exit code 1.

Expected behavior

Every thing works well in 0.8.2 with same resource above.

Reproduction

https://github.com/MinatoHikari/unplugin-i18n-bug

pnpm i
pnpm run build

Process will end with an error.

Change @intlify/unplugin-vue-i18n version to 0.8.2.

pnpm i
pnpm run build

Every thing works well.

Issue Package

unplugin-vue-i18n

System Info

System:
    OS: macOS 13.2.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 198.56 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/.volta/tools/image/node/18.15.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 9.5.0 - ~/.volta/tools/image/node/18.15.0/bin/npm
  Browsers:
    Chrome: 111.0.5563.64
    Chrome Canary: 113.0.5667.3
    Firefox Developer Edition: 112.0
    Safari: 16.3
  npmPackages:
    rollup: 3.18.0 => 3.18.0 
    vite: ^4.2.1 => 4.2.1 
    vue: ^3.2.47 => 3.2.47 
    vue-i18n: ^9.2.2 => 9.2.2

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