@mindees/compiler 0.12.0 → 0.14.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/README.md +33 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
**MDC** — the Mindees Compiler. A build-time optimizer built on the TypeScript
|
|
4
4
|
Compiler API: a strict **type-check gate**, a **TSX → `createElement`** transform
|
|
5
5
|
(matching `@mindees/core`), **tree-flattening**, a per-route **code-splitting**
|
|
6
|
-
manifest,
|
|
6
|
+
manifest, a **plugin API**, a **perf-lint** (warns on reactive/render footguns),
|
|
7
|
+
and **enforced performance budgets** (a build that exceeds its bytes/elements
|
|
8
|
+
budget refuses to emit — "100% optimized" is enforced, not aspirational).
|
|
7
9
|
|
|
8
10
|
> **Status: 🧪 Experimental (Phase 4).** Implemented and tested. The working
|
|
9
11
|
> emit path is **TS → optimized JavaScript**. **TS → native machine code (AOT)**
|
|
@@ -44,6 +46,15 @@ ok.map // JSON source map
|
|
|
44
46
|
buildRouteManifest(['index.tsx', 'blog/[slug].tsx'])
|
|
45
47
|
// → { routes: [{ routePath: '/', ... },
|
|
46
48
|
// { routePath: '/blog/:slug', params: ['slug'], chunk: 'route_blog_slug' }] }
|
|
49
|
+
|
|
50
|
+
// Opt-in perf-lint: warns on reactive/render footguns (never blocks the build).
|
|
51
|
+
compileChecked(src, { perf: true }).diagnostics
|
|
52
|
+
// → [{ severity: 'warning', code: 'MDC_PERF_001', ... }] // e.g. a list via bare .map()
|
|
53
|
+
|
|
54
|
+
// Enforced budget: a violation is an ERROR that refuses to emit (spec §12).
|
|
55
|
+
const over = compileChecked(src, { budget: { maxBytes: 256, maxElements: 40 } })
|
|
56
|
+
over.code // '' — over budget, refused to emit
|
|
57
|
+
over.diagnostics // [{ severity: 'error', code: 'MDC_BUDGET_BYTES' | 'MDC_BUDGET_ELEMENTS', ... }]
|
|
47
58
|
```
|
|
48
59
|
|
|
49
60
|
## What the optimizer does
|
|
@@ -64,6 +75,22 @@ buildRouteManifest(['index.tsx', 'blog/[slug].tsx'])
|
|
|
64
75
|
- **Plugin API** (`MdcPlugin`) — plugins receive the `typescript` module and
|
|
65
76
|
return a transformer that runs **after** JSX desugaring (so they see
|
|
66
77
|
`createElement(...)` calls, not raw JSX).
|
|
78
|
+
- **Perf-lint** (`perfLint` / `compileChecked(src, { perf })`) — an opt-in pass
|
|
79
|
+
that flags real performance footguns in the fine-grained reactive + Helix render
|
|
80
|
+
model as `warning` diagnostics (it **never blocks the build**): a list via bare
|
|
81
|
+
`.map()` (`MDC_PERF_001`), a keyed builder with no `key` (`002`), heavy work in a
|
|
82
|
+
sync-lane `effect()` (`003`), a signal re-read in a loop (`004`), a subscribing
|
|
83
|
+
`effect()` with no cleanup (`005`), a static literal in a function-valued prop
|
|
84
|
+
(`006`), and a large inline list (`007`, off by default). Each rule reports a
|
|
85
|
+
concrete structural fact and *why* it's slow in this model — no invented
|
|
86
|
+
frame-time numbers. Suppress with a `// mdc-perf-ignore [CODE]` comment or
|
|
87
|
+
`rules: { MDC_PERF_001: 'off' }`. A diagnostic neither RN nor Flutter ships.
|
|
88
|
+
- **Enforced perf budgets** (`checkBudget` / `compileChecked(src, { budget })`) —
|
|
89
|
+
spec §12: the compiler **fails the build** when a module exceeds its `maxBytes`
|
|
90
|
+
(compiled UTF-8 output) or `maxElements` (pre-flatten UI-tree count) budget. A
|
|
91
|
+
violation is an `error` that refuses to emit (`code: ''`), same contract as the
|
|
92
|
+
type-check gate — "100% optimized" is enforced, not aspirational. Neither React
|
|
93
|
+
Native nor Flutter enforces a perf budget at build time.
|
|
67
94
|
|
|
68
95
|
## API
|
|
69
96
|
|
|
@@ -72,11 +99,13 @@ buildRouteManifest(['index.tsx', 'blog/[slug].tsx'])
|
|
|
72
99
|
| `typecheck(source, fileName?)` | fn | Type-check → `Diagnostic[]`. |
|
|
73
100
|
| `hasErrors(diagnostics)` | fn | Any `error`-severity diagnostic? |
|
|
74
101
|
| `compile(source, options?)` | fn | TSX → JS (+ flatten, plugins, source map). |
|
|
75
|
-
| `compileChecked(source, options?)` | fn | Gate, then compile; no emit on errors. |
|
|
76
|
-
| `
|
|
102
|
+
| `compileChecked(source, options?)` | fn | Gate (+ opt-in `perf`/`budget`), then compile; no emit on type or budget errors. |
|
|
103
|
+
| `perfLint(source, fileName?, options?)` | fn | Opt-in perf-lint → `warning` `Diagnostic[]`; never blocks. |
|
|
104
|
+
| `checkBudget(result, budget)` | fn | Perf-budget check → `error` `Diagnostic[]` for each exceeded limit. |
|
|
105
|
+
| `buildRouteManifest(files)` / `fileToRoute` / `chunkName` / `generateRouteModule` | fn | Per-route manifest + file-based route codegen. |
|
|
77
106
|
| `createFlattenTransformer` / `STATIC_MARKER` | fn | The flatten pass. |
|
|
78
107
|
| `compileToNative` | fn | 🔬 research track — throws `NotImplementedError`. |
|
|
79
|
-
| `CompileOptions`, `CompileResult`, `Diagnostic`, `MdcPlugin`, … | type | Public types. |
|
|
108
|
+
| `CompileOptions`, `CompileResult`, `Diagnostic`, `MdcPlugin`, `BudgetOptions`, `PerfLintOptions`, … | type | Public types. |
|
|
80
109
|
|
|
81
110
|
## License
|
|
82
111
|
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { Maturity, NotImplementedError, PackageInfo, notImplemented } from "@min
|
|
|
12
12
|
/** The npm package name. */
|
|
13
13
|
declare const name = "@mindees/compiler";
|
|
14
14
|
/** The package version. All `@mindees/*` packages share one locked version line. */
|
|
15
|
-
declare const VERSION = "0.
|
|
15
|
+
declare const VERSION = "0.14.0";
|
|
16
16
|
/**
|
|
17
17
|
* Current maturity. The build-time optimizer — type-check gate, TSX→createElement
|
|
18
18
|
* transform, tree-flattening, per-route manifest, plugin API — is implemented
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import { NotImplementedError, notImplemented } from "@mindees/core";
|
|
|
10
10
|
/** The npm package name. */
|
|
11
11
|
const name = "@mindees/compiler";
|
|
12
12
|
/** The package version. All `@mindees/*` packages share one locked version line. */
|
|
13
|
-
const VERSION = "0.
|
|
13
|
+
const VERSION = "0.14.0";
|
|
14
14
|
/**
|
|
15
15
|
* Current maturity. The build-time optimizer — type-check gate, TSX→createElement
|
|
16
16
|
* transform, tree-flattening, per-route manifest, plugin API — is implemented
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Maturity, PackageInfo } from '@mindees/core'\nimport { NotImplementedError, notImplemented } from '@mindees/core'\n\n/** TS → native AOT (research track). */\nexport { compileToNative, type NativeTarget } from './aot'\n/** Build-time performance budget (opt-in via `compileChecked(src, { budget })`) — fails the build. */\nexport { type BudgetOptions, checkBudget } from './budget'\n/** Tree-flattening optimizer pass. */\nexport { createFlattenTransformer, STATIC_MARKER } from './flatten'\n/** Build-time perf-lint (opt-in via `compileChecked(src, { perf: true })`). */\nexport { type PerfLintOptions, perfLint } from './perf-lint'\n/** Per-route code-splitting manifest + file-based route codegen. */\nexport {\n buildRouteManifest,\n chunkName,\n fileToRoute,\n type GenerateRouteModuleOptions,\n generateRouteModule,\n type RouteEntry,\n type RouteManifest,\n} from './routes'\n/** Compile pipeline (TSX → optimized JS). */\nexport { compile, compileChecked } from './transform'\n/** The type-check gate. */\nexport { hasErrors, typecheck } from './typecheck'\n/** Shared types. */\nexport type {\n CompileOptions,\n CompileResult,\n CompileStats,\n Diagnostic,\n DiagnosticSeverity,\n MdcPlugin,\n SourcePosition,\n} from './types'\n\n/** The npm package name. */\nexport const name = '@mindees/compiler'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { Maturity, PackageInfo } from '@mindees/core'\nimport { NotImplementedError, notImplemented } from '@mindees/core'\n\n/** TS → native AOT (research track). */\nexport { compileToNative, type NativeTarget } from './aot'\n/** Build-time performance budget (opt-in via `compileChecked(src, { budget })`) — fails the build. */\nexport { type BudgetOptions, checkBudget } from './budget'\n/** Tree-flattening optimizer pass. */\nexport { createFlattenTransformer, STATIC_MARKER } from './flatten'\n/** Build-time perf-lint (opt-in via `compileChecked(src, { perf: true })`). */\nexport { type PerfLintOptions, perfLint } from './perf-lint'\n/** Per-route code-splitting manifest + file-based route codegen. */\nexport {\n buildRouteManifest,\n chunkName,\n fileToRoute,\n type GenerateRouteModuleOptions,\n generateRouteModule,\n type RouteEntry,\n type RouteManifest,\n} from './routes'\n/** Compile pipeline (TSX → optimized JS). */\nexport { compile, compileChecked } from './transform'\n/** The type-check gate. */\nexport { hasErrors, typecheck } from './typecheck'\n/** Shared types. */\nexport type {\n CompileOptions,\n CompileResult,\n CompileStats,\n Diagnostic,\n DiagnosticSeverity,\n MdcPlugin,\n SourcePosition,\n} from './types'\n\n/** The npm package name. */\nexport const name = '@mindees/compiler'\n\n/** The package version. All `@mindees/*` packages share one locked version line. */\nexport const VERSION = '0.14.0'\n\n/**\n * Current maturity. The build-time optimizer — type-check gate, TSX→createElement\n * transform, tree-flattening, per-route manifest, plugin API — is implemented\n * and tested on the TypeScript Compiler API. TS→native AOT is a research track\n * (throws `NotImplementedError`); the working path is TS → optimized JS.\n */\nexport const maturity: Maturity = 'experimental'\n\n/**\n * Static identity + maturity metadata for this package. Frozen so the\n * self-reported identity tooling introspects cannot be mutated at runtime,\n * matching the `readonly` fields of {@link PackageInfo}.\n */\nexport const info: PackageInfo = Object.freeze({ name, version: VERSION, maturity })\n\nexport type { Maturity, PackageInfo }\nexport { NotImplementedError, notImplemented }\n"],"mappings":";;;;;;;;;;AAqCA,MAAa,OAAO;;AAGpB,MAAa,UAAU;;;;;;;AAQvB,MAAa,WAAqB;;;;;;AAOlC,MAAa,OAAoB,OAAO,OAAO;CAAE;CAAM,SAAS;CAAS;AAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindees/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "MindeesNative Compiler (MDC) — build-time optimizer: type-check gate, TSX→createElement transform, tree-flattening, per-route code-splitting, and a plugin API. TS→native AOT is a research track.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"typescript": "6.0.3",
|
|
27
|
-
"@mindees/core": "0.
|
|
27
|
+
"@mindees/core": "0.14.0"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsdown",
|