Needless to say, you can't use Phaser 4 in production yet, so please don't even try.
- Checkout the Phaser 4 repo.
npm i
.- The
packages
folder contains all of the Phaser 4 modules. - The
bundles
folder contains all of the Phaser 4 bundles.
- Go into the
scripts/
folder and copy the_template
folder. - Paste it into the
packages/
folder. - Rename the
_template
folder it to whatever the module is called, i.e.geom-line
. - Inside the new folder, edit the
package.json
file. - Replace the
"name"
property with the module name, i.e."@phaserjs/geom-line"
. - Change the
"description"
property to be the Phaser namespace for the module, i.e."Phaser.Geom.Line"
. - Save
package.json
.
Now, edit the TypeScript source in the src
folder, making sure to properly export the module.
Once you're ready to publish:
- First, commit your changes to git, as you can't publish with uncommited changes.
- Run
lerna-wizard
. - Pick
publish
from the menu and answerN
to custom publishing andinfo
for the log level. - It will detect your new package and ask for a version increment. Select
Patch
(0.0.1). - Confirm your choices and publish. It should then send it all off to npm and you're done.
- Edit the TypeScript code to make the changes required.
- First, commit your changes to git, as you can't publish with uncommited changes.
- Run
lerna-wizard
. - Pick
publish
from the menu and answerN
to custom publishing andinfo
for the log level. - It will detect your new package and ask for a version increment. Select
Patch
(0.0.1). - Confirm your choices and publish. It should then send it all off to npm and you're done.
- Change into the package directory, i.e.
cd packages/geom-line
. - Run
npm run build
. - TypeScript will do its thing. If there are errors in the source, fix them.
- If the build completes, the files will be in the
dist
folder. - Commit the build files and publish then to npm via the
lerna-wizard
->publish
option.
First, to aid in testing, link the packages together:
- In the package folder in the Phaser 4 repo, i.e.
packages/geom-line
and run the commandnpm link
. - In the Phaser 4 Dev repo, add the package you've just created, i.e.
npm i @phaserjs/geom-line
. - Now link them together:
npm link @phaserjs/geom-line
. - It should create a symlink between phaser4-dev and the roaming node_modules package.
- This means you can write a test in Phaser 4 Dev and edit the package source inside of Phaser 4 without needing to publish every time.
When you've finished an edit, just build the package as usual with npm run build
, and npm link will see the changes automatically.
Do the following in the Phaser 4 Dev Repo (not this repo)
- Run the command
npm run create
. This will create a brand new folder in which you can build a test. The folder name will automatically increment from the previous one, i.e.009
,010
, etc. If you want a specific folder name, use the commandnpm run create -- -f folderName
instead. - Edit the test file, i.e. if the folder it created was called
009
then edittest009.ts
:
import { Angle, Line } from '@phaserjs/geom-line';
const test: Line = new Line(0, 100, 400, 50);
console.log(Angle(test));
- Build the test with
npm run build
. It will create the build file in the test folder. - Open the test in a browser, i.e.
localhost/phaser4-dev/src/009/
and the test will load. - If you want to do lots of edits, use
npm run watch
and it'll rebuild the test on each save. - If you want to test for errors, use
npm run test
. - If you want to check to see which modules the test depends on, use
npm run trace
for a full trace resolution.
This repo uses https://www.npmjs.com/package/npm-check-updates - which you can run from the cli via ncu
.
Use this in the root folder to check for out dated packages for the core scripts.
Then, use the script npm run packagencu
to run ncu on all sub-packages and update each of them in turn.
Also, use lerna-wizard
to check for out-dated packages across sub-packages.