@travetto/compiler 8.0.0-alpha.24 → 8.0.0-alpha.26
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/package.json +17 -17
- package/src/event.ts +2 -2
- package/src/server/server.ts +1 -1
- package/src/state.ts +11 -11
- package/support/invoke.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/compiler",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
4
|
-
"
|
|
3
|
+
"version": "8.0.0-alpha.26",
|
|
4
|
+
"private": false,
|
|
5
5
|
"description": "The compiler infrastructure for the Travetto framework",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"compiler",
|
|
@@ -11,8 +11,15 @@
|
|
|
11
11
|
"homepage": "https://travetto.io",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"author": {
|
|
14
|
-
"
|
|
15
|
-
"
|
|
14
|
+
"name": "Travetto Framework",
|
|
15
|
+
"email": "travetto.framework@gmail.com"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"url": "git+https://github.com/travetto/travetto.git",
|
|
19
|
+
"directory": "module/compiler"
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"trvc": "bin/trvc.js"
|
|
16
23
|
},
|
|
17
24
|
"files": [
|
|
18
25
|
"__index__.ts",
|
|
@@ -21,21 +28,18 @@
|
|
|
21
28
|
"support",
|
|
22
29
|
"tsconfig.trv.json"
|
|
23
30
|
],
|
|
31
|
+
"type": "module",
|
|
24
32
|
"main": "__index__.ts",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
},
|
|
28
|
-
"repository": {
|
|
29
|
-
"url": "git+https://github.com/travetto/travetto.git",
|
|
30
|
-
"directory": "module/compiler"
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
31
35
|
},
|
|
32
36
|
"dependencies": {
|
|
33
37
|
"@parcel/watcher": "^2.6.0",
|
|
34
|
-
"@travetto/manifest": "^8.0.0-alpha.
|
|
35
|
-
"@travetto/transformer": "^8.0.0-alpha.
|
|
38
|
+
"@travetto/manifest": "^8.0.0-alpha.13",
|
|
39
|
+
"@travetto/transformer": "^8.0.0-alpha.19"
|
|
36
40
|
},
|
|
37
41
|
"peerDependencies": {
|
|
38
|
-
"@travetto/cli": "^8.0.0-alpha.
|
|
42
|
+
"@travetto/cli": "^8.0.0-alpha.33"
|
|
39
43
|
},
|
|
40
44
|
"peerDependenciesMeta": {
|
|
41
45
|
"@travetto/cli": {
|
|
@@ -47,9 +51,5 @@
|
|
|
47
51
|
"roles": [
|
|
48
52
|
"compile"
|
|
49
53
|
]
|
|
50
|
-
},
|
|
51
|
-
"private": false,
|
|
52
|
-
"publishConfig": {
|
|
53
|
-
"access": "public"
|
|
54
54
|
}
|
|
55
55
|
}
|
package/src/event.ts
CHANGED
|
@@ -3,14 +3,14 @@ import type { CompilerEvent, CompilerEventPayload, CompilerEventType } from './t
|
|
|
3
3
|
const VALID_EVENT_TYPES = new Set<CompilerEventType>(['change', 'log', 'progress', 'state', 'all', 'file']);
|
|
4
4
|
|
|
5
5
|
export class EventUtil {
|
|
6
|
-
static
|
|
6
|
+
static isCompilerEventType = (value: string): value is CompilerEventType => VALID_EVENT_TYPES.has(value as CompilerEventType);
|
|
7
7
|
|
|
8
8
|
static isCompilerEvent = (value: unknown): value is CompilerEvent =>
|
|
9
9
|
typeof value === 'object' &&
|
|
10
10
|
value !== null &&
|
|
11
11
|
'type' in value &&
|
|
12
12
|
typeof value.type === 'string' &&
|
|
13
|
-
EventUtil.
|
|
13
|
+
EventUtil.isCompilerEventType(value.type);
|
|
14
14
|
|
|
15
15
|
static sendEvent<K extends CompilerEventType, T extends CompilerEventPayload<K>>(type: K, payload: T): void {
|
|
16
16
|
process.connected && process.send!({ type, payload }, undefined, undefined, () => {});
|
package/src/server/server.ts
CHANGED
|
@@ -178,7 +178,7 @@ export class CompilerServer {
|
|
|
178
178
|
let close = false;
|
|
179
179
|
switch (action) {
|
|
180
180
|
case 'event': {
|
|
181
|
-
if (EventUtil.
|
|
181
|
+
if (EventUtil.isCompilerEventType(subAction)) {
|
|
182
182
|
this.#addListener(subAction, response);
|
|
183
183
|
}
|
|
184
184
|
return;
|
package/src/state.ts
CHANGED
|
@@ -30,7 +30,7 @@ export class CompilerState implements CompilerHost {
|
|
|
30
30
|
#sourceDirectory = new Map<string, string>();
|
|
31
31
|
#sourceToEntry = new Map<string, CompileStateEntry>();
|
|
32
32
|
#outputToEntry = new Map<string, CompileStateEntry>();
|
|
33
|
-
#
|
|
33
|
+
#tscOutputFileToOutput = new Map<string, string>();
|
|
34
34
|
|
|
35
35
|
#sourceContents = new Map<string, string | undefined>();
|
|
36
36
|
#sourceFileObjects = new Map<string, SourceFile>();
|
|
@@ -198,7 +198,7 @@ export class CompilerState implements CompilerHost {
|
|
|
198
198
|
case 'package-json': {
|
|
199
199
|
const text = this.readFile(sourceFile)!;
|
|
200
200
|
const finalText = CompilerUtil.rewritePackageJSON(this.#manifest, text);
|
|
201
|
-
const location = this.#
|
|
201
|
+
const location = this.#tscOutputFileToOutput.get(output) ?? output;
|
|
202
202
|
this.#writeFile(location, finalText);
|
|
203
203
|
this.#writeExternalTypings(location, finalText);
|
|
204
204
|
break;
|
|
@@ -277,14 +277,14 @@ export class CompilerState implements CompilerHost {
|
|
|
277
277
|
this.#sourceToEntry.set(sourceFile, entry);
|
|
278
278
|
this.#sourceDirectory.set(sourceFolder, sourceFolder);
|
|
279
279
|
|
|
280
|
-
this.#
|
|
281
|
-
this.#
|
|
280
|
+
this.#tscOutputFileToOutput.set(tscOutputFile, outputFile);
|
|
281
|
+
this.#tscOutputFileToOutput.set(`${tscOutputFile}.map`, `${outputFile}.map`);
|
|
282
282
|
|
|
283
283
|
if (!isTypings) {
|
|
284
284
|
const srcBase = `${ManifestModuleUtil.withoutSourceExtension(tscOutputFile)}${ManifestModuleUtil.TYPINGS_EXT}`;
|
|
285
285
|
const outBase = `${ManifestModuleUtil.withoutSourceExtension(outputFile)}${ManifestModuleUtil.TYPINGS_EXT}`;
|
|
286
|
-
this.#
|
|
287
|
-
this.#
|
|
286
|
+
this.#tscOutputFileToOutput.set(`${srcBase}.map`, `${outBase}.map`);
|
|
287
|
+
this.#tscOutputFileToOutput.set(srcBase, outBase);
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
return entry;
|
|
@@ -319,10 +319,10 @@ export class CompilerState implements CompilerHost {
|
|
|
319
319
|
this.#sourceFiles.delete(sourceFile);
|
|
320
320
|
|
|
321
321
|
const tscOutputDts = `${ManifestModuleUtil.withoutSourceExtension(entry.tscOutputFile)}${ManifestModuleUtil.TYPINGS_EXT}`;
|
|
322
|
-
this.#
|
|
323
|
-
this.#
|
|
324
|
-
this.#
|
|
325
|
-
this.#
|
|
322
|
+
this.#tscOutputFileToOutput.delete(entry.tscOutputFile);
|
|
323
|
+
this.#tscOutputFileToOutput.delete(`${entry.tscOutputFile}.map`);
|
|
324
|
+
this.#tscOutputFileToOutput.delete(tscOutputDts);
|
|
325
|
+
this.#tscOutputFileToOutput.delete(`${tscOutputDts}.map`);
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
getAllFiles(): string[] {
|
|
@@ -361,7 +361,7 @@ export class CompilerState implements CompilerHost {
|
|
|
361
361
|
// JSX runtime shenanigans
|
|
362
362
|
text = text.replace(/support\/jsx-runtime"/g, 'support/jsx-runtime.js"');
|
|
363
363
|
|
|
364
|
-
const location = this.#
|
|
364
|
+
const location = this.#tscOutputFileToOutput.get(outputFile) ?? outputFile;
|
|
365
365
|
|
|
366
366
|
if (ManifestModuleUtil.TYPINGS_WITH_MAP_EXT_REGEX.test(outputFile)) {
|
|
367
367
|
this.#writeExternalTypings(location, text, bom);
|
package/support/invoke.ts
CHANGED
|
@@ -85,7 +85,7 @@ export async function invoke(...input: string[]): Promise<unknown> {
|
|
|
85
85
|
return CommonUtil.writeStdout(2, info);
|
|
86
86
|
}
|
|
87
87
|
case 'event': {
|
|
88
|
-
if (!EventUtil.
|
|
88
|
+
if (!EventUtil.isCompilerEventType(args[0])) {
|
|
89
89
|
throw new Error(`Unknown event type: ${args[0]}`);
|
|
90
90
|
}
|
|
91
91
|
for await (const event of client.fetchEvents(args[0])) {
|