javascript-state-machine icon indicating copy to clipboard operation
javascript-state-machine copied to clipboard

Reduce bundle size

Open davestewart opened this issue 7 years ago • 0 comments

The minified bundle is 25K, which I think is too big.

It would be nice to reduce this, either at source or by optimising for tree-shaking.

Extract DSL parsing to a separate class

The StateMachine class would then only take Object config. String options could be pre-processed and saved as JSON, then used in size-critical builds:

import { parse } from 'state-machine'
const config = parse(options) // could be saved as json
var fsm = new StateMachine(config)

Another option might be to create this using a plugin system like Vue, i.e.:

StateMachine.use(ParseConfig)

All files needed for parsing config would then be omitted from the final bundle.

Could do some rudimentary tests first to see the impact

Refactor to be simpler

Right now, ValueMap is used to set and get values. Could this be simplified, or target nodes targeted using concatenation rather than parsing, then the class omitted?

var target = transitions[foo][bar]

Should check the code to see how much of an impact this actually is. Could be a tradeoff too far.

Reduce lines of code

Not sure how feasible this is

davestewart avatar Jun 22 '17 08:06 davestewart