Skip to content

Reduce bundle size #11

@davestewart

Description

@davestewart

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions