Closed kevguy closed 3 years ago
I would rather have ES6 with import
and export
without the need of annoying bundlers (rollup). JSDoc will do the type checking.
This is great. @jakesgordon would you be willing to add new community members as maintainers for this library to keep it updated?
how can i install 4.0.0-beta use yarn.
It's cool for the async support. May I ask is there any install guide for this branch?
I've tried using the build script rollup -c
but it cannot build. @kevguy
The error message is as below:
$ /Users/admin/javascript-state-machine/node_modules/.bin/rollup -c
src/app/index.ts → dist/umd/index.js...
[!] (plugin rpt2) Error: /Users/admin/javascript-state-machine/src/jsm.ts(291,44): semantic error TS2343: This syntax requires an imported helper named '__spreadArray' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
src/jsm.ts
Error: /Users/admin/javascript-state-machine/src/jsm.ts(291,44): semantic error TS2343: This syntax requires an imported helper named '__spreadArray' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'.
at error (/Users/admin/javascript-state-machine/node_modules/rollup/dist/shared/rollup.js:158:30)
at throwPluginError (/Users/admin/javascript-state-machine/node_modules/rollup/dist/shared/rollup.js:21784:12)
at Object.error (/Users/admin/javascript-state-machine/node_modules/rollup/dist/shared/rollup.js:22488:20)
at Object.error (/Users/admin/javascript-state-machine/node_modules/rollup/dist/shared/rollup.js:21960:38)
at RollupContext.error (/Users/admin/javascript-state-machine/node_modules/rollup-plugin-typescript2/src/rollupcontext.ts:37:18)
at /Users/admin/javascript-state-machine/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:41:11
at arrayEach (/Users/admin/javascript-state-machine/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:516:11)
at Function._.each [as forEach] (/Users/admin/javascript-state-machine/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9368:14)
at printDiagnostics (/Users/admin/javascript-state-machine/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:9:2)
at Object.transform (/Users/admin/javascript-state-machine/node_modules/rollup-plugin-typescript2/src/index.ts:244:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This is a total rewrite of the whole library in TypeScript, and the changes are almost completely compatible with the original version.
rollup
instead ofwebpack
with three formats:umd
,cjs
andes
.class
.bin/example.js
and the example state machines in theexamples
folder) was modified accordingly and all work.test
folder usingjest
instead ofava
, due toava
requiring changes that conflicts withrollup
(look at this ava issue) in order to support TypeScript.test-js
folder with minimal changes which will be covered later. All test cases passed except one.const machine = StateMachine()
anymore without thenew
keyword. One of the test cases was covering this, which is the case that didn't pass.factory
method to create the machine and you have an base class constructor, you don't need to explicitly runthis._fsm()
in it anymore.apply
method to extend your object to a state machine, you will get a new object instead of mutating the original object, that is runningStateMachine.apply(obj)
and useobj
as it is, you have to doconst newObj = StateMachine.apply(obj)
and usenewObj
instead.All in all, changes are mostly compatible with a few enhancements, and with type support .