@zylaris/compiler 1.0.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/dist/compile-worker.d.ts +2 -0
- package/dist/compile-worker.d.ts.map +1 -0
- package/dist/compile-worker.js +49 -0
- package/dist/compile-worker.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +152 -0
- package/dist/index.js.map +1 -0
- package/dist/jit.d.ts +47 -0
- package/dist/jit.d.ts.map +1 -0
- package/dist/jit.js +138 -0
- package/dist/jit.js.map +1 -0
- package/dist/lazy-compile.d.ts +28 -0
- package/dist/lazy-compile.d.ts.map +1 -0
- package/dist/lazy-compile.js +171 -0
- package/dist/lazy-compile.js.map +1 -0
- package/dist/parallel-jit.d.ts +61 -0
- package/dist/parallel-jit.d.ts.map +1 -0
- package/dist/parallel-jit.js +223 -0
- package/dist/parallel-jit.js.map +1 -0
- package/package.json +39 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-worker.d.ts","sourceRoot":"","sources":["../src/compile-worker.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Worker Thread for Parallel Compilation
|
|
2
|
+
import { parentPort } from 'worker_threads';
|
|
3
|
+
import { transform as esbuildTransform } from 'esbuild';
|
|
4
|
+
parentPort?.on('message', async (task) => {
|
|
5
|
+
const startTime = performance.now();
|
|
6
|
+
try {
|
|
7
|
+
const ext = task.filename.split('.').pop()?.toLowerCase();
|
|
8
|
+
let loader = 'ts';
|
|
9
|
+
if (ext === 'tsx')
|
|
10
|
+
loader = 'tsx';
|
|
11
|
+
else if (ext === 'jsx')
|
|
12
|
+
loader = 'jsx';
|
|
13
|
+
else if (ext === 'js')
|
|
14
|
+
loader = 'js';
|
|
15
|
+
const result = await esbuildTransform(task.source, {
|
|
16
|
+
loader,
|
|
17
|
+
target: task.options.target || 'es2022',
|
|
18
|
+
format: 'esm',
|
|
19
|
+
platform: 'neutral',
|
|
20
|
+
jsx: 'automatic',
|
|
21
|
+
jsxImportSource: 'zylaris',
|
|
22
|
+
sourcemap: task.options.sourceMap ? 'inline' : false,
|
|
23
|
+
sourcesContent: false,
|
|
24
|
+
minifyWhitespace: false,
|
|
25
|
+
minifyIdentifiers: false,
|
|
26
|
+
minifySyntax: false,
|
|
27
|
+
keepNames: true,
|
|
28
|
+
treeShaking: true,
|
|
29
|
+
});
|
|
30
|
+
const compileResult = {
|
|
31
|
+
id: task.id,
|
|
32
|
+
code: result.code,
|
|
33
|
+
map: result.map || '',
|
|
34
|
+
compileTime: performance.now() - startTime,
|
|
35
|
+
};
|
|
36
|
+
parentPort?.postMessage(compileResult);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const errorResult = {
|
|
40
|
+
id: task.id,
|
|
41
|
+
code: '',
|
|
42
|
+
map: '',
|
|
43
|
+
error: error instanceof Error ? error.message : String(error),
|
|
44
|
+
compileTime: performance.now() - startTime,
|
|
45
|
+
};
|
|
46
|
+
parentPort?.postMessage(errorResult);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=compile-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile-worker.js","sourceRoot":"","sources":["../src/compile-worker.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAoBxD,UAAU,EAAE,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,IAAiB,EAAE,EAAE;IACpD,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IAEpC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,WAAW,E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AAM,CAAC,KAAK,CAAC;YAC7D,WAAW,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS;SAC3C,CAAC;QAEF,UAAU,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IACvC,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface CompileOptions {
|
|
2
|
+
target?: 'es2020' | 'es2022' | 'esnext';
|
|
3
|
+
minify?: boolean;
|
|
4
|
+
sourceMap?: boolean;
|
|
5
|
+
jsx?: {
|
|
6
|
+
runtime?: 'automatic' | 'classic';
|
|
7
|
+
importSource?: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface CompileResult {
|
|
11
|
+
code: string;
|
|
12
|
+
map?: string;
|
|
13
|
+
errors: CompileError[];
|
|
14
|
+
}
|
|
15
|
+
export interface CompileError {
|
|
16
|
+
message: string;
|
|
17
|
+
location?: {
|
|
18
|
+
line: number;
|
|
19
|
+
column: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare function compile(source: string, filename: string, options?: CompileOptions): Promise<CompileResult>;
|
|
23
|
+
export declare function bundle(entryPoints: string[], outdir: string, options?: CompileOptions): Promise<void>;
|
|
24
|
+
export declare function transformJSXForClient(source: string, filename: string): Promise<string>;
|
|
25
|
+
export * from './jit.js';
|
|
26
|
+
export declare function transformJSXForServer(source: string, filename: string): Promise<string>;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,GAAG,CAAC,EAAE;QACJ,OAAO,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;QAClC,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAexB;AAwFD,wBAAsB,MAAM,CAC1B,WAAW,EAAE,MAAM,EAAE,EACrB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAcf;AAGD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAmBjB;AAGD,cAAc,UAAU,CAAC;AAGzB,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CAmBjB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// Zylaris Compiler
|
|
2
|
+
// Transforms JSX and TypeScript for production
|
|
3
|
+
import { transform as swcTransform } from '@swc/core';
|
|
4
|
+
import * as esbuild from 'esbuild';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
export async function compile(source, filename, options = {}) {
|
|
7
|
+
const ext = path.extname(filename);
|
|
8
|
+
if (ext === '.tsx' || ext === '.jsx') {
|
|
9
|
+
return compileJSX(source, filename, options);
|
|
10
|
+
}
|
|
11
|
+
if (ext === '.ts') {
|
|
12
|
+
return compileTypeScript(source, filename, options);
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
code: source,
|
|
16
|
+
errors: [],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
async function compileJSX(source, filename, options) {
|
|
20
|
+
try {
|
|
21
|
+
const result = await swcTransform(source, {
|
|
22
|
+
filename,
|
|
23
|
+
jsc: {
|
|
24
|
+
parser: {
|
|
25
|
+
syntax: 'typescript',
|
|
26
|
+
tsx: true,
|
|
27
|
+
},
|
|
28
|
+
transform: {
|
|
29
|
+
react: {
|
|
30
|
+
runtime: options.jsx?.runtime || 'automatic',
|
|
31
|
+
importSource: options.jsx?.importSource || 'zylaris',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
target: options.target || 'es2022',
|
|
35
|
+
minify: {
|
|
36
|
+
compress: options.minify,
|
|
37
|
+
mangle: options.minify,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
sourceMaps: options.sourceMap,
|
|
41
|
+
minify: options.minify,
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
code: result.code,
|
|
45
|
+
map: result.map,
|
|
46
|
+
errors: [],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
return {
|
|
51
|
+
code: '',
|
|
52
|
+
errors: [
|
|
53
|
+
{
|
|
54
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function compileTypeScript(source, filename, options) {
|
|
61
|
+
try {
|
|
62
|
+
const result = await swcTransform(source, {
|
|
63
|
+
filename,
|
|
64
|
+
jsc: {
|
|
65
|
+
parser: {
|
|
66
|
+
syntax: 'typescript',
|
|
67
|
+
},
|
|
68
|
+
target: options.target || 'es2022',
|
|
69
|
+
minify: {
|
|
70
|
+
compress: options.minify,
|
|
71
|
+
mangle: options.minify,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
sourceMaps: options.sourceMap,
|
|
75
|
+
minify: options.minify,
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
code: result.code,
|
|
79
|
+
map: result.map,
|
|
80
|
+
errors: [],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return {
|
|
85
|
+
code: '',
|
|
86
|
+
errors: [
|
|
87
|
+
{
|
|
88
|
+
message: error instanceof Error ? error.message : 'Unknown error',
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Bundle with esbuild
|
|
95
|
+
export async function bundle(entryPoints, outdir, options = {}) {
|
|
96
|
+
await esbuild.build({
|
|
97
|
+
entryPoints,
|
|
98
|
+
outdir,
|
|
99
|
+
bundle: true,
|
|
100
|
+
splitting: true,
|
|
101
|
+
format: 'esm',
|
|
102
|
+
target: options.target || 'es2022',
|
|
103
|
+
minify: options.minify,
|
|
104
|
+
sourcemap: options.sourceMap,
|
|
105
|
+
jsx: 'automatic',
|
|
106
|
+
jsxImportSource: options.jsx?.importSource || 'zylaris',
|
|
107
|
+
metafile: true,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// Transform JSX for client-side hydration
|
|
111
|
+
export async function transformJSXForClient(source, filename) {
|
|
112
|
+
const result = await swcTransform(source, {
|
|
113
|
+
filename,
|
|
114
|
+
jsc: {
|
|
115
|
+
parser: {
|
|
116
|
+
syntax: 'typescript',
|
|
117
|
+
tsx: true,
|
|
118
|
+
},
|
|
119
|
+
transform: {
|
|
120
|
+
react: {
|
|
121
|
+
runtime: 'automatic',
|
|
122
|
+
importSource: 'zylaris',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
target: 'es2022',
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
return result.code;
|
|
129
|
+
}
|
|
130
|
+
// Export JIT compiler for development
|
|
131
|
+
export * from './jit.js';
|
|
132
|
+
// Transform JSX for server-side rendering
|
|
133
|
+
export async function transformJSXForServer(source, filename) {
|
|
134
|
+
const result = await swcTransform(source, {
|
|
135
|
+
filename,
|
|
136
|
+
jsc: {
|
|
137
|
+
parser: {
|
|
138
|
+
syntax: 'typescript',
|
|
139
|
+
tsx: true,
|
|
140
|
+
},
|
|
141
|
+
transform: {
|
|
142
|
+
react: {
|
|
143
|
+
runtime: 'automatic',
|
|
144
|
+
importSource: 'zylaris',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
target: 'es2022',
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
return result.code;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,+CAA+C;AAE/C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,IAAI,MAAM,MAAM,CAAC;AA0BxB,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,MAAc,EACd,QAAgB,EAChB,UAA0B,EAAE;IAE5B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEnC,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACrC,OAAO,UAAU,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QAClB,OAAO,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,EAAE;KACX,CAAC;AACJ,C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R,GAAG,EAAE;YACH,MAAM,EAAE;gBACN,MAAM,EAAE,YAAY;gBACpB,GAAG,EAAE,IAAI;aACV;YACD,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,OAAO,EAAE,WAAW;oBACpB,YAAY,EAAE,SAAS;iBACxB;aACF;YACD,MAAM,EAAE,QAAQ;SACjB;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,sCAAsC;AACtC,cAAc,UAAU,CAAC;AAEzB,0CAA0C;AAC1C,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAc,EACd,QAAgB;IAEhB,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE;QACxC,QAAQ;QACR,GAAG,EAAE;YACH,MAAM,EAAE;gBACN,MAAM,EAAE,YAAY;gBACpB,GAAG,EAAE,IAAI;aACV;YACD,SAAS,EAAE;gBACT,KAAK,EAAE;oBACL,OAAO,EAAE,WAAW;oBACpB,YAAY,EAAE,SAAS;iBACxB;aACF;YACD,MAAM,EAAE,QAAQ;SACjB;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC"}
|
package/dist/jit.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
interface JITCacheEntry {
|
|
2
|
+
code: string;
|
|
3
|
+
map: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
dependencies: Set<string>;
|
|
6
|
+
}
|
|
7
|
+
interface JITOptions {
|
|
8
|
+
target?: 'es2020' | 'es2022' | 'esnext';
|
|
9
|
+
jsx?: 'transform' | 'preserve';
|
|
10
|
+
jsxImportSource?: string;
|
|
11
|
+
sourceMap?: boolean;
|
|
12
|
+
cacheTimeout?: number;
|
|
13
|
+
}
|
|
14
|
+
declare const moduleCache: Map<string, JITCacheEntry>;
|
|
15
|
+
/**
|
|
16
|
+
* JIT Compile TypeScript/TSX/JSX file
|
|
17
|
+
* Uses esbuild for maximum speed with in-memory caching
|
|
18
|
+
*/
|
|
19
|
+
export declare function jitCompile(source: string, filename: string, options?: JITOptions): Promise<{
|
|
20
|
+
code: string;
|
|
21
|
+
map: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Invalidate cache for a specific file
|
|
25
|
+
*/
|
|
26
|
+
export declare function invalidateCache(filename: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Clear all cache
|
|
29
|
+
*/
|
|
30
|
+
export declare function clearCache(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get cache stats
|
|
33
|
+
*/
|
|
34
|
+
export declare function getCacheStats(): {
|
|
35
|
+
size: number;
|
|
36
|
+
entries: number;
|
|
37
|
+
hitRate: number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Warm up cache for commonly used files
|
|
41
|
+
*/
|
|
42
|
+
export declare function warmupCache(files: Array<{
|
|
43
|
+
source: string;
|
|
44
|
+
filename: string;
|
|
45
|
+
}>, options?: JITOptions): Promise<void>;
|
|
46
|
+
export { moduleCache };
|
|
47
|
+
//# sourceMappingURL=jit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jit.d.ts","sourceRoot":"","sources":["../src/jit.ts"],"names":[],"mappings":"AAMA,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B;AAED,UAAU,UAAU;IAClB,MAAM,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACxC,GAAG,CAAC,EAAE,WAAW,GAAG,UAAU,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD,QAAA,MAAM,WAAW,4BAAmC,CAAC;AA4BrD;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CA2DxC;AAiBD;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAOtD;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAGjC;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAMA;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,KAAK,EAAE,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,EAClD,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,IAAI,CAAC,CAQf;AAGD,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/jit.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// JIT Compiler for Development
|
|
2
|
+
// Ultra-fast compilation with in-memory caching
|
|
3
|
+
import { transform as esbuildTransform } from 'esbuild';
|
|
4
|
+
import { createHash } from 'crypto';
|
|
5
|
+
// In-memory cache for compiled modules
|
|
6
|
+
const moduleCache = new Map();
|
|
7
|
+
const fileTimestamps = new Map();
|
|
8
|
+
// Default options
|
|
9
|
+
const defaultOptions = {
|
|
10
|
+
target: 'es2022',
|
|
11
|
+
jsx: 'transform',
|
|
12
|
+
jsxImportSource: 'zylaris',
|
|
13
|
+
sourceMap: true,
|
|
14
|
+
cacheTimeout: 5 * 60 * 1000, // 5 minutes
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Generate cache key from content and options
|
|
18
|
+
*/
|
|
19
|
+
function generateCacheKey(source, filename, options) {
|
|
20
|
+
const content = `${source}::${filename}::${JSON.stringify(options)}`;
|
|
21
|
+
return createHash('md5').update(content).digest('hex');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Check if cache entry is valid
|
|
25
|
+
*/
|
|
26
|
+
function isCacheValid(entry, cacheTimeout) {
|
|
27
|
+
const now = Date.now();
|
|
28
|
+
return (now - entry.timestamp) < cacheTimeout;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* JIT Compile TypeScript/TSX/JSX file
|
|
32
|
+
* Uses esbuild for maximum speed with in-memory caching
|
|
33
|
+
*/
|
|
34
|
+
export async function jitCompile(source, filename, options = {}) {
|
|
35
|
+
const opts = { ...defaultOptions, ...options };
|
|
36
|
+
const cacheKey = generateCacheKey(source, filename, opts);
|
|
37
|
+
// Check cache first
|
|
38
|
+
const cached = moduleCache.get(cacheKey);
|
|
39
|
+
if (cached && isCacheValid(cached, opts.cacheTimeout)) {
|
|
40
|
+
return { code: cached.code, map: cached.map };
|
|
41
|
+
}
|
|
42
|
+
// Determine loader based on extension
|
|
43
|
+
const ext = filename.split('.').pop()?.toLowerCase();
|
|
44
|
+
let loader = 'ts';
|
|
45
|
+
if (ext === 'tsx' || (ext === 'ts' && filename.includes('jsx'))) {
|
|
46
|
+
loader = 'tsx';
|
|
47
|
+
}
|
|
48
|
+
else if (ext === 'jsx') {
|
|
49
|
+
loader = 'jsx';
|
|
50
|
+
}
|
|
51
|
+
// Compile with esbuild (faster than SWC for single-file transforms)
|
|
52
|
+
const result = await esbuildTransform(source, {
|
|
53
|
+
loader,
|
|
54
|
+
target: opts.target,
|
|
55
|
+
format: 'esm',
|
|
56
|
+
platform: 'neutral',
|
|
57
|
+
jsx: opts.jsx === 'transform' ? 'automatic' : 'preserve',
|
|
58
|
+
jsxImportSource: opts.jsxImportSource,
|
|
59
|
+
sourcemap: opts.sourceMap ? 'inline' : false,
|
|
60
|
+
sourcesContent: false,
|
|
61
|
+
// Development optimizations
|
|
62
|
+
minifyWhitespace: false,
|
|
63
|
+
minifyIdentifiers: false,
|
|
64
|
+
minifySyntax: false,
|
|
65
|
+
// Keep names for debugging
|
|
66
|
+
keepNames: true,
|
|
67
|
+
// Fastest tree shaking
|
|
68
|
+
treeShaking: true,
|
|
69
|
+
// Preserve import.meta
|
|
70
|
+
define: {
|
|
71
|
+
'import.meta.env.DEV': 'true',
|
|
72
|
+
'import.meta.env.PROD': 'false',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
const output = {
|
|
76
|
+
code: result.code,
|
|
77
|
+
map: result.map || '',
|
|
78
|
+
};
|
|
79
|
+
// Store in cache
|
|
80
|
+
moduleCache.set(cacheKey, {
|
|
81
|
+
code: output.code,
|
|
82
|
+
map: output.map,
|
|
83
|
+
timestamp: Date.now(),
|
|
84
|
+
dependencies: extractDependencies(source),
|
|
85
|
+
});
|
|
86
|
+
return output;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Extract import dependencies from source
|
|
90
|
+
*/
|
|
91
|
+
function extractDependencies(source) {
|
|
92
|
+
const deps = new Set();
|
|
93
|
+
const importRegex = /import\s+(?:{[^}]*}|[^'"]*)\s*from\s*['"]([^'"]+)['"]|import\s*['"]([^'"]+)['"]/g;
|
|
94
|
+
let match;
|
|
95
|
+
while ((match = importRegex.exec(source)) !== null) {
|
|
96
|
+
deps.add(match[1] || match[2]);
|
|
97
|
+
}
|
|
98
|
+
return deps;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Invalidate cache for a specific file
|
|
102
|
+
*/
|
|
103
|
+
export function invalidateCache(filename) {
|
|
104
|
+
// Find and remove cache entries that depend on this file
|
|
105
|
+
for (const [key, entry] of moduleCache.entries()) {
|
|
106
|
+
if (entry.dependencies.has(filename)) {
|
|
107
|
+
moduleCache.delete(key);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Clear all cache
|
|
113
|
+
*/
|
|
114
|
+
export function clearCache() {
|
|
115
|
+
moduleCache.clear();
|
|
116
|
+
fileTimestamps.clear();
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Get cache stats
|
|
120
|
+
*/
|
|
121
|
+
export function getCacheStats() {
|
|
122
|
+
return {
|
|
123
|
+
size: moduleCache.size,
|
|
124
|
+
entries: moduleCache.size,
|
|
125
|
+
hitRate: 0, // Would need to track hits/misses
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Warm up cache for commonly used files
|
|
130
|
+
*/
|
|
131
|
+
export async function warmupCache(files, options) {
|
|
132
|
+
await Promise.all(files.map(({ source, filename }) => jitCompile(source, filename, options).catch(() => {
|
|
133
|
+
// Silently ignore errors during warmup
|
|
134
|
+
})));
|
|
135
|
+
}
|
|
136
|
+
// Export for monitoring
|
|
137
|
+
export { moduleCache };
|
|
138
|
+
//# sourceMappingURL=jit.js.map
|
package/dist/jit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jit.js","sourceRoot":"","sources":["../src/jit.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,gDAAgD;AAEhD,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAoB,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAiBpC,uCAAuC;AACvC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAyB,CAAC;AACrD,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;AAEjD,kBAAkB;AAClB,MAAM,cAAc,GAAe;IACjC,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,WAAW;IAChB,eAAe,EAAE,SAAS;IAC1B,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAE,YAAY;CAC1C,CAAC;AAEF;;GAEG;AACH,SAAS,gBAAgB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O,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;QAC/C,uCAAuC;IACzC,CAAC,CAAC,CACH,CACF,CAAC;AACJ,CAAC;AAED,wBAAwB;AACxB,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface LazyCompileOptions {
|
|
2
|
+
root: string;
|
|
3
|
+
entryPoints: string[];
|
|
4
|
+
onCompile: (filename: string, code: string) => void;
|
|
5
|
+
}
|
|
6
|
+
declare class ModuleGraph {
|
|
7
|
+
private modules;
|
|
8
|
+
private onCompile;
|
|
9
|
+
private compileQueue;
|
|
10
|
+
private processing;
|
|
11
|
+
constructor(options: LazyCompileOptions);
|
|
12
|
+
private addModule;
|
|
13
|
+
private generateId;
|
|
14
|
+
requestModule(filename: string): Promise<void>;
|
|
15
|
+
private processQueue;
|
|
16
|
+
private compileModule;
|
|
17
|
+
private extractDependencies;
|
|
18
|
+
private transformCode;
|
|
19
|
+
getCompilationOrder(): string[];
|
|
20
|
+
invalidate(filename: string): string[];
|
|
21
|
+
getStats(): {
|
|
22
|
+
total: number;
|
|
23
|
+
compiled: number;
|
|
24
|
+
pending: number;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export { ModuleGraph as LazyModuleGraph };
|
|
28
|
+
//# sourceMappingURL=lazy-compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-compile.d.ts","sourceRoot":"","sources":["../src/lazy-compile.ts"],"names":[],"mappings":"AAMA,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAaD,cAAM,WAAW;IACf,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,SAAS,CAA2C;IAC5D,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,EAAE,kBAAkB;IASvC,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,UAAU;IAKZ,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAatC,YAAY;YAWZ,aAAa;IAqC3B,OAAO,CAAC,mBAAmB;YA4Bb,aAAa;IAO3B,mBAAmB,IAAI,MAAM,EAAE;IAyB/B,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAyBtC,QAAQ;;;;;CAeT;AAGD,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Lazy Compilation - Only compile what's needed
|
|
2
|
+
// Speeds up initial dev server startup dramatically
|
|
3
|
+
import fs from 'fs/promises';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
// Module Graph for tracking dependencies
|
|
6
|
+
class ModuleGraph {
|
|
7
|
+
modules = new Map();
|
|
8
|
+
onCompile;
|
|
9
|
+
compileQueue = [];
|
|
10
|
+
processing = false;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.onCompile = options.onCompile;
|
|
13
|
+
// Initialize entry points
|
|
14
|
+
for (const entry of options.entryPoints) {
|
|
15
|
+
this.addModule(entry);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
addModule(filename) {
|
|
19
|
+
if (!this.modules.has(filename)) {
|
|
20
|
+
this.modules.set(filename, {
|
|
21
|
+
id: this.generateId(filename),
|
|
22
|
+
filename,
|
|
23
|
+
dependencies: new Set(),
|
|
24
|
+
dependents: new Set(),
|
|
25
|
+
compiled: false,
|
|
26
|
+
compiling: false,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return this.modules.get(filename);
|
|
30
|
+
}
|
|
31
|
+
generateId(filename) {
|
|
32
|
+
return Buffer.from(filename).toString('base64').replace(/[^a-zA-Z0-9]/g, '');
|
|
33
|
+
}
|
|
34
|
+
// Mark module as requested (lazy compile)
|
|
35
|
+
async requestModule(filename) {
|
|
36
|
+
const module = this.addModule(filename);
|
|
37
|
+
if (module.compiled || module.compiling)
|
|
38
|
+
return;
|
|
39
|
+
module.compiling = true;
|
|
40
|
+
this.compileQueue.push(filename);
|
|
41
|
+
if (!this.processing) {
|
|
42
|
+
this.processQueue();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async processQueue() {
|
|
46
|
+
this.processing = true;
|
|
47
|
+
while (this.compileQueue.length > 0) {
|
|
48
|
+
const filename = this.compileQueue.shift();
|
|
49
|
+
await this.compileModule(filename);
|
|
50
|
+
}
|
|
51
|
+
this.processing = false;
|
|
52
|
+
}
|
|
53
|
+
async compileModule(filename) {
|
|
54
|
+
const module = this.modules.get(filename);
|
|
55
|
+
if (!module || module.compiled)
|
|
56
|
+
return;
|
|
57
|
+
try {
|
|
58
|
+
// Read source
|
|
59
|
+
const source = await fs.readFile(filename, 'utf-8');
|
|
60
|
+
// Extract dependencies
|
|
61
|
+
const deps = this.extractDependencies(source, filename);
|
|
62
|
+
// Update dependency graph
|
|
63
|
+
for (const dep of deps) {
|
|
64
|
+
module.dependencies.add(dep);
|
|
65
|
+
const depModule = this.addModule(dep);
|
|
66
|
+
depModule.dependents.add(filename);
|
|
67
|
+
// Queue dependency for compilation
|
|
68
|
+
if (!depModule.compiled && !depModule.compiling) {
|
|
69
|
+
this.compileQueue.push(dep);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// Compile (in real implementation, use JIT compiler)
|
|
73
|
+
const code = await this.transformCode(source, filename);
|
|
74
|
+
module.compiled = true;
|
|
75
|
+
module.compiling = false;
|
|
76
|
+
// Notify
|
|
77
|
+
this.onCompile(filename, code);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
module.error = String(error);
|
|
81
|
+
module.compiling = false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
extractDependencies(source, filename) {
|
|
85
|
+
const deps = [];
|
|
86
|
+
const basedir = path.dirname(filename);
|
|
87
|
+
// Match ES6 imports
|
|
88
|
+
const importRegex = /import\s+(?:{[^}]*}|[^'"]*)\s*from\s*['"]([^'"]+)['"]|import\s*['"]([^'"]+)['"]/g;
|
|
89
|
+
let match;
|
|
90
|
+
while ((match = importRegex.exec(source)) !== null) {
|
|
91
|
+
const importPath = match[1] || match[2];
|
|
92
|
+
// Resolve relative paths
|
|
93
|
+
if (importPath.startsWith('.')) {
|
|
94
|
+
const resolved = path.resolve(basedir, importPath);
|
|
95
|
+
// Try extensions
|
|
96
|
+
const extensions = ['.tsx', '.ts', '.jsx', '.js'];
|
|
97
|
+
for (const ext of extensions) {
|
|
98
|
+
const fullPath = resolved + ext;
|
|
99
|
+
deps.push(fullPath);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return deps;
|
|
105
|
+
}
|
|
106
|
+
async transformCode(source, filename) {
|
|
107
|
+
// In real implementation, call JIT compiler here
|
|
108
|
+
// For now, return a placeholder
|
|
109
|
+
return `/* compiled: ${filename} */\n${source}`;
|
|
110
|
+
}
|
|
111
|
+
// Get compilation order (for pre-compilation)
|
|
112
|
+
getCompilationOrder() {
|
|
113
|
+
const visited = new Set();
|
|
114
|
+
const order = [];
|
|
115
|
+
const visit = (filename) => {
|
|
116
|
+
if (visited.has(filename))
|
|
117
|
+
return;
|
|
118
|
+
visited.add(filename);
|
|
119
|
+
const module = this.modules.get(filename);
|
|
120
|
+
if (module) {
|
|
121
|
+
for (const dep of module.dependencies) {
|
|
122
|
+
visit(dep);
|
|
123
|
+
}
|
|
124
|
+
order.push(filename);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
for (const [filename] of this.modules) {
|
|
128
|
+
visit(filename);
|
|
129
|
+
}
|
|
130
|
+
return order;
|
|
131
|
+
}
|
|
132
|
+
// Invalidate module and dependents
|
|
133
|
+
invalidate(filename) {
|
|
134
|
+
const module = this.modules.get(filename);
|
|
135
|
+
if (!module)
|
|
136
|
+
return [];
|
|
137
|
+
const toInvalidate = new Set();
|
|
138
|
+
const queue = [filename];
|
|
139
|
+
while (queue.length > 0) {
|
|
140
|
+
const current = queue.shift();
|
|
141
|
+
const mod = this.modules.get(current);
|
|
142
|
+
if (mod && !toInvalidate.has(current)) {
|
|
143
|
+
toInvalidate.add(current);
|
|
144
|
+
mod.compiled = false;
|
|
145
|
+
// Add dependents
|
|
146
|
+
for (const dep of mod.dependents) {
|
|
147
|
+
queue.push(dep);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return Array.from(toInvalidate);
|
|
152
|
+
}
|
|
153
|
+
getStats() {
|
|
154
|
+
let compiled = 0;
|
|
155
|
+
let pending = 0;
|
|
156
|
+
for (const mod of this.modules.values()) {
|
|
157
|
+
if (mod.compiled)
|
|
158
|
+
compiled++;
|
|
159
|
+
if (mod.compiling)
|
|
160
|
+
pending++;
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
total: this.modules.size,
|
|
164
|
+
compiled,
|
|
165
|
+
pending,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Export for use in dev server
|
|
170
|
+
export { ModuleGraph as LazyModuleGraph };
|
|
171
|
+
//# sourceMappingURL=lazy-compile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-compile.js","sourceRoot":"","sources":["../src/lazy-compile.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,oDAAoD;AAEpD,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAkBxB,yCAAyC;AACzC,MAAM,WAAW;IACP,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IACxC,SAAS,CAA2C;IACpD,YAAY,GAAa,EAAE,CAAC;IAC5B,UAAU,GAAG,KAAK,CAAC;IAE3B,YAAY,OAA2B;QACrC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,KAAK,CAAC,KAAK,EAAG,CAAC;YAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YAEtC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACtC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBAC1B,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC;gBAErB,iBAAiB;gBACjB,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;oBACjC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED,QAAQ;QACN,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,OAAO,GAAG,CAAC,CAAC;QAEhB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACxC,IAAI,GAAG,CAAC,QAAQ;gBAAE,QAAQ,EAAE,CAAC;YAC7B,IAAI,GAAG,CAAC,SAAS;gBAAE,OAAO,EAAE,CAAC;QAC/B,CAAC;QAED,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACxB,QAAQ;YACR,OAAO;SACR,CAAC;IACJ,CAAC;CACF;AAED,+BAA+B;AAC/B,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
interface CompileTask {
|
|
2
|
+
id: string;
|
|
3
|
+
source: string;
|
|
4
|
+
filename: string;
|
|
5
|
+
options: any;
|
|
6
|
+
}
|
|
7
|
+
interface CompileResult {
|
|
8
|
+
id: string;
|
|
9
|
+
code: string;
|
|
10
|
+
map: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
compileTime: number;
|
|
13
|
+
}
|
|
14
|
+
declare class WorkerPool {
|
|
15
|
+
private workers;
|
|
16
|
+
private queue;
|
|
17
|
+
private maxWorkers;
|
|
18
|
+
constructor(maxWorkers?: number);
|
|
19
|
+
private getWorker;
|
|
20
|
+
private isWorkerBusy;
|
|
21
|
+
execute(task: CompileTask): Promise<CompileResult>;
|
|
22
|
+
private processQueue;
|
|
23
|
+
terminate(): Promise<number[]>;
|
|
24
|
+
}
|
|
25
|
+
declare class PersistentCache {
|
|
26
|
+
private cacheDir;
|
|
27
|
+
constructor(cacheDir?: string);
|
|
28
|
+
private ensureCacheDir;
|
|
29
|
+
private getCachePath;
|
|
30
|
+
get(key: string): Promise<{
|
|
31
|
+
code: string;
|
|
32
|
+
map: string;
|
|
33
|
+
} | null>;
|
|
34
|
+
set(key: string, code: string, map: string): Promise<void>;
|
|
35
|
+
clear(): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export declare class ParallelJITCompiler {
|
|
38
|
+
private workerPool;
|
|
39
|
+
private persistentCache;
|
|
40
|
+
private memoryCache;
|
|
41
|
+
private cacheTimeout;
|
|
42
|
+
constructor();
|
|
43
|
+
compile(source: string, filename: string, options?: any): Promise<{
|
|
44
|
+
code: string;
|
|
45
|
+
map: string;
|
|
46
|
+
fromCache: boolean;
|
|
47
|
+
compileTime: number;
|
|
48
|
+
}>;
|
|
49
|
+
private generateCacheKey;
|
|
50
|
+
invalidate(filename: string): Promise<void>;
|
|
51
|
+
clearMemoryCache(): void;
|
|
52
|
+
clearAllCache(): Promise<void>;
|
|
53
|
+
getStats(): {
|
|
54
|
+
memoryCacheSize: number;
|
|
55
|
+
maxWorkers: number;
|
|
56
|
+
};
|
|
57
|
+
terminate(): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
export declare function getParallelCompiler(): ParallelJITCompiler;
|
|
60
|
+
export { WorkerPool, PersistentCache };
|
|
61
|
+
//# sourceMappingURL=parallel-jit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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CAAiB;;IAO/B,OAAO,CACX,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,GAAQ,GAChB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IA8DlF,OAAO,CAAC,gBAAgB;IAKlB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASjD,gBAAgB,IAAI,IAAI;IAIlB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAKpC,QAAQ;;;;IAOF,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAGjC;AAKD,wBAAgB,mBAAmB,IAAI,mBAAmB,CAKzD;AAGD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
// Parallel JIT Compiler with Worker Threads
|
|
2
|
+
// For maximum performance during development
|
|
3
|
+
import { Worker } from 'worker_threads';
|
|
4
|
+
import { cpus } from 'os';
|
|
5
|
+
import { createHash } from 'crypto';
|
|
6
|
+
import fs from 'fs/promises';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = path.dirname(__filename);
|
|
11
|
+
// Worker pool management
|
|
12
|
+
class WorkerPool {
|
|
13
|
+
workers = [];
|
|
14
|
+
queue = [];
|
|
15
|
+
maxWorkers;
|
|
16
|
+
constructor(maxWorkers = Math.max(1, cpus().length - 1)) {
|
|
17
|
+
this.maxWorkers = maxWorkers;
|
|
18
|
+
}
|
|
19
|
+
async getWorker() {
|
|
20
|
+
// Return existing idle worker or create new one
|
|
21
|
+
const idleWorker = this.workers.find(w => !this.isWorkerBusy(w));
|
|
22
|
+
if (idleWorker)
|
|
23
|
+
return idleWorker;
|
|
24
|
+
if (this.workers.length < this.maxWorkers) {
|
|
25
|
+
const worker = new Worker(path.join(__dirname, 'compile-worker.js'));
|
|
26
|
+
this.workers.push(worker);
|
|
27
|
+
return worker;
|
|
28
|
+
}
|
|
29
|
+
// Wait for a worker to become available
|
|
30
|
+
return new Promise((resolve) => {
|
|
31
|
+
const checkInterval = setInterval(() => {
|
|
32
|
+
const idle = this.workers.find(w => !this.isWorkerBusy(w));
|
|
33
|
+
if (idle) {
|
|
34
|
+
clearInterval(checkInterval);
|
|
35
|
+
resolve(idle);
|
|
36
|
+
}
|
|
37
|
+
}, 10);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
isWorkerBusy(worker) {
|
|
41
|
+
// Check if worker has pending message handlers
|
|
42
|
+
return worker._isBusy === true;
|
|
43
|
+
}
|
|
44
|
+
async execute(task) {
|
|
45
|
+
const worker = await this.getWorker();
|
|
46
|
+
worker._isBusy = true;
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
const messageHandler = (result) => {
|
|
49
|
+
if (result.id === task.id) {
|
|
50
|
+
worker.off('message', messageHandler);
|
|
51
|
+
worker._isBusy = false;
|
|
52
|
+
if (result.error) {
|
|
53
|
+
reject(new Error(result.error));
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
resolve(result);
|
|
57
|
+
}
|
|
58
|
+
this.processQueue();
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
worker.on('message', messageHandler);
|
|
62
|
+
worker.postMessage(task);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
processQueue() {
|
|
66
|
+
if (this.queue.length === 0)
|
|
67
|
+
return;
|
|
68
|
+
const next = this.queue.shift();
|
|
69
|
+
if (next) {
|
|
70
|
+
this.execute(next.task).then(next.resolve).catch(next.reject);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
terminate() {
|
|
74
|
+
return Promise.all(this.workers.map(w => w.terminate()));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// Persistent disk cache
|
|
78
|
+
class PersistentCache {
|
|
79
|
+
cacheDir;
|
|
80
|
+
constructor(cacheDir = '.zylaris/cache') {
|
|
81
|
+
this.cacheDir = cacheDir;
|
|
82
|
+
this.ensureCacheDir();
|
|
83
|
+
}
|
|
84
|
+
async ensureCacheDir() {
|
|
85
|
+
await fs.mkdir(this.cacheDir, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
getCachePath(key) {
|
|
88
|
+
return path.join(this.cacheDir, `${key}.json`);
|
|
89
|
+
}
|
|
90
|
+
async get(key) {
|
|
91
|
+
try {
|
|
92
|
+
const cachePath = this.getCachePath(key);
|
|
93
|
+
const data = await fs.readFile(cachePath, 'utf-8');
|
|
94
|
+
const parsed = JSON.parse(data);
|
|
95
|
+
// Check if cache is still valid (24 hours)
|
|
96
|
+
const age = Date.now() - parsed.timestamp;
|
|
97
|
+
if (age > 24 * 60 * 60 * 1000) {
|
|
98
|
+
await fs.unlink(cachePath);
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
return { code: parsed.code, map: parsed.map };
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async set(key, code, map) {
|
|
108
|
+
const cachePath = this.getCachePath(key);
|
|
109
|
+
const data = JSON.stringify({
|
|
110
|
+
code,
|
|
111
|
+
map,
|
|
112
|
+
timestamp: Date.now(),
|
|
113
|
+
});
|
|
114
|
+
await fs.writeFile(cachePath, data, 'utf-8');
|
|
115
|
+
}
|
|
116
|
+
async clear() {
|
|
117
|
+
const files = await fs.readdir(this.cacheDir);
|
|
118
|
+
await Promise.all(files.map(f => fs.unlink(path.join(this.cacheDir, f))));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Main Parallel JIT Compiler
|
|
122
|
+
export class ParallelJITCompiler {
|
|
123
|
+
workerPool;
|
|
124
|
+
persistentCache;
|
|
125
|
+
memoryCache = new Map();
|
|
126
|
+
cacheTimeout = 5 * 60 * 1000; // 5 minutes for memory cache
|
|
127
|
+
constructor() {
|
|
128
|
+
this.workerPool = new WorkerPool();
|
|
129
|
+
this.persistentCache = new PersistentCache();
|
|
130
|
+
}
|
|
131
|
+
async compile(source, filename, options = {}) {
|
|
132
|
+
const cacheKey = this.generateCacheKey(source, filename, options);
|
|
133
|
+
const startTime = performance.now();
|
|
134
|
+
// 1. Check memory cache first (fastest)
|
|
135
|
+
const memoryCached = this.memoryCache.get(cacheKey);
|
|
136
|
+
if (memoryCached && Date.now() - memoryCached.timestamp < this.cacheTimeout) {
|
|
137
|
+
return {
|
|
138
|
+
code: memoryCached.code,
|
|
139
|
+
map: memoryCached.map,
|
|
140
|
+
fromCache: true,
|
|
141
|
+
compileTime: performance.now() - startTime,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
// 2. Check persistent cache
|
|
145
|
+
const diskCached = await this.persistentCache.get(cacheKey);
|
|
146
|
+
if (diskCached) {
|
|
147
|
+
// Promote to memory cache
|
|
148
|
+
this.memoryCache.set(cacheKey, {
|
|
149
|
+
...diskCached,
|
|
150
|
+
timestamp: Date.now(),
|
|
151
|
+
});
|
|
152
|
+
return {
|
|
153
|
+
code: diskCached.code,
|
|
154
|
+
map: diskCached.map,
|
|
155
|
+
fromCache: true,
|
|
156
|
+
compileTime: performance.now() - startTime,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
// 3. Compile in parallel using worker
|
|
160
|
+
const result = await this.workerPool.execute({
|
|
161
|
+
id: cacheKey,
|
|
162
|
+
source,
|
|
163
|
+
filename,
|
|
164
|
+
options,
|
|
165
|
+
});
|
|
166
|
+
const compileTime = performance.now() - startTime;
|
|
167
|
+
// 4. Cache results
|
|
168
|
+
this.memoryCache.set(cacheKey, {
|
|
169
|
+
code: result.code,
|
|
170
|
+
map: result.map,
|
|
171
|
+
timestamp: Date.now(),
|
|
172
|
+
});
|
|
173
|
+
// Save to disk cache in background
|
|
174
|
+
this.persistentCache.set(cacheKey, result.code, result.map).catch(() => {
|
|
175
|
+
// Ignore disk cache errors
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
code: result.code,
|
|
179
|
+
map: result.map,
|
|
180
|
+
fromCache: false,
|
|
181
|
+
compileTime,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
generateCacheKey(source, filename, options) {
|
|
185
|
+
const content = `${source}::${filename}::${JSON.stringify(options)}`;
|
|
186
|
+
return createHash('md5').update(content).digest('hex');
|
|
187
|
+
}
|
|
188
|
+
async invalidate(filename) {
|
|
189
|
+
// Invalidate all cache entries that might depend on this file
|
|
190
|
+
for (const [key] of this.memoryCache.entries()) {
|
|
191
|
+
if (key.includes(filename)) {
|
|
192
|
+
this.memoryCache.delete(key);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
clearMemoryCache() {
|
|
197
|
+
this.memoryCache.clear();
|
|
198
|
+
}
|
|
199
|
+
async clearAllCache() {
|
|
200
|
+
this.memoryCache.clear();
|
|
201
|
+
await this.persistentCache.clear();
|
|
202
|
+
}
|
|
203
|
+
getStats() {
|
|
204
|
+
return {
|
|
205
|
+
memoryCacheSize: this.memoryCache.size,
|
|
206
|
+
maxWorkers: Math.max(1, cpus().length - 1),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
async terminate() {
|
|
210
|
+
await this.workerPool.terminate();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// Singleton instance
|
|
214
|
+
let compilerInstance = null;
|
|
215
|
+
export function getParallelCompiler() {
|
|
216
|
+
if (!compilerInstance) {
|
|
217
|
+
compilerInstance = new ParallelJITCompiler();
|
|
218
|
+
}
|
|
219
|
+
return compilerInstance;
|
|
220
|
+
}
|
|
221
|
+
// Export for direct use
|
|
222
|
+
export { WorkerPool, PersistentCache };
|
|
223
|
+
//# sourceMappingURL=parallel-jit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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
|
+
"description": "Compiler for Zylaris Framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"dev": "tsc --watch",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"clean": "rm -rf dist"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@swc/core": "^1.3.100",
|
|
26
|
+
"@swc/helpers": "^0.5.3",
|
|
27
|
+
"esbuild": "^0.19.8"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.0.0",
|
|
31
|
+
"typescript": "^5.3.3"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"compiler",
|
|
35
|
+
"transform",
|
|
36
|
+
"zylaris"
|
|
37
|
+
],
|
|
38
|
+
"license": "MIT"
|
|
39
|
+
}
|