Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bab31dc
Remove browserify, Use rollup
ShinobuTakahashi Jun 18, 2025
9ec0aea
Remove comment
ShinobuTakahashi Jun 18, 2025
c1d6ab5
Fix NodeModules.ts
ShinobuTakahashi Jul 24, 2025
bb82fe8
Use memfs, remove mock-fs
ShinobuTakahashi Jul 29, 2025
7386235
Fix spec
ShinobuTakahashi Jul 30, 2025
afe3253
Fix TestUtil.ts,
ShinobuTakahashi Jul 30, 2025
bf78a05
Fix NodeModulesSpec, TestUtil
ShinobuTakahashi Aug 1, 2025
0597faf
Fix spec
ShinobuTakahashi Aug 5, 2025
58e42ad
Fix export
ShinobuTakahashi Aug 6, 2025
c1f0ef9
fix extra
ShinobuTakahashi Aug 6, 2025
7be56f1
Fix init
ShinobuTakahashi Aug 7, 2025
d671ac5
Fix scan
ShinobuTakahashi Aug 20, 2025
93c7eb4
Fix lib-manage
ShinobuTakahashi Aug 20, 2025
b975719
Fix BasicParametersSpec
ShinobuTakahashi Aug 21, 2025
8f0275f
Remove unnecessary fixes
ShinobuTakahashi Aug 21, 2025
af1a076
Fix NodeModulesSpec
ShinobuTakahashi Aug 26, 2025
c0a8a47
Merge branch 'main' into remove-browserify-use-rollup
ShinobuTakahashi Aug 27, 2025
11451dd
Merge branch 'remove-browserify-use-rollup' into use-memfs-for-commons
ShinobuTakahashi Aug 27, 2025
852f952
Merge branch 'use-memfs-for-commons' into use-memfs-other
ShinobuTakahashi Aug 27, 2025
0eeb5dc
Remove mock-fs
ShinobuTakahashi Aug 27, 2025
b68692a
Fix Testutil
ShinobuTakahashi Sep 9, 2025
c4e3da8
Fix NodeModulesSpec
ShinobuTakahashi Sep 9, 2025
5ad18d6
Fix NodeModuleSpec
ShinobuTakahashi Sep 9, 2025
2c0ced3
Fix BasicParameterSpec
ShinobuTakahashi Sep 19, 2025
d20fc16
Fix installSpec
ShinobuTakahashi Feb 3, 2026
482045b
remove unnecessary fixes
ShinobuTakahashi Feb 3, 2026
59d09d2
Fix comment
ShinobuTakahashi Feb 4, 2026
0b0002c
Merge pull request #1586 from akashic-games/use-memfs-other
ShinobuTakahashi Feb 4, 2026
d795562
Merge pull request #1576 from akashic-games/use-memfs-for-commons
ShinobuTakahashi Feb 26, 2026
773ec2b
Merge branch 'main' into remove-browserify-use-rollup
ShinobuTakahashi Mar 3, 2026
bbe108c
Merge branch 'main' into remove-browserify-use-rollup
ShinobuTakahashi Mar 3, 2026
fbd2f96
Update sandbox package.json
ShinobuTakahashi Mar 3, 2026
9e4223e
Update package-lock.json
ShinobuTakahashi Mar 3, 2026
85def37
Fix scan spec
ShinobuTakahashi Mar 3, 2026
204c5ae
Update package.json
ShinobuTakahashi Mar 3, 2026
0bef5c0
Update package-lock.json
ShinobuTakahashi Mar 3, 2026
5b21096
Add changeset
ShinobuTakahashi Mar 3, 2026
77fae96
Fix changeset comment
ShinobuTakahashi Mar 3, 2026
2e14a1e
Update moudles
ShinobuTakahashi Mar 4, 2026
4116411
Add changeset dir to remarkignore
ShinobuTakahashi Mar 4, 2026
97b9b55
Merge pull request #1703 from akashic-games/fix-after-merge-in-latest
ShinobuTakahashi Mar 9, 2026
1390e50
Fix NodeModules.ts
ShinobuTakahashi Mar 9, 2026
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
7 changes: 7 additions & 0 deletions .changeset/four-turkeys-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@akashic/akashic-cli-lib-manage": patch
"@akashic/akashic-cli-commons": patch
"@akashic/akashic-cli-export": patch
---

