Coder Social home page Coder Social logo

Comments (6)

yck-rgb avatar yck-rgb commented on April 28, 2024 3

webpack配置里的resolve:{
alias:{
vue$: "vue/dist/vue.esm.js",
}
}

改成这样就好了,在之前的issus里看到的解决方案,但不知道为什么要这样改

from element.

godky avatar godky commented on April 28, 2024 2

cjs和esm混用导致的。配置alias之后,vue指向了用一个源。如果不配置alias,则按照nodejs默认规则解析,element-ui/lib内使用的vue是vue/dist/dist/vue.runtime.common.js,而源码中 import Vue from vue 指向了 vue/dist/vue.runtime.esm.js,从而使用的不是同一个Vue构造函数。在vite中经过了 esbuild@rollup/plugin-commonjs 转换,cjs导入变成了esm导入,所以表现正常。结合以上分析,把入口import Vue from vueconst Vue = require('vue')之后,即使不配置alias的情况下,同样会表现正常。

from element.

luoriwusheng-xia avatar luoriwusheng-xia commented on April 28, 2024 1

在 rspack看+ vue2 也是空白的

懵逼的

from element.

damaohub avatar damaohub commented on April 28, 2024

webpack配置里的resolve:{ alias:{ vue$: "vue/dist/vue.esm.js", } }

改成这样就好了,在之前的issus里看到的解决方案,但不知道为什么要这样改

引用完整版的vue:参考官方文档
问题是为什么要引入完整版,为什么需要在运行时编译模版?

from element.

yck-rgb avatar yck-rgb commented on April 28, 2024

webpack配置里的resolve:{ alias:{ vue$: "vue/dist/vue.esm.js", } }webpack解析器:{别名:{视图$:"vue/dist/vue.esm.js",} }
改成这样就好了,在之前的issus里看到的解决方案,但不知道为什么要这样改

引用完整版的vue:参考官方文档 问题是为什么要引入完整版,为什么需要在运行时编译模版?

我也不知道为什么

from element.

yck-rgb avatar yck-rgb commented on April 28, 2024

cjs和esm混用导致的。配置alias之后,vue指向了用一个源。如果不配置alias,则按照nodejs默认规则解析,element-ui/lib内使用的vue是vue/dist/dist/vue.runtime.common.js,而源码中 import Vue from vue 指向了 vue/dist/vue.runtime.esm.js,从而使用的不是同一个Vue构造函数。在vite中经过了 esbuild@rollup/plugin-commonjs 转换,cjs导入变成了esm导入,所以表现正常。结合以上分析,把入口import Vue from vueconst Vue = require('vue')之后,即使不配置alias的情况下,同样会表现正常。

大佬很强 不明觉厉

from element.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.