storm-lua-minify 0.2.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +157 -37
- package/dist/aggregateSpecialization.js +406 -0
- package/dist/ast2lua.js +223 -82
- package/dist/astWalk.js +162 -0
- package/dist/callGraph.js +372 -0
- package/dist/cli.js +53 -32
- package/dist/cliOptions.js +36 -0
- package/dist/cliProgress.js +87 -0
- package/dist/config.js +73 -0
- package/dist/constantFold.js +798 -0
- package/dist/controlFlow.js +266 -0
- package/dist/functionRewrites.js +580 -0
- package/dist/generatedAst.js +108 -0
- package/dist/generatedNode.js +23 -0
- package/dist/globalRename.js +35 -0
- package/dist/interproceduralAnalysis.js +842 -0
- package/dist/interproceduralConstants.js +120 -0
- package/dist/keywordLocator.js +68 -0
- package/dist/linker.js +13 -0
- package/dist/luaString.js +157 -0
- package/dist/minifier.js +1243 -35
- package/dist/optimizerAnalysis.js +43 -0
- package/dist/optimizerDiagnostics.js +65 -0
- package/dist/optimizerFacts.js +529 -0
- package/dist/optimizerPass.js +96 -0
- package/dist/optimizerTransaction.js +56 -0
- package/dist/optimizerValueDomain.js +180 -0
- package/dist/options.js +233 -0
- package/dist/progress.js +2 -0
- package/dist/removeUnused.js +145 -0
- package/dist/renamer.js +236 -53
- package/dist/resolver.js +37 -14
- package/dist/runtimeEnvironment.js +105 -0
- package/dist/sourceMetadata.js +314 -0
- package/dist/statementDataflow.js +259 -0
- package/dist/statementScheduler.js +595 -0
- package/dist/symbolLiveness.js +92 -0
- package/dist/tableEffects.js +356 -0
- package/dist/transform.js +40 -0
- package/dist/valueFlow.js +409 -0
- package/dist/wholeProgramExports.js +646 -0
- package/dist/wholeProgramFieldRenames.js +583 -0
- package/dist/wholeProgramFields.js +672 -0
- package/dist/wholeProgramObjects.js +783 -0
- package/package.json +50 -33
- package/.github/workflows/ci.yml +0 -39
- package/.github/workflows/publish.yml +0 -39
- package/.prettierignore +0 -3
- package/.prettierrc.json +0 -1
- package/dist/index.js +0 -27
- package/eslint.config.js +0 -29
- package/src/ast2lua.ts +0 -940
- package/src/cli.ts +0 -86
- package/src/linker.ts +0 -108
- package/src/minifier.ts +0 -284
- package/src/output.ts +0 -71
- package/src/renamer.ts +0 -134
- package/src/resolver.ts +0 -378
- package/test/circular-require.test.ts +0 -19
- package/test/fixtures/bare-require/main.lua +0 -2
- package/test/fixtures/bare-require/mod.lua +0 -1
- package/test/fixtures/bitwise-precedence/main.lua +0 -10
- package/test/fixtures/circular-require/a.lua +0 -2
- package/test/fixtures/circular-require/b.lua +0 -2
- package/test/fixtures/circular-require/main.lua +0 -2
- package/test/fixtures/dofile/greet.lua +0 -1
- package/test/fixtures/dofile/main.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_alpha.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_bravo.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_charlie.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_delta.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_echo.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_foxtrot.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_golf.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_hotel.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_india.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_juliet.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/dep_kilo.lua +0 -2
- package/test/fixtures/entry-scope-many-requires/main.lua +0 -25
- package/test/fixtures/multi-require/common.lua +0 -1
- package/test/fixtures/multi-require/main.lua +0 -3
- package/test/fixtures/nested-module/main.lua +0 -2
- package/test/fixtures/nested-module/sub/deep.lua +0 -1
- package/test/fixtures/require-call/main.lua +0 -2
- package/test/fixtures/require-call/mod.lua +0 -5
- package/test/fixtures/require-in-expression/main.lua +0 -1
- package/test/fixtures/require-in-expression/mod.lua +0 -1
- package/test/fixtures/require-string-call/main.lua +0 -2
- package/test/fixtures/require-string-call/mod.lua +0 -5
- package/test/fixtures/single-file/main.lua +0 -15
- package/test/identifier-collision.test.ts +0 -28
- package/test/lib/collision.ts +0 -131
- package/test/lib/helpers.ts +0 -124
- package/test/no-rename.test.ts +0 -19
- package/test/output.test.ts +0 -95
- package/test/precedence.test.ts +0 -28
- package/test/renamer.test.ts +0 -130
- package/test/resolver.test.ts +0 -206
- package/test/roundtrip.test.ts +0 -26
- package/test/snapshot.test.ts +0 -27
- package/test/snapshots/bare-require.sl.lua +0 -1
- package/test/snapshots/bitwise-precedence.sl.lua +0 -2
- package/test/snapshots/dofile.sl.lua +0 -1
- package/test/snapshots/entry-scope-many-requires.m.lua +0 -14
- package/test/snapshots/multi-require.m.lua +0 -4
- package/test/snapshots/multi-require.sl.lua +0 -1
- package/test/snapshots/nested-module.m.lua +0 -4
- package/test/snapshots/require-call.m.lua +0 -5
- package/test/snapshots/require-call.sl.lua +0 -1
- package/test/snapshots/require-in-expression.sl.lua +0 -1
- package/test/snapshots/require-string-call.m.lua +0 -5
- package/test/snapshots/single-file.sl.lua +0 -6
- package/test/sourcemap.test.ts +0 -105
- package/tsconfig.eslint.json +0 -8
- package/tsconfig.json +0 -111
package/package.json
CHANGED
|
@@ -1,33 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "storm-lua-minify",
|
|
3
|
-
"description": "A Lua minifier also outputs source map",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "storm-lua-minify",
|
|
3
|
+
"description": "A Lua minifier also outputs source map",
|
|
4
|
+
"version": "0.9.0",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=22"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"commander": "^12.1.0",
|
|
13
|
+
"luaparse": "^0.3.1",
|
|
14
|
+
"source-map": "^0.7.4"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@eslint/js": "^9.39.5",
|
|
18
|
+
"@types/luaparse": "^0.2.13",
|
|
19
|
+
"@types/node": "^22.20.1",
|
|
20
|
+
"eslint": "^9.39.5",
|
|
21
|
+
"eslint-config-prettier": "^10.1.8",
|
|
22
|
+
"globals": "^17.7.0",
|
|
23
|
+
"prettier": "^3.9.5",
|
|
24
|
+
"typescript": "^5.9.3",
|
|
25
|
+
"typescript-eslint": "^8.63.0",
|
|
26
|
+
"vitest": "^4.1.10"
|
|
27
|
+
},
|
|
28
|
+
"author": "Nona Takahara <nona_t_2612@yahoo.co.jp>",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"scripts": {
|
|
31
|
+
"start": "node ./dist/cli.js",
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"test": "tsc -p tsconfig.eslint.json && npx vitest run",
|
|
34
|
+
"test:smoke": "pnpm run build && vitest run --config vitest.smoke.config.ts",
|
|
35
|
+
"lint": "eslint .",
|
|
36
|
+
"format": "prettier --write .",
|
|
37
|
+
"format:check": "prettier --check .",
|
|
38
|
+
"verify:lua-budget": "node scripts/verify-lua-resource-budget.cjs",
|
|
39
|
+
"report:optimizer": "pnpm run build && node scripts/report-optimizer-diagnostics.cjs",
|
|
40
|
+
"report:whole-program-objects": "pnpm run build && node scripts/report-whole-program-objects.cjs",
|
|
41
|
+
"report:whole-program-fields": "pnpm run build && node scripts/report-whole-program-fields.cjs",
|
|
42
|
+
"report:aggregate-specialization": "pnpm run build && node scripts/report-aggregate-specialization.cjs",
|
|
43
|
+
"report:whole-program-exports": "pnpm run build && node scripts/report-whole-program-exports.cjs",
|
|
44
|
+
"report:whole-program-field-renames": "pnpm run build && node scripts/report-whole-program-field-renames.cjs",
|
|
45
|
+
"verify:effect-semantics": "pnpm run build && node scripts/verify-effect-semantics.cjs"
|
|
46
|
+
},
|
|
47
|
+
"bin": {
|
|
48
|
+
"storm-lua-minify": "dist/cli.js"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
- develop
|
|
8
|
-
pull_request:
|
|
9
|
-
branches:
|
|
10
|
-
- main
|
|
11
|
-
- develop
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
build-lint-test:
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
steps:
|
|
17
|
-
- name: Checkout
|
|
18
|
-
uses: actions/checkout@v4
|
|
19
|
-
|
|
20
|
-
- name: Setup Node.js
|
|
21
|
-
uses: actions/setup-node@v4
|
|
22
|
-
with:
|
|
23
|
-
node-version: "22.x"
|
|
24
|
-
cache: "npm"
|
|
25
|
-
|
|
26
|
-
- name: Install dependencies
|
|
27
|
-
run: npm ci
|
|
28
|
-
|
|
29
|
-
- name: Build
|
|
30
|
-
run: npm run build
|
|
31
|
-
|
|
32
|
-
- name: Lint
|
|
33
|
-
run: npm run lint
|
|
34
|
-
|
|
35
|
-
- name: Check formatting
|
|
36
|
-
run: npm run format:check
|
|
37
|
-
|
|
38
|
-
- name: Test
|
|
39
|
-
run: npm test
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
name: Publish to npm
|
|
2
|
-
|
|
3
|
-
# NOTE: npm publish is disabled for now (see issue #10).
|
|
4
|
-
# Once the repository is ready to publish (NPM_TOKEN secret configured,
|
|
5
|
-
# owner sign-off), uncomment the "Publish" step below.
|
|
6
|
-
on:
|
|
7
|
-
release:
|
|
8
|
-
types: [published]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
publish:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- name: Checkout
|
|
15
|
-
uses: actions/checkout@v4
|
|
16
|
-
|
|
17
|
-
- name: Setup Node.js
|
|
18
|
-
uses: actions/setup-node@v4
|
|
19
|
-
with:
|
|
20
|
-
node-version: "22.x"
|
|
21
|
-
cache: "npm"
|
|
22
|
-
registry-url: "https://registry.npmjs.org"
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: npm ci
|
|
26
|
-
|
|
27
|
-
- name: Build
|
|
28
|
-
run: npm run build
|
|
29
|
-
|
|
30
|
-
- name: Lint
|
|
31
|
-
run: npm run lint
|
|
32
|
-
|
|
33
|
-
- name: Test
|
|
34
|
-
run: npm test
|
|
35
|
-
|
|
36
|
-
# - name: Publish
|
|
37
|
-
# run: npm publish
|
|
38
|
-
# env:
|
|
39
|
-
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.prettierignore
DELETED
package/.prettierrc.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
package/dist/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const luaparse_1 = __importDefault(require("luaparse"));
|
|
8
|
-
const node_process_1 = require("node:process");
|
|
9
|
-
const ast2lua_1 = require("./ast2lua");
|
|
10
|
-
const luaparseSetting = {
|
|
11
|
-
locations: true,
|
|
12
|
-
luaVersion: '5.3',
|
|
13
|
-
ranges: true,
|
|
14
|
-
scope: true,
|
|
15
|
-
};
|
|
16
|
-
const argPath = node_process_1.argv[2];
|
|
17
|
-
if (fs_1.default.existsSync(argPath)) {
|
|
18
|
-
const code = fs_1.default.readFileSync(argPath).toString();
|
|
19
|
-
const ast = luaparse_1.default.parse(code, luaparseSetting);
|
|
20
|
-
if ("globals" in ast) {
|
|
21
|
-
const map = (0, ast2lua_1.minify)(ast);
|
|
22
|
-
map.add("\n--[[\n//# sourceMappingURL=test.lua.map\n]]");
|
|
23
|
-
console.log(map.toStringWithSourceMap().code);
|
|
24
|
-
// toStringWithSourceMap().map の file に書き出したのちのファイル名を入れないとVSCode Extでは検索失敗する
|
|
25
|
-
//console.log(JSON.stringify(map.toStringWithSourceMap().map));
|
|
26
|
-
}
|
|
27
|
-
}
|
package/eslint.config.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
const eslint = require("@eslint/js");
|
|
3
|
-
const tseslint = require("typescript-eslint");
|
|
4
|
-
const globals = require("globals");
|
|
5
|
-
const eslintConfigPrettier = require("eslint-config-prettier");
|
|
6
|
-
|
|
7
|
-
module.exports = tseslint.config(
|
|
8
|
-
{
|
|
9
|
-
ignores: ["dist/**"],
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
files: ["src/**/*.ts", "test/**/*.ts"],
|
|
13
|
-
extends: [
|
|
14
|
-
eslint.configs.recommended,
|
|
15
|
-
...tseslint.configs.strictTypeChecked,
|
|
16
|
-
...tseslint.configs.stylistic,
|
|
17
|
-
],
|
|
18
|
-
languageOptions: {
|
|
19
|
-
globals: {
|
|
20
|
-
...globals.node,
|
|
21
|
-
},
|
|
22
|
-
parserOptions: {
|
|
23
|
-
project: "./tsconfig.eslint.json",
|
|
24
|
-
tsconfigRootDir: __dirname,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
eslintConfigPrettier,
|
|
29
|
-
);
|