No matching export in "node_modules/xxx/vue/dist/vue.runtime.esm-bundler.js" for import "isInSSRComponentSetup"
Opened this issue · 0 comments
tofrankie commented
发行方式
None
具体平台
App 端,在编译阶段报错
开发环境
macOS
项目创建方式
CLI命令行
依赖版本
HBuilderX:4.76.2025073103-alpha
uniapp 相关依赖版本:
{
"name": "uniapp-simple-demo",
"version": "0.0.1",
"scripts": {
"dev:app-plus": "uni -p app-plus",
"build:app-plus": "uni build -p app-plus"
},
"dependencies": {
"@dcloudio/uni-app": "3.0.0-4070620250821001",
"@dcloudio/uni-app-harmony": "3.0.0-4070620250821001",
"@dcloudio/uni-app-plus": "3.0.0-4070620250821001",
"@dcloudio/uni-components": "3.0.0-4070620250821001",
"@dcloudio/uni-h5": "3.0.0-4070620250821001",
"@dcloudio/uni-mp-alipay": "3.0.0-4070620250821001",
"@dcloudio/uni-mp-baidu": "3.0.0-4070620250821001",
"@dcloudio/uni-mp-jd": "3.0.0-4070620250821001",
"@dcloudio/uni-mp-kuaishou": "3.0.0-4070620250821001",
"@dcloudio/uni-mp-lark": "3.0.0-4070620250821001",
"@dcloudio/uni-mp-qq": "3.0.0-4070620250821001",
"@dcloudio/uni-mp-toutiao": "3.0.0-4070620250821001",
"@dcloudio/uni-mp-weixin": "3.0.0-4070620250821001",
"@dcloudio/uni-mp-xhs": "3.0.0-4070620250821001",
"@dcloudio/uni-quickapp-webview": "3.0.0-4070620250821001",
"vue": "3.4.21",
"vue-i18n": "^9.1.9"
},
"devDependencies": {
"@dcloudio/types": "3.4.21",
"@dcloudio/uni-automator": "3.0.0-4070620250821001",
"@dcloudio/uni-cli-shared": "3.0.0-4070620250821001",
"@dcloudio/uni-stacktracey": "3.0.0-4070620250821001",
"@dcloudio/vite-plugin-uni": "3.0.0-4070620250821001",
"@vue/runtime-core": "3.4.21",
"vite": "5.2.8"
}
}问题描述
在 App 端使用 renderjs,发现在 renderjs script 块中导入 @dcloudio/uni-app 就会报错:
<script lang="renderjs" module="renderjs">
import { formatAppLog } from '@dcloudio/uni-app'
// ...
</script>完整示例看 uniapp-simple-demo
$ pnpm dev:app-plus
> uniapp-simple-demo@0.0.1 dev:app-plus /Users/frankie/Web/Git/uniapp-simple-demo
> uni -p app-plus
请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。
编译器版本:4.76(vue3)
正在编译中...
✘ [ERROR] No matching export in "node_modules/.pnpm/vue@3.4.21/node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "isInSSRComponentSetup"
node_modules/.pnpm/@dcloudio+uni-app@3.0.0-4070620250821001_@dcloudio+types@3.4.21_postcss@8.5.6_rollup@4.50.2_vue@3.4.21/node_modules/@dcloudio/uni-app/dist/uni-app.es.js:1:46:
1 │ import { shallowRef, ref, getCurrentInstance, isInSSRComponentSetup, injectHook } from 'vue';
╵ ~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] No matching export in "node_modules/.pnpm/vue@3.4.21/node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "injectHook"
node_modules/.pnpm/@dcloudio+uni-app@3.0.0-4070620250821001_@dcloudio+types@3.4.21_postcss@8.5.6_rollup@4.50.2_vue@3.4.21/node_modules/@dcloudio/uni-app/dist/uni-app.es.js:1:69:
1 │ import { shallowRef, ref, getCurrentInstance, isInSSRComponentSetup, injectHook } from 'vue';
╵ ~~~~~~~~~~
[plugin:uni:app-vue-renderjs] Build failed with 2 errors:
node_modules/.pnpm/@dcloudio+uni-app@3.0.0-4070620250821001_@dcloudio+types@3.4.21_postcss@8.5.6_rollup@4.50.2_vue@3.4.21/node_modules/@dcloudio/uni-app/dist/uni-app.es.js:1:46: ERROR: No matching export in "node_modules/.pnpm/vue@3.4.21/node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "isInSSRComponentSetup"
node_modules/.pnpm/@dcloudio+uni-app@3.0.0-4070620250821001_@dcloudio+types@3.4.21_postcss@8.5.6_rollup@4.50.2_vue@3.4.21/node_modules/@dcloudio/uni-app/dist/uni-app.es.js:1:69: ERROR: No matching export in "node_modules/.pnpm/vue@3.4.21/node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "injectHook"
at pages/index/index.vue:1:0uni-app.es.js 中 import 了 vue 的 isInSSRComponentSetup 和 injectHook,但是 vue 指向了 vue.runtime.esm-bundler.js,它并没有导出这两个方法,所以报错了~
社区上与 isInSSRComponentSetup 和 injectHook 报错的问题还挺多的,here
重现步骤
按以下步骤,编译就能复现:
$ git clone -b renderjs https://github.com/tofrankie/uniapp-simple-demo.git
$ pnpm install
$ pnpm dev:app-plus期望行为
- 在 renderjs script 内导入 @dcloudio/uni-app(且允许在 renderjs 中使用的)方法可以正常编译。
<script lang="renderjs" module="renderjs">
import { formatAppLog } from '@dcloudio/uni-app' // ✅
// ...
</script>PS: 这里 formatAppLog 只是为了举例说明问题,更多的用法可能是第二种。
- 在 renderjs script 内导入其他模块方法(以尽可能复用逻辑),该模块又导入了 @dcloudio/uni-app,也可以正常编译。
<script lang="renderjs" module="renderjs">
import { methodA } from './utils' // ✅
// ...
</script>// utils.js
import { formatAppLog } from '@dcloudio/uni-app'
export function methodA() {
// do something
}
export function methodB() {
formatAppLog('warn', 'index.vue', 'test')
}实际行为
这样使用编译报错(报错信息前面已列举,这里就不重复了)
<script lang="renderjs" module="renderjs">
import { formatAppLog } from '@dcloudio/uni-app' // ❌
// ...
</script>完整 renderjs 使用示例请看 index.vue
截图或录屏
No response