Closed mmikitka closed 7 years ago
Hey,
Thanks for checking out the package.
Sorry you're having integration issues. I have to admit this end of the toolchain is something I'm not the best at.
When I wrote this last year, I didn't have any Node experience; I have a little now, so I might be able to help. Can you point or post to a sample Node setup I could setup or clone, and I'll take a look to see how I can get it working?
I have some time tomorrow, so I might be able to crack it.
Cheers, Dave
@davestewart - thanks for the quick response.
To reproduce the issue, I recommend running the following commands in a vanilla Node 6.x (LTS) and Node 7.x (active) Docker container:
require('state-machine'); var fsm = new StateMachine({}); EOF
(Then repeat with node:7)
Also, to simplify the installation process, is there any way to reduce the number of dependencies? When I run npm install, 550 packages are installed. I realize that most of these are > grand-children, but the number can be reduced by ensuring a minimal set of dependencies. Perhaps remove the Babel dependency in favour of ES2015 native?
Thanks for your help.
Thanks for the detailed instructions.
Just trying to release another project right now, but hopefully I can find time to fit this in.
As for the node dependencies, I'm pretty sure this is because my install instructions specify GitHub. Once I push this to npm, I think I can set the src folder to be ignored and you'll only get the stuff you need.
Cheers, Dave
Hey Matt,
Sorry that it seems I've been ignoring this issue; I've been in the process of securing a (really nice) NPM package name to publish to, which I think will solve the issue.
Hoping to have this resolved by next week, so if you're still looking to use StateMachine, hopefully I'll have good news for you 😄
OK, this is finally fixed! Sorry for the wait...
So I managed to secure the NPM package name state-machine
and have configured it to publish only the main libs:
You should now be able to install directly from NPM, with a tiny download, and import StateMachine directly:
Let me know if this all works for you, as it's only my second NPM package.
EDIT: I've just realised that this may not work for you, as I think node 6 uses require()
and mymain
file index.js
uses import. Let me know if this is the next thing we need t fix..
Cheers, Dave
@davestewart Thanks for following-up on this. I am still seeing an exception on the 'import' call - perhaps due to the lack of webpack.config.js and a reference to the Bable loader (I notice that the "build" script in package.json invokes webpack)?
Ideally, the steps in my second comment, (re: Docker) work without exception.
Thanks,
Hey,
Yes, it is indeed the build process that is the stumbling block here, I need to take some time to work out how best to build a multi-part library. I think it's this, so I'l need to update webpack:
I might even switch to use Rollup, but I need to find the time to test the damn stuff.
On the plus side, I've got a workflow sorted now where I can test the package install locally with node, so that bit shouldn't trip me up anyway.
OK, so have finally got a build where it all works!
The code from Node is:
var StateMachine = require('state-machine').StateMachine;
In ES6, the main files are imported as:
import { StateMachine, StateHelper } from 'state-machine'
In the browser, StateMachine
and StateHelper
are loaded as globals.
I'll try and find time to update the demo and publish this today, and we should be good to go!
Thanks for being so patient 😝
Thanks, Dave
On Wed, Jun 21, 2017 at 6:04 AM, Dave Stewart notifications@github.com wrote:
So I've got a version working where I pack everything into a single file main.js and the code from node would be:
var StateMachine = require('state-machine').StateMachine; var fsm = new StateMachine({});
In ES6, the main files are imported as:
import { StateMachine, StateHelper } from 'state-machine'
In the browser, StateMachine and StateHelper are loaded as globals.
So I'm pretty sure this works, thought I need to double-check the ES6 import.
I'll try and find time to do this today, and we should be good to go!
Thanks for being so patient 😝
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davestewart/javascript-state-machine/issues/9#issuecomment-310032205, or mute the thread https://github.com/notifications/unsubscribe-auth/AB7vmfPRjhfpRsESDfIS3AU0QFbI1uOWks5sGOq3gaJpZM4NUbX3 .
OK - all done now!
npm install state-machine
Seems to work fine on my tests and RunKit:
var StateMachine = require("state-machine").StateMachine
var fsm = new StateMachine({transitions:[
'next: a > b > c'
]});
fsm.go('b')
fsm.go('c')
fsm.go('a')
console.log(fsm.state)
I'll close this as fixed, but feel free to reopen if it's not working for you.
And, thanks for raising the issue and your support in helping me to fix it.
@davestewart Works for me, as well.
$ docker run -it node:6 /bin/bash root@5b11a1de243f:/# mkdir -p /tmp/node-fsm root@5b11a1de243f:/# cd /tmp/node-fsm root@5b11a1de243f:/tmp/node-fsm# npm install state-machine npm info it worked if it ends with ok npm info using npm@3.10.10 npm info using node@v6.10.3 npm info attempt registry request try #1 at 12:44:16 PM npm http request GET https://registry.npmjs.org/state-machine npm http 200 https://registry.npmjs.org/state-machine npm info addNameTag [ 'state-machine', 'latest' ] npm info retry fetch attempt 1 at 12:44:16 PM npm info attempt registry request try #1 at 12:44:16 PM npm http fetch GET https://registry.npmjs.org/state-machine/-/state-machine-1.0.1.tgz npm http fetch 200 https://registry.npmjs.org/state-machine/-/state-machine-1.0.1.tgz npm info lifecycle state-machine@1.0.1~preinstall: state-machine@1.0.1 npm info linkStuff state-machine@1.0.1 npm info lifecycle state-machine@1.0.1~install: state-machine@1.0.1 npm info lifecycle state-machine@1.0.1~postinstall: state-machine@1.0.1 /tmp/node-fsm `-- state-machine@1.0.1
npm WARN enoent ENOENT: no such file or directory, open '/tmp/node-fsm/package.json' npm WARN node-fsm No description npm WARN node-fsm No repository field. npm WARN node-fsm No README data npm WARN node-fsm No license field. npm info ok
root@5b11a1de243f:/tmp/node-fsm# cat <
test.js var StateMachine = require("state-machine").StateMachine; var fsm = new StateMachine({transitions:['next: a > b > c']}); fsm.go('b'); fsm.go('c'); fsm.go('a'); console.log(fsm.state); EOF root@5b11a1de243f:/tmp/node-fsm# node test.js No transition exists from "c" to "a" c
Awesome!
Well, if you're still in the market for using it, I hope you like it.
I'll be here for any questions.
Cheers, Dave
I've been struggling with integrating this package into a Node app; I've encountered a couple of problems:
Possible solution: Change "main" value to "src/StateMachine.js"
Possible solution: Unsure
Please advise on how I should proceed.
Aside: It would be really helpful to have installation and configuration instructions on the GitHub page, and to ensure that the instructions function properly in vanilla environments. You may have lots of features and decent documentation, but unless one can integrate the package quickly into multiple popular environments (e.g., Node, Web ), I suspect that most people would look for another package.