lljj-x / vue-json-schema-form

基于Vue/Vue3,Json Schema 和 ElementUi/antd/iview3/naiveUi 等生成 HTML Form 表单,用于活动编辑器、h5编辑器、cms等数据配置;支持可视化生成表单Schema 。 Generate a form using Vue/Vue3, Json Schema and ElementUi/antdv/iview3/naiveUi
https://form.lljj.me/
Apache License 2.0
2.01k stars 418 forks source link

vue3-form-core 在vite项目中引用报错 #292

Closed azoth1991 closed 8 months ago

azoth1991 commented 1 year ago

vite.config.ts

  plugins: [vue(), babel({
    exclude: /node_modules\/(?!(@lljj)\/).*/,
    extensions: ['.js', '.vue'],
  }),],
image
lljj-x commented 1 year ago

.vue 后缀问题,配置下 extensions 支持 .vue

lljj-x commented 1 year ago

补充了后缀 可以试试最新版

mice33 commented 11 months ago
✘ [ERROR] No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "default"

    node_modules/@lljj/vjsf-utils/vueUtils.js:5:7:
      5 │ import Vue from 'vue';

也是 vite 项目, 引入的 vue3-form-core, 报错信息如上

@lljj-x

mice33 commented 11 months ago
✘ [ERROR] No matching export in "node_modules/vue/dist/vue.runtime.esm-bundler.js" for import "default"

    node_modules/@lljj/vjsf-utils/vueUtils.js:5:7:
      5 │ import Vue from 'vue';

也是 vite 项目, 引入的 vue3-form-core, 报错信息如上

@lljj-x

查到问题了, 在 vjsf-utils/vue3Utils.js 和 vjsf-utils/formUtils.js 中引用了 vueUtils.js,vueUtils.js 中引入了 Vue2.. 把 vueUtils.js 中的 nodePath2ClassName, isRootNodePath, computedCurPath, getPathVal, path2prop 单独剥离出一个 vue 公共工具 js 就行了 没找到 vjsf-utils 仓库位置, 只能等作者修复了

lljj-x commented 11 months ago

@mice33 对 很有道理,可以贡献就更好了

不过你的使用方式是基于源码导入的吗 ?vue3 utils build之后vue2的导入部分应该是会被rollup shake掉

mice33 commented 11 months ago

@lljj-x 没找到 vjsf-utils 仓库位置。。

嗯对,要基于 vant 写一个只能源码导入了

lljj-x commented 11 months ago

@lljj/vjsf-utils 在这个下面 ,可以按你说的抽出来会更合适

lljj-x commented 11 months ago

https://github.com/lljj-x/vue-json-schema-form/blob/master/packages/lib/utils/vue3Utils.js