Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(export): fix --bundle breaks games including audio #1506

Merged
merged 2 commits into from
Feb 17, 2025
Merged

Conversation

xnv
Copy link
Member

@xnv xnv commented Feb 14, 2025

掲題どおり。

--bundle 時、不要ファイルを削除する際に音声アセットが全て消される問題を解消します。

「不要ファイル」の判定は preservingFilePathSetasset.path で行われていますが、音声アセットの場合に限り asset.path が拡張子を含まないため、間違って全部不要と判定されていました。( #1486 の最後でつけたコメント #1486 (comment) が誤りでした。) 元々現状では音声アセットが減ることはない=全て残るだけなので、暫定的に type: "audio" のアセットは常に残すように変更します。

#1465 同様に、ミニマムコンテンツのほか、ニコニコスネークリリアと魔女 [LILIEA - Act1] で動作を確認しています。ユニットテストでは扱えていない範囲で、prerelease 後に reftest で動作確認を行います。

@@ -183,7 +183,7 @@ describe("exportHTML", function () {
expect(fsx.statSync(path.join(dest, "audio", "dummyse.ogg"))).toBeTruthy();
expect(fsx.statSync(path.join(dest, "audio", "dummyse.aac"))).toBeTruthy();
expect(fsx.statSync(path.join(dest, "audio", "dummyse.m4a"))).toBeTruthy();
expect(() => void fsx.statSync(path.join(dest, "audio", "dummyse.invalidext"))).toThrow();
expect(() => fsx.statSync(path.join(dest, "audio", "dummyse.invalidext"))).toThrow();
Copy link
Member Author

Choose a reason for hiding this comment

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

別件。こうなっている経緯がよくわかっていません (およそうっかり書くような演算子ではない) が、エディタ上で implicit any として怒られるので削っています。

@@ -12,8 +12,7 @@ import { rollup } from "rollup";
import type { MinifyOptions } from "terser";
import { minify_sync } from "terser";
import * as liceneUtil from "../licenseUtil.js";
import * as utils from "../utils.js";
import { validateGameJson } from "../utils.js";
import { validateGameJson, warnLackOfAudioFile } from "../utils.js";
Copy link
Member Author

Choose a reason for hiding this comment

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

別件2。import 方法を統一しておきます。

gcu.removeAssets(gamejson, (asset) => preservingFilePathSet.has(asset.path));
// preservingFilePathSet (維持するファイル一覧) にないものは game.json から削除する。
// 暫定措置: audio は常に残す。(path に拡張子がないので preservingFilePathSet と比較できない。今後 audio を bundle しない限り動作上の悪影響はない)
gcu.removeAssets(gamejson, (asset) => (asset.type === "audio") || preservingFilePathSet.has(asset.path));
Copy link
Member Author

Choose a reason for hiding this comment

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

本題ここだけです。

@xnv xnv merged commit 813dca6 into main Feb 17, 2025
8 checks passed
@xnv xnv deleted the fix-export-with-audio branch February 17, 2025 08:14
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