matthewp / robot

🤖 A functional, immutable Finite State Machine library

Home Page:https://thisrobot.life

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use the unpkg version of this?

pke opened this issue · comments

I can't seem to get the exports from the published module at
import { createMachine } from "https://unpkg.com/robot3@0.2.9/dist/machine.js"

It errors with:

Uncaught SyntaxError: The requested module 'https://unpkg.com/robot3@0.2.9/dist/machine.js?module' does not provide an export named 'createMachine'

Maybe the module should export using module.exports instead of just exports?

I got it working using:
import { createMachine, state, transition } from "https://unpkg.com/robot3@0.2.9/machine.js"

However preact-robot is not properly hosted on unpkg (it tries to import from preact-hooks). So is there a way to get robot running with webmodules instead of transpiling?

Are we missing the module field in package.json maybe?

No clue ;) Never published to unpkg. I don't even know how it works. Do they pull the packages from npm?

If you use https://unpkg.com/preact-robot?module and https://unpkg.com/robot3?module it looks like it should do the right thing.

Closing as I think this is correct.