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.
Files changed (116) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +157 -37
  3. package/dist/aggregateSpecialization.js +406 -0
  4. package/dist/ast2lua.js +223 -82
  5. package/dist/astWalk.js +162 -0
  6. package/dist/callGraph.js +372 -0
  7. package/dist/cli.js +53 -32
  8. package/dist/cliOptions.js +36 -0
  9. package/dist/cliProgress.js +87 -0
  10. package/dist/config.js +73 -0
  11. package/dist/constantFold.js +798 -0
  12. package/dist/controlFlow.js +266 -0
  13. package/dist/functionRewrites.js +580 -0
  14. package/dist/generatedAst.js +108 -0
  15. package/dist/generatedNode.js +23 -0
  16. package/dist/globalRename.js +35 -0
  17. package/dist/interproceduralAnalysis.js +842 -0
  18. package/dist/interproceduralConstants.js +120 -0
  19. package/dist/keywordLocator.js +68 -0
  20. package/dist/linker.js +13 -0
  21. package/dist/luaString.js +157 -0
  22. package/dist/minifier.js +1243 -35
  23. package/dist/optimizerAnalysis.js +43 -0
  24. package/dist/optimizerDiagnostics.js +65 -0
  25. package/dist/optimizerFacts.js +529 -0
  26. package/dist/optimizerPass.js +96 -0
  27. package/dist/optimizerTransaction.js +56 -0
  28. package/dist/optimizerValueDomain.js +180 -0
  29. package/dist/options.js +233 -0
  30. package/dist/progress.js +2 -0
  31. package/dist/removeUnused.js +145 -0
  32. package/dist/renamer.js +236 -53
  33. package/dist/resolver.js +37 -14
  34. package/dist/runtimeEnvironment.js +105 -0
  35. package/dist/sourceMetadata.js +314 -0
  36. package/dist/statementDataflow.js +259 -0
  37. package/dist/statementScheduler.js +595 -0
  38. package/dist/symbolLiveness.js +92 -0
  39. package/dist/tableEffects.js +356 -0
  40. package/dist/transform.js +40 -0
  41. package/dist/valueFlow.js +409 -0
  42. package/dist/wholeProgramExports.js +646 -0
  43. package/dist/wholeProgramFieldRenames.js +583 -0
  44. package/dist/wholeProgramFields.js +672 -0
  45. package/dist/wholeProgramObjects.js +783 -0
  46. package/package.json +50 -33
  47. package/.github/workflows/ci.yml +0 -39
  48. package/.github/workflows/publish.yml +0 -39
  49. package/.prettierignore +0 -3
  50. package/.prettierrc.json +0 -1
  51. package/dist/index.js +0 -27
  52. package/eslint.config.js +0 -29
  53. package/src/ast2lua.ts +0 -940
  54. package/src/cli.ts +0 -86
  55. package/src/linker.ts +0 -108
  56. package/src/minifier.ts +0 -284
  57. package/src/output.ts +0 -71
  58. package/src/renamer.ts +0 -134
  59. package/src/resolver.ts +0 -378
  60. package/test/circular-require.test.ts +0 -19
  61. package/test/fixtures/bare-require/main.lua +0 -2
  62. package/test/fixtures/bare-require/mod.lua +0 -1
  63. package/test/fixtures/bitwise-precedence/main.lua +0 -10
  64. package/test/fixtures/circular-require/a.lua +0 -2
  65. package/test/fixtures/circular-require/b.lua +0 -2
  66. package/test/fixtures/circular-require/main.lua +0 -2
  67. package/test/fixtures/dofile/greet.lua +0 -1
  68. package/test/fixtures/dofile/main.lua +0 -2
  69. package/test/fixtures/entry-scope-many-requires/dep_alpha.lua +0 -2
  70. package/test/fixtures/entry-scope-many-requires/dep_bravo.lua +0 -2
  71. package/test/fixtures/entry-scope-many-requires/dep_charlie.lua +0 -2
  72. package/test/fixtures/entry-scope-many-requires/dep_delta.lua +0 -2
  73. package/test/fixtures/entry-scope-many-requires/dep_echo.lua +0 -2
  74. package/test/fixtures/entry-scope-many-requires/dep_foxtrot.lua +0 -2
  75. package/test/fixtures/entry-scope-many-requires/dep_golf.lua +0 -2
  76. package/test/fixtures/entry-scope-many-requires/dep_hotel.lua +0 -2
  77. package/test/fixtures/entry-scope-many-requires/dep_india.lua +0 -2
  78. package/test/fixtures/entry-scope-many-requires/dep_juliet.lua +0 -2
  79. package/test/fixtures/entry-scope-many-requires/dep_kilo.lua +0 -2
  80. package/test/fixtures/entry-scope-many-requires/main.lua +0 -25
  81. package/test/fixtures/multi-require/common.lua +0 -1
  82. package/test/fixtures/multi-require/main.lua +0 -3
  83. package/test/fixtures/nested-module/main.lua +0 -2
  84. package/test/fixtures/nested-module/sub/deep.lua +0 -1
  85. package/test/fixtures/require-call/main.lua +0 -2
  86. package/test/fixtures/require-call/mod.lua +0 -5
  87. package/test/fixtures/require-in-expression/main.lua +0 -1
  88. package/test/fixtures/require-in-expression/mod.lua +0 -1
  89. package/test/fixtures/require-string-call/main.lua +0 -2
  90. package/test/fixtures/require-string-call/mod.lua +0 -5
  91. package/test/fixtures/single-file/main.lua +0 -15
  92. package/test/identifier-collision.test.ts +0 -28
  93. package/test/lib/collision.ts +0 -131
  94. package/test/lib/helpers.ts +0 -124
  95. package/test/no-rename.test.ts +0 -19
  96. package/test/output.test.ts +0 -95
  97. package/test/precedence.test.ts +0 -28
  98. package/test/renamer.test.ts +0 -130
  99. package/test/resolver.test.ts +0 -206
  100. package/test/roundtrip.test.ts +0 -26
  101. package/test/snapshot.test.ts +0 -27
  102. package/test/snapshots/bare-require.sl.lua +0 -1
  103. package/test/snapshots/bitwise-precedence.sl.lua +0 -2
  104. package/test/snapshots/dofile.sl.lua +0 -1
  105. package/test/snapshots/entry-scope-many-requires.m.lua +0 -14
  106. package/test/snapshots/multi-require.m.lua +0 -4
  107. package/test/snapshots/multi-require.sl.lua +0 -1
  108. package/test/snapshots/nested-module.m.lua +0 -4
  109. package/test/snapshots/require-call.m.lua +0 -5
  110. package/test/snapshots/require-call.sl.lua +0 -1
  111. package/test/snapshots/require-in-expression.sl.lua +0 -1
  112. package/test/snapshots/require-string-call.m.lua +0 -5
  113. package/test/snapshots/single-file.sl.lua +0 -6
  114. package/test/sourcemap.test.ts +0 -105
  115. package/tsconfig.eslint.json +0 -8
  116. 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.2.0",
