intlify / intlify/bundle-tools

Build fails with rolldown:vite-resolve, messages not exported under conditions

Open
#600 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
270
Forks
46
PR merge metrics
No merged PRs in 30d

Description

### Reporting a bug?

In `dev` mode everything works fine, but when trying to build using `vite build`, I get the following error:

Error message from vite build

```bash
error during build:
Build failed with 1 error:

[rolldown:vite-resolve] plugin `rolldown:vite-resolve` threw an error

Caused by:
"./messages" is not exported under the conditions ["module", "browser", "production", "import"] from package /project-folder-path/node_modules/@intlify/unplugin-vue-i18n (see exports field in /project-folder-path/node_modules/@intlify/unplugin-vue-i18n/package.json)

at aggregateBindingErrorsIntoJsError (file:///project-folder-path/node_modules/rolldown/dist/shared/error-BzLGqhSQ.mjs:48:18)
at unwrapBindingResult (file:///project-folder-path/node_modules/rolldown/dist/shared/error-BzLGqhSQ.mjs:18:128)
at #build (file:///project-folder-path/node_modules/rolldown/dist/shared/rolldown-I5b6h5Km.mjs:132:34)
at async buildEnvironment (file:///project-folder-path/node_modules/vite/dist/node/chunks/node.js:33669:66)
at async Object.build (file:///project-folder-path/node_modules/vite/dist/node/chunks/node.js:34091:19)
at async buildSW (file:///project-folder-path/node_modules/vite-plugin-pwa/dist/vite-build-BGK4YAIU.js:22:3)
at async generateInjectManifest (file:///project-folder-path/node_modules/vite-plugin-pwa/dist/index.js:224:3)
at async _generateSW (file:///project-folder-path/node_modules/vite-plugin-pwa/dist/index.js:232:5)
at async PluginContextImpl.handler (file:///project-folder-path/node_modules/vite-plugin-pwa/dist/index.js:427:13)
at async plugin (file:///project-folder-path/node_modules/rolldown/dist/shared/bindingify-input-options-CMab5gbt.mjs:1721:3) {
errors: [Getter/Setter],
code: 'PLUGIN_ERROR',
plugin: 'vite-plugin-pwa:build',
hook: 'closeBundle'
}
```

Is there a conflict with the `vite-plugin-pwa` package?

### Expected behavior

No build errors and working as in development mode.

### Reproduction

Below the messages are imported:
```typescript
// i18n.ts
import messages from '@intlify/unplugin-vue-i18n/messages'

export const createCustomI18n = (locale?: string) => createI18n({
locale: navigator.language,
messages,
legacy: false,
globalInjection: true,
});
```

The following options are set on the plugin in vite.config.ts:
```typescript
// vite.config.ts
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'

export default defineConfig({
plugins: [
VueI18nPlugin({
include: [path.resolve(import.meta.dirname, 'src/locales/**')],
treeShaking: true,
})
]
})
```

### Issue Package

vite-plugin-vue-i18n

### System Info

```shell
System:
OS: Linux 6.8 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
CPU: (8) x64 Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
Memory: 4.95 GB / 15.44 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 26.2.0 - /home/user/.nvm/versions/node/v26.2.0/bin/node
npm: 12.0.2 - /home/user/.nvm/versions/node/v26.2.0/bin/npm
Browsers:
Firefox: 153.0.3
Firefox Developer Edition: 153.0.3
npmPackages:
vite: ^8.2.0 => 8.2.0
vue: ^3.5.41 => 3.5.41
vue-i18n: ^11.4.8 => 11.4.8
```

### Screenshot

_No response_

### Additional context

_No response_

### Validations

- [x] Read the [Contributing Guidelines](https://github.com/intlify/bundle-tools/blob/main/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

Research direction

Start by reproducing the failure with `vite build` using the imports in `i18n.ts` and the VueI18nPlugin settings in `vite.config.ts`. Inspect the `exports` field in `node_modules/@intlify/unplugin-vue-i18n/package.json` and the reported resolver conditions; done means the build completes successfully while development mode and message imports continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.