Skip to content

Commit

Permalink
updated build script for vanilla js projects
Browse files Browse the repository at this point in the history
Updated the build script to check if the `import` line for a file is
referencing the editor scripts base package, and when there is a match
the `import` statement will be changed from:

```js
from "@phaserjs/editor-scripts-base.js";
```

to

```js
from "../../phaserjs_editor_scripts_base/index.js";
```

This fix has a few limitations:

* if any other npm packages are added to this library, this change will
not fix those
* the generated `phaserjs_editor_scripts_quick` needs to be placed
at the root of the phaser editor project, next to the original location
of the `phaserjs_editor_scripts_base` folder.

Signed-off-by: Scott Westover <[email protected]>
  • Loading branch information
scottwestover committed Dec 6, 2024
1 parent f6ff66c commit f5b20b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion build-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ function processJSFiles(fromFolder, toFolder) {
const importRegex = /from "([^"]+)"/g;

content = content.replace(importRegex, (match, p1) => {
if (p1 === '@phaserjs/editor-scripts-base') {
return `from "../../phaserjs_editor_scripts_base/index.js"`;
}
return `from "${p1}.js"`;
});

Expand All @@ -78,4 +81,4 @@ fs.mkdirSync(`browser/${name}`, { recursive: true });

fs.writeFileSync(`browser/${name}/library.txt`, version);
copyFiles("src", `browser/${name}/`, ".scene", ".components");
processJSFiles("out", `browser/${name}/`);
processJSFiles("out", `browser/${name}/`);

0 comments on commit f5b20b3

Please sign in to comment.