store icon indicating copy to clipboard operation
store copied to clipboard

How to import store.on?

Open frangeris opened this issue 8 years ago • 5 comments

First, thanks for this awesome lib..!

I'm using store2 on vue.js without problems, but now I want to import store.on, how to do it?

import Storage from 'store2' // WORKS!

// Uncaught TypeError: Cannot read property '_' of undefined
import StoreOn from 'store2/src/store.on'

So, why not include extensions via "ES6 Destructuring and Module imports"? It could be nice do this:

import Storage, {StoreOn, StoreOverflow, StoreQuota} from 'store2'

Thanks

frangeris avatar Aug 01 '16 19:08 frangeris

Sorry for the belated response, i've been on vacation. :) As for your suggestion, it sounds good, but i've barely dabbled in ES6 so far. I don't know what it would take to make this happen. Got a patch? Or an example?

nbubna avatar Aug 08 '16 05:08 nbubna

Rollup can help on this.

aMarCruz avatar Aug 30 '16 18:08 aMarCruz

Any update on this lib? The last commit is one year ago...

hustcer avatar Oct 10 '16 04:10 hustcer

I still use store2 daily. Works fantastically still. :)

If i needed any changes, i'd be adding them. I don't need/use ES6 imports. I'm happy to take patches or maybe clearer explanations of what needs to be done. Heck, i'd even take money to do this. But i write enterprise open source, it's not an ego/hobby thing. So this issue will be resolved either when i need it for paid work or someone else contributes the changes.

nbubna avatar Oct 10 '16 16:10 nbubna

You can solve this with webpack (or rollup):

Weback:

 resolve: {
    extensions: ['.js'],
    alias: {
      'store2/old': 'store2/src/store.old.js'
    }
  },
  plugins: [
    new webpack.ProvidePlugin({
      'window.store': 'store2',
      'store': 'store2'
    })
  ]

In code:

import store from 'store2';
import 'store2/old';

gregorskii avatar Nov 09 '17 19:11 gregorskii