5
- "dependencies": {
6
- "commander": "^12.1.0",
7
- "luaparse": "^0.3.1",
8
- "source-map": "^0.7.4"
9
- },
10
- "devDependencies": {
11
- "@eslint/js": "^9.39.5",
12
- "@types/node": "^22.20.1",
13
- "@types/luaparse": "^0.2.13",
14
- "eslint": "^9.39.5",
15
- "eslint-config-prettier": "^10.1.8",
16
- "globals": "^17.7.0",
17
- "prettier": "^3.9.5",
18
- "ts-node": "^10.9.2",
19
- "typescript": "^5.9.3",
20
- "typescript-eslint": "^8.63.0"
21
- },
22
- "bin": "dist/cli.js",
23
- "scripts": {
24
- "start": "node ./dist/index.js",
25
- "build": "npx tsc",
26
- "test": "node -r ts-node/register/transpile-only --test \"test/**/*.test.ts\"",
27
- "lint": "eslint .",
28
- "format": "prettier --write .",
29
- "format:check": "prettier --check ."
30
- },
31
- "author": "Nona Takahara <nona_t_2612@yahoo.co.jp>",
32
- "license": "MIT"
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
+ }
@@ -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
@@ -1,3 +0,0 @@
1
- dist
2
- node_modules
3
- package-lock.json
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
- );