intlify / intlify/bundle-tools

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

Open
#245 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
270
Forks
46
PR merge metrics
No merged PRs in 30d

Description

### Reporting a bug?

when I use function like
```ts
pagination: {
pages: ({ named }: Parameters[0]) => `${named('number')}/page`,
total: ({ named }: Parameters[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:
```js
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)
 ELIFECYCLE  Command 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
```js
pnpm i
pnpm run build
```
Process will end with an error.

Change `@intlify/unplugin-vue-i18n` version to 0.8.2.
```js
pnpm i
pnpm run build
```
Every thing works well.

### Issue Package

unplugin-vue-i18n

### System Info

```shell
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

- [X] Read the [Contributing Guidelines](https://github.com/intlify/bundle-tools/blob/main/.github/contributing.md).
- [X] Read the README
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/intlify/bundle-tools/discussions).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.