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 mmp behavior #501

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ChangeLog

## 3.18.1
* `moduleMainPaths` の挙動を `moduleMainScripts` が存在しない場合に利用するように修正

## 3.18.0
* @akashic/[email protected] に追従
* `moduleMainPaths` をサポート
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@akashic/akashic-engine",
"version": "3.18.0",
"version": "3.18.1",
"description": "The core library of Akashic Engine",
"main": "index.js",
"dependencies": {
Expand Down
10 changes: 4 additions & 6 deletions src/ModuleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export class ModuleManager {
let resolvedPath: string | undefined;
const liveAssetVirtualPathTable = this._assetManager._liveAssetVirtualPathTable;
const moduleMainScripts = this._assetManager._moduleMainScripts;
const moduleMainPaths = this._assetManager._moduleMainPaths;

// 0. アセットIDらしい場合はまず当該アセットを探す
if (path.indexOf("/") === -1) {
Expand All @@ -96,8 +95,8 @@ export class ModuleManager {
}

// akashic-engine独自仕様: 対象の `path` が `moduleMainScripts` に指定されていたらそちらを参照する
// moduleMainScripts は将来的に非推奨となるため、moduleMainPaths が存在しない場合だけ参照する
if (!moduleMainPaths && moduleMainScripts[path]) {
// moduleMainScripts は将来的に非推奨となるが、後方互換性のため moduleMainScripts が存在すれば moduleMainScripts を優先する
if (moduleMainScripts[path]) {
targetScriptAsset = liveAssetVirtualPathTable[resolvedPath];
} else {
targetScriptAsset = this._findAssetByPathAsFile(resolvedPath, liveAssetVirtualPathTable);
Expand Down Expand Up @@ -147,7 +146,6 @@ export class ModuleManager {
let resolvedPath: string | null = null;
const liveAssetVirtualPathTable = this._assetManager._liveAssetVirtualPathTable;
const moduleMainScripts = this._assetManager._moduleMainScripts;
const moduleMainPaths = this._assetManager._moduleMainPaths;

// require(X) from module at path Y
// 1. If X is a core module,
Expand Down Expand Up @@ -183,8 +181,8 @@ export class ModuleManager {
// 3. LOAD_NODE_MODULES(X, dirname(Y))

// akashic-engine独自仕様: 対象の `path` が `moduleMainScripts` に指定されていたらそちらを返す
// moduleMainScripts は将来的に非推奨となるため、moduleMainPaths が存在しない場合だけ参照する
if (!moduleMainPaths && moduleMainScripts[path]) {
// moduleMainScripts は将来的に非推奨となるが、後方互換性のため moduleMainScripts が存在すれば moduleMainScripts を優先する
if (moduleMainScripts[path]) {
return moduleMainScripts[path];
}

Expand Down