Remove browserify & mock-fs, Use rollup & memfs
1 change: 1 addition & 0 deletions .remarkignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
packages/akashic-cli-serve/www/public/thirdparty/
CHANGELOG.md
.changeset/
7,561 changes: 4,791 additions & 2,770 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
"@akashic/remark-preset-lint": "^0.1.2",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.5",
"@types/node": "^22.19.13",
"get-port": "^7.1.0",
"nx": "^20.3.1",
"ps-tree": "^1.2.0",
"remark-cli": "^10.0.1",
"shelljs": "^0.8.5"
"remark-cli": "^12.0.0",
"shelljs": "^0.10.0"
}
}
2 changes: 1 addition & 1 deletion packages/akashic-cli-commons/eslint.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module.exports = [
languageOptions: {
sourceType: "module",
parserOptions: {
project: "tsconfig.json",
project: "tsconfig.test.json",
},
},
ignores: [
Expand Down
12 changes: 6 additions & 6 deletions packages/akashic-cli-commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@
],
"devDependencies": {
"@akashic/eslint-config": "^3.0.2",
"@types/browserify": "12.0.40",
"@types/mock-fs": "4.13.4",
"@types/node": "20.14.15",
"@types/resolve": "^1.20.6",
"mock-fs": "5.2.0",
"memfs": "4.23.0",
"mock-require": "^3.0.3",
"shx": "0.3.4",
"shx": "0.4.0",
"typescript": "5.5.4"
},
"dependencies": {
"@akashic/game-configuration": "2.5.0",
"browserify": "17.0.1",
"@rollup/plugin-node-resolve": "^16.0.1",
"@rollup/plugin-commonjs": "^28.0.3",
"editorconfig": "^2.0.0",
"fs-readdir-recursive": "1.1.0",
"js-sha256": "^0.11.0",
"resolve": "^1.22.8"
"resolve": "^1.22.8",
"rollup": "4.41.1"
},
"publishConfig": {
"access": "public",
Expand Down
65 changes: 30 additions & 35 deletions packages/akashic-cli-commons/src/NodeModules.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import * as fs from "fs";
Copy link
Copy Markdown
Contributor Author

@ShinobuTakahashi ShinobuTakahashi Mar 3, 2026

Choose a reason for hiding this comment

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

browserify -> rollup 変更のファイルで、この PR でレビューしていただきたいファイルです。
CI で落ちていますが、#1703 で対応しています。

import { createRequire } from "module";
import * as path from "path";
import type { ModuleMainPathsMap, ModuleMainScriptsMap } from "@akashic/game-configuration";
import browserify from "browserify";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import type { RollupOptions } from "rollup";
import { rollup } from "rollup";
import { ConsoleLogger } from "./ConsoleLogger.js";
import type { Logger } from "./Logger.js";
import { StringStream } from "./StringStream.js";
import * as Util from "./Util.js";

const require = createRequire(import.meta.url);
const commonjs = require("@rollup/plugin-commonjs");

interface ModuleMainInfo {
moduleName: string;
mainScriptPath: string;
Expand Down Expand Up @@ -88,7 +93,7 @@ export module NodeModules {

// TODO: node_modules/ 以下以外でも利用するメソッドのため、NodeModules ではなく別の適切な場所に移動する
// checkAllModules は実験的なものです。 akashic-cli の外部から利用しないでください
export function listScriptFiles(
export async function listScriptFiles(
basepath: string,
modules: string|string[],
logger: Logger,
Expand All @@ -97,41 +102,32 @@ export module NodeModules {
if (modules.length === 0) return Promise.resolve([]);
const moduleNames = (typeof modules === "string") ? [modules] : modules;

// moduleNamesをrequireするだけのソースコード文字列を作って依存性解析の基点にする
// (moduleNamesを直接b.require()してもよいはずだが、そうするとモジュールのエントリポイントの代わりに
// モジュールの名前(ディレクトリ名であることが多い)が出力されてしまうので避ける)
const dummyRootName = "__akashic-cli_dummy_require_root.js";
const dummyRootPath = path.join(basepath, dummyRootName);
const rootRequirer = moduleNames.map((name: string) => {
return "require(\"" + Util.makeModuleNameNoVer(name) + "\");";
}).join("\n");

// akashicコンテンツが Node.js のコアモジュールを参照するモジュールに依存している場合、
// akashic-cli-commons/node_modules 以下への依存として表現される。
// これを検知した場合、そのモジュールへの依存はgame.jsonに追記せず、akashicコマンドユーザには警告を表示する。
const ignoreModulePaths = ["/akashic-cli-commons/node_modules/"];

// builtins (コアモジュール) を有効にすると browserify が polyfill したモジュールが b.on("dep", ...) で検出される。
// したがってここでは false を指定してコアモジュールの読み込みを禁止する。
const builtins = false;

const b = browserify({
entries: new StringStream(rootRequirer, dummyRootPath),
basedir: basepath,
preserveSymlinks: true, // npm link で node_modules 以下に置かれたモジュールを symlink パスのまま扱う
builtins,
});
b.external("g");
const restoreDirectory = Util.chdir(basepath);
const inputOptions: RollupOptions = {
input: moduleNames,
external: ["g"],
preserveSymlinks: true,
plugins: [
commonjs(),
nodeResolve()
]
};
const filePaths: string[] = [];
try {
const bundle = await rollup(inputOptions);

return new Promise<string[]>((resolve, reject) => {
const filePaths: string[] = [];
b.on("dep", (row: any) => {
const filePath = Util.makeUnixPath(path.relative(basepath, row.file));
if (filePath === dummyRootName || (!checkAllModules && !(/^(?:\.\/)?node_modules/.test(filePath)))) {
bundle.watchFiles.forEach(file => {
const filePath = Util.makeUnixPath(path.relative(basepath, file));
if (!checkAllModules && !(/^(?:\.\/)?node_modules/.test(filePath))) {
return;
}
if (/^\.\.\//.test(filePath)) {
const rawFilePath = Util.makeUnixPath(row.file);
const rawFilePath = Util.makeUnixPath(file);
if (ignoreModulePaths.find((modulePath) => rawFilePath.includes(modulePath))) {
const detectedModuleName = path.basename(path.dirname(filePath));
const msg = "Reference to '" + detectedModuleName
Expand All @@ -144,14 +140,13 @@ export module NodeModules {
const msg = "Unsupported module found in " + JSON.stringify(modules)
+ ". Skipped listing '" + filePath
+ "' that cannot be dealt with. (This may be a core module of Node.js)";
reject(new Error(msg));
return;
throw new Error(msg);
}
filePaths.push(filePath);
});
b.bundle((err: any) => {
void (err ? reject(err) : resolve(filePaths));
});
});
} finally {
await restoreDirectory();
}
return filePaths;
}
}
11 changes: 8 additions & 3 deletions packages/akashic-cli-commons/src/__tests__/ConfigurationSpec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import mockfs from "mock-fs";
import { Configuration } from "../Configuration.js";
import { ConsoleLogger } from "../ConsoleLogger.js";
import { fs, vol } from "memfs";

vi.mock("node:fs", async () => {
const memfs: { fs: typeof fs } = await vi.importActual("memfs")
return memfs.fs;
});

describe("Configuration", () => {
afterEach(() => {
mockfs.restore();
vol.reset();
});
it("can be instantiated", () => {
const loggedResult: string[] = [];
Expand Down Expand Up @@ -58,7 +63,7 @@ describe("Configuration", () => {
"zoo": {}
}
};
mockfs(mockFsContent);
vol.fromNestedJSON(mockFsContent);

const self = new Configuration({ content: content, logger: logger });
self.vacuumGlobalScripts();
Expand Down
53 changes: 40 additions & 13 deletions packages/akashic-cli-commons/src/__tests__/FileSystemSpec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
import mockfs from "mock-fs";
import { readFile, writeFile, readJSON, writeJSON, readdir, unlink } from "../FileSystem.js";
import { buildEditorconfig } from "./helpers/buildEditorconfig.js";
import { fs, vol } from "memfs";
import * as editorconfig from "editorconfig";
import path from "path";

vi.mock("node:fs", async () => {
const memfs: { fs: typeof fs } = await vi.importActual("memfs");
return memfs.fs;
});

// editorconfig の parse() で memfs でモックした .editorconfig が読み込めないため parse() をモックしている。
vi.mock("editorconfig", async (importOriginal) => {
return {
...await importOriginal<typeof editorconfig>(),
parse: vi.fn((filepath: string, options?: editorconfig.ParseOptions): Promise<editorconfig.Props> => {
const targetPath = path.join(path.dirname(filepath), ".editorconfig");
if (!fs.existsSync(targetPath)) return Promise.resolve({});
const ret = fs.readFileSync(targetPath);
const parsed = editorconfig.parseBuffer(ret as Buffer);
const parsedObj = parsed[1][1];
const obj: editorconfig.Props = {
indent_size: parseInt(parsedObj.indent_size, 10),
indent_style: parsedObj.indent_style === "tab" ? "tab" : "space",
insert_final_newline: parsedObj.insert_final_newline === "true"
}
return Promise.resolve(obj);
})
}
});

describe("FileSystemSpec", () => {
afterEach(() => {
mockfs.restore();
vol.reset();
});

it("read text", async () => {
mockfs({
vol.fromJSON({
"someText.txt": "text content!"
});
expect(
Expand All @@ -17,7 +44,7 @@ describe("FileSystemSpec", () => {
});

it("read binary", async () => {
mockfs({
vol.fromJSON({
"someBinary": Buffer.from([12, 34, 56])
});
expect(
Expand All @@ -26,7 +53,7 @@ describe("FileSystemSpec", () => {
});

it("read json", async () => {
mockfs({
vol.fromNestedJSON({
"game": {
"game.json": JSON.stringify({
width: 120,
Expand All @@ -43,7 +70,7 @@ describe("FileSystemSpec", () => {
});

it("write text", async () => {
mockfs({
vol.fromNestedJSON({
"some": {}
});
await writeFile("./some/foo.txt", "string content!!");
Expand All @@ -53,7 +80,7 @@ describe("FileSystemSpec", () => {
});

it("write binary", async () => {
mockfs({});
vol.fromNestedJSON({ "": {} });
await writeFile("./someBinary", Buffer.from([12, 34]));
expect(
await readFile("./someBinary")
Expand All @@ -62,7 +89,7 @@ describe("FileSystemSpec", () => {

describe("#writeJson", () => {
it("write game.json", async () => {
mockfs({
vol.fromNestedJSON({
"game": {
"game.json": JSON.stringify({})
}
Expand All @@ -77,7 +104,7 @@ describe("FileSystemSpec", () => {
});

it("write json without .editorconfig", async () => {
mockfs({
vol.fromNestedJSON({
"test.json": JSON.stringify({})
});
await writeJSON("test.json", { width: 120, height: 240 });
Expand All @@ -92,7 +119,7 @@ describe("FileSystemSpec", () => {
});

it("write json with .editorconfig", async () => {
mockfs({
vol.fromNestedJSON({
"test1/.editorconfig": buildEditorconfig({ indentSize: 4, indentStyle: "tab", insertFinalNewline: true }),
"test1/test.json": JSON.stringify({}),
"test2/.editorconfig": buildEditorconfig({ indentSize: 2, indentStyle: "space", insertFinalNewline: true }),
Expand Down Expand Up @@ -132,7 +159,7 @@ describe("FileSystemSpec", () => {
});

it("write json with formatter", async () => {
mockfs({
vol.fromNestedJSON({
"test.json": JSON.stringify({})
});
await writeJSON("test.json", { width: 120, height: 240 }, (content) => JSON.stringify(content, undefined, " "));
Expand All @@ -148,7 +175,7 @@ describe("FileSystemSpec", () => {
});

it("read directories", async () => {
mockfs({
vol.fromNestedJSON({
"foo": {
"test.json": ""
},
Expand All @@ -167,7 +194,7 @@ describe("FileSystemSpec", () => {
});

it("unlink file", async () => {
mockfs({
vol.fromNestedJSON({
"foo": {
"test.json": JSON.stringify({ val: 42 })
},
Expand Down
Loading