Skip to content

Typescript them all#57

Open
Calamari wants to merge 33 commits intomasterfrom
typescript
Open

Typescript them all#57
Calamari wants to merge 33 commits intomasterfrom
typescript

Conversation

@Calamari
Copy link
Owner

@Calamari Calamari commented Nov 7, 2021

  • Add Types to everything
  • Experiment sufficiently
  • Rewrite README to mention Typescript properly

Note

Medium Risk
Moderate risk because it changes the build/test toolchain (esbuild bundling outputs and jest transform), which can affect published artifacts and CI behavior despite minimal runtime code changes.

Overview
Migrates project tooling away from the previous Babel + Standard/Prettier ESLint setup to a TypeScript-first workflow, adding a new .eslintrc.js (with @typescript-eslint) and ignoring bin/ in linting.

Introduces an esbuild-based build script (bin/build.js) that bundles src/index.ts into lib/ outputs (with sourcemaps/minification and node externals) and configures Jest to compile .ts/.tsx via esbuild-jest.

Updates formatting/config hygiene (.prettierrc semicolons + wider lines, .gitignore now includes lib/, adds VSCode spellings) and refreshes README.md examples/sections (semicolonized snippets, expanded introspection wording, and a brief built-in node types list + 3.0.0 notes/TODOs).

Written by Cursor Bugbot for commit 0f97102. This will update automatically on new commits. Configure here.

@Calamari Calamari mentioned this pull request Nov 7, 2021
@Telokis
Copy link

Telokis commented Dec 3, 2022

Hello!
I'm very interested in using this library but I'm unsure whether it's still maintained.

How is the TypeScript version going? What are you missing before you can release it?

I can use it to maybe give you some feedback if you publish it to npm with any kind of name. (Same for the parallel branch)

@Calamari
Copy link
Owner Author

Calamari commented Dec 5, 2022

Hello @Telokis.
It is still maintained. I just didn't came around to fully test the TypeScript version to my hearts content. And I don't want to release a version that is broken for some people. But I probably can but it out later as a release candidate. 👍
If you like to play with it, I am happy to do that. You are the first one to ask for a TypeScript version :)

@Telokis
Copy link

Telokis commented Dec 5, 2022

Hello and thank you for the answer!

If you can, I'll be happy to test the TypeScript version! It's difficult to find a proper behavior tree library in JS and even more so in TypeScript!
Just let me know the tag once you've published it to npm and I'll start using the thing to design my AI. It's the first time I use a BT so it probably won't be insane but it's still something!

(I was asking for parallel/async as well because my real AI will use websockets to perform actions but that can come later, I'll do a synchronous prototype in the first time.)

@Calamari
Copy link
Owner Author

Calamari commented Dec 5, 2022

So I added the parallel branch stuff and this into one release: behaviortree@3.0.0-beta.0

It should be published by now.

@Tresky
Copy link

Tresky commented Jan 20, 2023

I will also test this new support and let you know what I find. :)

@Tresky
Copy link

Tresky commented Jan 20, 2023

Just installed the beta version you released. It seems the index.d.ts file did not make it into the build.
Screen Shot 2023-01-20 at 2 29 03 PM

@Calamari
Copy link
Owner Author

@Tresky Thanks, very much for trying it out. You are right, during the publishing step, all files except those mentioned have been omitted. 🤦

But it should work now with the next beta release: behaviortree@3.0.0-beta.1
Sorry, for that.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Free Tier Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

outfile: 'lib/index.umd.js',
bundle: true,
minify: true,
format: 'esm',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UMD build file uses ESM format instead

High Severity

The first esbuild configuration outputs to lib/index.umd.js but specifies format: 'esm'. The filename implies a UMD (Universal Module Definition) bundle, but the actual output is ESM. Consumers expecting a UMD bundle (e.g., for use via a <script> tag in browsers) will get incompatible ESM code. The format option needs to be 'iife' (esbuild doesn't support UMD directly) or the filename corrected to reflect it's ESM.

Fix in Cursor Fix in Web

.catch((err) => {
console.error(err);
process.exit(1);
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esbuild node build output overwritten by tsc

High Severity

The second esbuild config produces lib/index.js (a bundled, minified CJS build targeting node14), but the build pipeline runs tsc immediately after node bin/build.js. Since tsconfig.json has outDir: "lib" without emitDeclarationOnly or noEmit, tsc emits its own unbundled lib/index.js, overwriting esbuild's output. The published lib/index.js (referenced by both main and module in package.json) ends up being raw tsc output rather than the intended bundled build, making this entire esbuild config dead code.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants