Calamari / BehaviorTree.js

An JavaScript implementation of Behavior Trees.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

it doesn't work in browser

sunq0001 opened this issue · comments

i tried import the module into browser by webpack4 as below
import { BehaviorTree, Sequence, Task, SUCCESS, FAILURE } from 'behaviortree'

once i want to check by console.log(BehaviorTree), console shows undefined.

when i tried this way
import { BehaviorTree, Sequence, Task, SUCCESS, FAILURE } from '../node_modules/behaviortree/dist/index.node'
it can work.

but when i tried
import { BehaviorTree, Sequence, Task, SUCCESS, FAILURE } from '../node_modules/behaviortree/dist/index'
it doesn't work.

it seems that this package can only be used in Node, but not applied for web.

I am not quite sure how your setup looks like, but you most likely would need a precompilation step, like using Webpack. If that is the case I don't see a reason why it shouldn't work.

I can't get this imported into a TypeScript+Webpack project... We need a .d.ts file.

Hey @alekop . Please try the typescript branch, which will be the base for the next release. That should work, and if it does not, please tell me, what error you get, so we can resolve that together.