Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing problems #67

Open
paglias opened this issue May 27, 2017 · 11 comments
Open

Importing problems #67

paglias opened this issue May 27, 2017 · 11 comments
Assignees

Comments

@paglias
Copy link

paglias commented May 27, 2017

Hi,

thanks for this library!

I'm having some problems importing only one picker

import ColorPicker from 'vue-color/src/components/Compact';

fails in my project (with webpack, and vue-loader installed) with this error:

This dependency was not found:

* !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../../vue-loader/lib/style-compiler/index?{"id":"data-v-ade7e162","scoped":false,"hasInlineConfig":false}!stylus-loader?{"sourceMap":false}!../../../vue-loader/lib/selector?type=styles&index=0!./Compact.vue in ./~/vue-color/src/components/Compact.vue

To install it, you can run: npm install --save !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../../vue-loader/lib/style-compiler/index?{"id":"data-v-ade7e162","scoped":false,"hasInlineConfig":false}!stylus-loader?{"sourceMap":false}!../../../vue-loader/lib/selector?type=styles&index=0!./Compact.vue

Importing with

import { Compact as ColorPicker } from 'vue-color';

works but it loads the entire library and not just the Compact picker

Thanks

@2one2
Copy link

2one2 commented Jun 12, 2017

I'm having the same problem... @paglias have you solved this?

@cassioscabral
Copy link
Collaborator

Are you sure that it's loading the entire library using
import { Compact as ColorPicker } from 'vue-color'; ?

We are exporting each component individually, importing like that should import only the component, not the whole library.

@paglias
Copy link
Author

paglias commented Jun 12, 2017

@2one2 I think I ended up importing the whole project because importing a single file doesn't work and import { Compact as ColorPicker } from 'vue-color'; imports the entire project anyway because it's compiled as an es5 module and not exported using es6

@2one2
Copy link

2one2 commented Jun 12, 2017

@paglias thanks

@cassioscabral yes importing with import { Compact as ColorPicker } from 'vue-color'; imports entire library... with webpack

@linx4200
Copy link
Collaborator

@paglias Can I ask did you install stylus-loader in your project? Need more information to debug.

@paglias
Copy link
Author

paglias commented Jul 24, 2017

@linx4200 no, I don't use stylus-loader

@linx4200
Copy link
Collaborator

linx4200 commented Jul 24, 2017

@paglias Thanks for the reply. Would fix this problem asap.

xiaokaike added a commit that referenced this issue Jul 29, 2017
@linx4200
Copy link
Collaborator

Fixed.
Please upgrade to the latest version.
Now you can import component individually. For example import compact from 'vue-color/src/components/Compact.vue';.

@frandiox
Copy link

Similar issue here but with babel-preset-es2015.

For the record, install it in your project (npm install babel-preset-es2015) and change vue-loader options in Webpack:

{
  test: /\.vue$/,
  loader: 'vue-loader',
  options: {
    // your options here,
    presets : [
      require.resolve('babel-preset-es2015')
    ]
  }
}

In addition, since there is a mixin/color.js file (non vue file) which also needs transpilation:

{
  test: /\.js$/,
  loader: 'babel-loader',
  options: {
    presets : [
      require.resolve('babel-preset-es2015')
    ]
  }
}

@linx4200 Perhaps this could be fixed in a new version? Providing an ESM ready folder would be ideal but might be a bit hard. I think using babel-preset-env, which is more common than babel-preset-es2015, is easier. Also, color.js would need to be full ES5. I think the only required change in that regard is syntax like this:

{
  data() {
  }
}

Should be:

{
  data: function() {
  }
}

Same for computed props, watch and methods.

@linx4200
Copy link
Collaborator

linx4200 commented Jan 31, 2018

@frandiox mixin/color.js is compiled by babel before release, so I think it is ES5 ready.

@linx4200
Copy link
Collaborator

Will use babel-preset-env in the next release, and provide ESM ready component in 3.0, which we are working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants