Closed WangJincheng4869 closed 1 year ago
the same problem
添加 noExternal
后可以打包
bundler: viteBundler({
viteOptions: {
plugins: [
// https://github.com/jpkleemans/vite-svg-loader
svgLoader(),
// https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n
VueI18nPlugin({
runtimeOnly: true,
compositionOnly: true,
include: [resolve(__dirname, "../../locales/**")],
}),
],
ssr: {
/**
* 由于在 build 时会报错 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.
* 所以要添加以下配置。详见:https://vite-plugin-ssr.com/common-issues 与 https://vite-plugin-ssr.com/invalid-esm#solution
*/
noExternal: ['vue-i18n']
}
}
}),
This issue is around cjs / esm in bundler, it can be worked around in bundler configuration. vue-i18n is esm first. vue-i18n is esm first and also provides cjs. You can check in the vue-i18n dist
directory.
Thanks!
Reporting a bug?
Expected behavior
运行命令:
pnpm docs:bulid
就会报错,如果时正常运行是可以使用的!Reproduction
https://github.com/WangJincheng4869/fanKuiWenJian/blob/main/%5Bvue-i18n%5D%20-%20vuepress2%20bulid%20error%20--SyntaxError%20-%20Named%20export%20createI18n%20not%20found.zip
System Info