vue-i18n-next: SyntaxError: Named export 'createI18n' not found
Reporting a bug?
import { createI18n, useI18n } from "vue-i18n/dist/vue-i18n.runtime.esm-bundler.js";
^^^^^^^^^^
SyntaxError: Named export 'createI18n' not found. The requested module 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js';
const { createI18n, useI18n } = pkg;
Expected behavior
- pnpm install
- pnpm build
- cd apps/docs
- pnpm build
Reproduction
branch: feat/date
https://github.com/huntersofbook/huntersofbook/tree/feat/date
System Info
System:
OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
CPU: (12) x64 11th Gen Intel(R) Core(TM) i5-11400 @ 2.60GHz
Memory: 17.10 GB / 31.12 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 16.17.0 - /usr/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 8.15.0 - /usr/bin/npm
Browsers:
Chrome: 104.0.5112.101
npmPackages:
vitepress: 1.0.0-alpha.10 => 1.0.0-alpha.10
Screenshot
No response
Additional context
No response
Validations
- Read the Contributing Guidelines
- Read the Documentation
- 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
- The provided reproduction is a minimal reproducible example of the bug.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 18 (16 by maintainers)
@productdevbook Thank you as always!
As found out, this issue occurs in builds when SSR is enabled. The
__VUE_PROD_DEVTOOLS__
flag is expected to be set toglobalThis
for vue-i18n.I have tried to enable
__VUE_PROD_DEVTOOLS__
in theconfigure
hook of the vite plugin, but for some reason it is not enabled when SSR. (And I noticed that other flags provided by vue-i18n are not enabled either)I will continue to fix it. Please wait 🙏
I’ve just released out vue-i18n 9.3.0-beta.3 Please check it!
@productdevbook Thank you for your feedback! I’ve just fixed it and send PR, please wait 🙏 https://github.com/intlify/vue-i18n-next/pull/1152
@productdevbook Hello! I’ve just released
@intlify/vite-plugin-vue-i18n
v7.0.0-beta.2 Please check it!I’ve checked your awesome hundersofbook! So, I’ve faced the error in it the below:
I seem that date-fns is not to fully support cjs/mjs vite3 SSR (vitepress) requires esm, so you might want to check if your module is supported as a dual module.
Thank you for your reproduction!
Hmm 🤔 , I could not your reproduction same situation. vitepress v1 alpha is using
vite@v3
, sovite@v3
require native ES modulesvue-i18n v9 is not yet a full native ES modules. So we need to support it.