playcanvas / playcanvas-spine

Plugin component for PlayCanvas which enables support for Spine animations.
MIT License
48 stars 18 forks source link

chore(build): replace Grunt with Rollup #77

Closed epreston closed 1 year ago

epreston commented 1 year ago

Replaces the build system with Rollup. This will allow the code to be transpiled with Babel for pure es5 or es6. Provides a base for the rewrite.

Fixes: https://github.com/playcanvas/engine/issues/5399 Unblocks: https://github.com/playcanvas/engine/issues/5521

Other Bits:

Notes:

Vendor runtime repo is located here: https://github.com/EsotericSoftware/spine-runtimes

From 4.0, the latest patch version is on NPM. for 3.6 and 3.8, its available as branches in the repo. To automate updates, npm versions are alaised to make multiple versions of the same package available to this project. See package.json (spine40, spine41).

They provide iife builds and instructions to modify them for use as ESM exports. Not ideal for an engine integration or plugin (its more targeted at inclusion in html headers). For the rewrite, its better to generate esm from the typescript source for each version with:

esbuild --bundle spine-ts/core/index.ts --target=es6 --sourcemap --outfile=spine.x.x.js --format=es

It is possible to add Babel now, but, the configuration will be replaced very shortly.

Next steps:

Reorganise the file structure of examples so we can swap to "serve" as dev server.

Make examples attractive like engine's examples using pcui (but keeping it simple). Might be worth making a tiny "examples" template that can be used across projects.

The next steps for the code are generating ESM bundles for 3.6 and 3.8 from the typescript source because vendor only publishes processed typescript to npm from 4.0. At that point, we need to remove the "context" (it needs to be top level undefined), introduce babbel to support language correct es5 and es6 targets (if translation is required), and flip the module setting accordingly.

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

mvaligursky commented 1 year ago

That sounds great! We'll check it out next week, as we have a long weekend already.

willeastcott commented 1 year ago

Yay. LGTM.