lostpebble / pullstate

Simple state stores using immer and React hooks - re-use parts of your state by pulling it anywhere you like!

Home Page:https://lostpebble.github.io/pullstate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Include umd bundle

prabirshrestha opened this issue · comments

Is it possible to provide UMD bundle similar to how immer provides one https://unpkg.com/browse/immer@7.0.7/dist/?

this would allow to easily consume the plugin in jsbin or jsfiddle.

pullstate.umd.development.js and pullstate.umd.production.min.js

Hi @prabirshrestha ,

Thanks for the suggestion! I'll look into adding this soon. Will have to see how easy it is to achieve with rollup.

This is the rollup config I'm currently using generate umd module.

rollup.config.js

import resolve from 'rollup-plugin-node-resolve';
import commonJS from 'rollup-plugin-commonjs';
import ignore from 'rollup-plugin-ignore';
import replace from 'rollup-plugin-replace';

export default {
    input: 'main.js',
    external: ['react', 'immer'],
    output: {
        file: 'pullstate.js',
        format: 'umd',
        name: 'pullstate',
        globals: {
            'react': 'React',
            'immer': 'immer'
        }
    },
    plugins: [
        resolve(),
        replace({
            'process.env.NODE_ENV': 'production'
        }),
        commonJS({}),
    ]
}

main.js:

import * as pullstate from 'pullstate';

export default pullstate;

This embeds fast-deep-equal since it doesn't have umd version but makes immer and react as external module.

Hi @prabirshrestha ,

Can you check out https://unpkg.com/pullstate@1.16.2/dist/pullstate.umd.js and see if this is all working for your needs?

It works.

It is missing the minified version i.e. pullstate.umd.min.js.

Not required but might be good to use pullstate.umd.development.js and pullstate.umd.production.min.js to align with react and immer naming patterns.

Okay cool, thanks I will look into that.

In the recent update, I've added in the minimized UMD module as well:

https://unpkg.com/pullstate@1.17.0/dist/pullstate.umd.min.js

So, think we can close this - Pullstate doesn't have any development / production differences, so until then - just the one plain and minimized module will be available.