vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.75k stars 6.33k forks source link

Importing element-ui on demand fails #739

Closed cristijora closed 6 years ago

cristijora commented 6 years ago

Version

3.0.0-alpha.4

Reproduction link

https://github.com/cristijora/vue-cli-element-ui

Steps to reproduce

This is most likely a babel/babel-plugin-component related issue but since element-ui is widely used, though that reporting here might be useful.

  1. Init repo
  2. Try to run yarn serve

What is expected?

Babel plugin component installation doesn't fail

What is actually happening?

https://www.npmjs.com/package/babel-plugin-component The plugin is not applied and the webpack server fails.

Module build failed: Error: .plugins[0][1] must be an object, false, or undefined at assertPluginItem (/Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/validation/option-assertions.js:155:15) at /Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/validation/option-assertions.js:132:14 at Array.forEach () at assertPluginList (/Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/validation/option-assertions.js:131:9) at /Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/validation/options.js:83:20 at Array.forEach () at validate (/Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/validation/options.js:61:21) at /Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/config-chain.js:136:36 at cachedFunction (/Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/caching.js:40:17) at init (/Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/config-chain.js:117:12) at /Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/config-chain.js:201:17 at buildRootChain (/Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/config-chain.js:82:20) at loadConfig (/Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/config/index.js:50:53) at transformSync (/Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/transform-sync.js:13:36) at Object.transform (/Users/cristij/CreativeTim/new-proj/node_modules/@babel/core/lib/transform.js:20:65) at transpile (/Users/cristij/CreativeTim/new-proj/node_modules/babel-loader/lib/index.js:55:20) at Object.module.exports (/Users/cristij/CreativeTim/new-proj/node_modules/babel-loader/lib/index.js:179:20)

@ multi (webpack)-dev-server/client?http://localhost:8082/ (webpack)/hot/dev-server.js ./src/main.js


Opened an issue on babel-plugin-component as well. https://github.com/ElementUI/babel-plugin-component/issues/30 If this is not related to vue-cli, we can redirect there

yyx990803 commented 6 years ago

This is most likely because babel-plugin-component is not yet compatible with babel 7.

yyx990803 commented 6 years ago

Nevermind - your .babelrc is not passing plugin options correctly - there's an extra set of square brackets around the options for babel-plugin-component.

cristijora commented 6 years ago

Thanks. Will make a PR to element-ui docs

omidkrad commented 5 years ago

Hi @cristijora, now with CLI 3 you can do vue add element. I recommend using that for your Vue Paper Dashboard template. 😉