Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
MinatoHikari opened this issue Mar 22, 2023 · 3 comments · Fixed by #248
Open
4 tasks done

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

MinatoHikari opened this issue Mar 22, 2023 · 3 comments · Fixed by #248

Comments

@MinatoHikari
Copy link

MinatoHikari commented Mar 22, 2023

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.
@MinatoHikari MinatoHikari added the Status: Review Needed Request for review comments label Mar 22, 2023
Copy link
Member

kazupon commented Mar 22, 2023

Thank you for your reporting!

Ah…
I’ve forgot for the case where the message functions were directly in the locale 😅
I'll fix this issue.

@MinatoHikari
Copy link
Author

Thank you for your reporting!

Ah… I’ve forgot for the case where the message functions were directly in the locale 😅 I'll fix this issue.

hello, ite seems that you also forgot the import of ts files.

import homepage from './pages/homepage/index';
homepage: {
       homepage: homepage.homepage.zhCN,
 },

@MinatoHikari
Copy link
Author

@kazupon

@kazupon kazupon reopened this Apr 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants