@travetto/compiler 8.0.0-alpha.20 → 8.0.0-alpha.21

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.
@@ -2,11 +2,11 @@ import { spawn } from 'node:child_process';
2
2
 
3
3
  import type { ManifestContext } from '@travetto/manifest';
4
4
 
5
- import type { CompilerEvent, CompilerLogLevel } from '../types.ts';
6
- import { AsyncQueue } from '../queue.ts';
7
- import { Log } from '../log.ts';
8
5
  import { CommonUtil } from '../common.ts';
9
6
  import { EventUtil } from '../event.ts';
7
+ import { Log } from '../log.ts';
8
+ import { AsyncQueue } from '../queue.ts';
9
+ import type { CompilerEvent, CompilerLogLevel } from '../types.ts';
10
10
  import type { CompilerClient } from './client.ts';
11
11
  import { CompilerServer } from './server.ts';
12
12
 
@@ -17,7 +17,7 @@ const log = Log.scoped('compiler-exec');
17
17
  */
18
18
  export class CompilerManager {
19
19
  /** Run compile process */
20
- static async * #runTarget(ctx: ManifestContext, watching: boolean, signal: AbortSignal): AsyncIterable<CompilerEvent> {
20
+ static async *#runTarget(ctx: ManifestContext, watching: boolean, signal: AbortSignal): AsyncIterable<CompilerEvent> {
21
21
  if (signal.aborted) {
22
22
  log.debug('Skipping, shutting down');
23
23
  return;
@@ -30,17 +30,17 @@ export class CompilerManager {
30
30
  env: {
31
31
  ...process.env,
32
32
  TRV_COMPILER_WATCH: String(watching),
33
- TRV_MANIFEST: CommonUtil.resolveWorkspace(ctx, ctx.build.outputFolder, 'node_modules', ctx.workspace.name),
33
+ TRV_MANIFEST: CommonUtil.resolveWorkspace(ctx, ctx.build.outputFolder, 'node_modules', ctx.workspace.name)
34
34
  },
35
35
  detached: true,
36
- stdio: ['pipe', 1, 2, 'ipc'],
36
+ stdio: ['pipe', 1, 2, 'ipc']
37
37
  })
38
38
  .on('message', message => EventUtil.isCompilerEvent(message) && queue.add(message))
39
39
  .on('exit', () => queue.close());
40
40
 
41
41
  const kill = (): unknown => {
42
42
  log.debug('Shutting down process');
43
- return (subProcess.connected ? subProcess.send('shutdown', () => subProcess.kill()) : subProcess.kill());
43
+ return subProcess.connected ? subProcess.send('shutdown', () => subProcess.kill()) : subProcess.kill();
44
44
  };
45
45
 
46
46
  process.once('SIGINT', kill);
@@ -58,11 +58,15 @@ export class CompilerManager {
58
58
  }
59
59
 
60
60
  /** Main entry point for compilation */
61
- static async compile(ctx: ManifestContext, client: CompilerClient, config: { watch?: boolean, logLevel?: CompilerLogLevel, forceRestart?: boolean }): Promise<void> {
61
+ static async compile(
62
+ ctx: ManifestContext,
63
+ client: CompilerClient,
64
+ config: { watch?: boolean; logLevel?: CompilerLogLevel; forceRestart?: boolean }
65
+ ): Promise<void> {
62
66
  Log.initLevel(config.logLevel ?? 'info');
63
67
  const watch = !!config.watch;
64
68
 
65
- if (config.forceRestart && await client.stop()) {
69
+ if (config.forceRestart && (await client.stop())) {
66
70
  log.info('Stopped existing server');
67
71
  }
68
72
 
@@ -84,8 +88,9 @@ export class CompilerManager {
84
88
 
85
89
  /** Compile only if necessary */
86
90
  static async compileIfNecessary(ctx: ManifestContext, client: CompilerClient): Promise<void> {
87
- if (!(await client.isWatching())) { // Short circuit if we can
91
+ if (!(await client.isWatching())) {
92
+ // Short circuit if we can
88
93
  await this.compile(ctx, client, { watch: false, logLevel: 'error' });
89
94
  }
90
95
  }
91
- }
96
+ }
@@ -3,11 +3,10 @@ import path from 'node:path';
3
3
 
4
4
  import type { ManifestContext } from '@travetto/manifest';
5
5
 
6
- import { Log, type Logger } from '../log.ts';
7
6
  import { CommonUtil } from '../common.ts';
7
+ import { Log, type Logger } from '../log.ts';
8
8
 
9
9
  export class ProcessHandle {
10
-
11
10
  #file: string;
12
11
  #log: Logger;
13
12
 
@@ -22,13 +21,17 @@ export class ProcessHandle {
22
21
  }
23
22
 
24
23
  getProcessId(): Promise<number | undefined> {
25
- return fs.readFile(this.#file, 'utf8')
26
- .then(processId => +processId > 0 ? +processId : undefined, () => undefined);
24
+ return fs.readFile(this.#file, 'utf8').then(
25
+ processId => (+processId > 0 ? +processId : undefined),
26
+ () => undefined
27
+ );
27
28
  }
28
29
 
29
30
  async isRunning(): Promise<boolean> {
30
31
  const processId = await this.getProcessId();
31
- if (!processId) { return false; }
32
+ if (!processId) {
33
+ return false;
34
+ }
32
35
  try {
33
36
  process.kill(processId, 0); // See if process is still running
34
37
  this.#log.debug('Is running', processId);
@@ -41,11 +44,11 @@ export class ProcessHandle {
41
44
 
42
45
  async kill(): Promise<boolean> {
43
46
  const processId = await this.getProcessId();
44
- if (processId && await this.isRunning()) {
47
+ if (processId && (await this.isRunning())) {
45
48
  try {
46
49
  this.#log.debug('Killing', processId);
47
50
  return process.kill(processId);
48
- } catch { }
51
+ } catch {}
49
52
  }
50
53
  return false;
51
54
  }
@@ -58,8 +61,9 @@ export class ProcessHandle {
58
61
  }
59
62
 
60
63
  this.#log.debug('Ensuring Killed', processId);
61
- while ((Date.now() - start) < gracePeriod) { // Ensure its done
62
- if (!await this.isRunning()) {
64
+ while (Date.now() - start < gracePeriod) {
65
+ // Ensure its done
66
+ if (!(await this.isRunning())) {
63
67
  return true;
64
68
  }
65
69
  await CommonUtil.blockingTimeout(100);
@@ -67,7 +71,7 @@ export class ProcessHandle {
67
71
  try {
68
72
  this.#log.debug('Force Killing', processId);
69
73
  process.kill(processId); // Force kill
70
- } catch { }
74
+ } catch {}
71
75
  this.#log.debug('Did Kill', this.#file, !!processId);
72
76
  return true;
73
77
  }
@@ -1,15 +1,15 @@
1
- import http from 'node:http';
2
- import fs from 'node:fs/promises';
3
1
  import { setMaxListeners } from 'node:events';
2
+ import fs from 'node:fs/promises';
3
+ import http from 'node:http';
4
4
 
5
5
  import type { ManifestContext } from '@travetto/manifest';
6
6
 
7
- import type { CompilerProgressEvent, CompilerEvent, CompilerEventType, CompilerServerInfo } from '../types.ts';
8
- import { Log } from '../log.ts';
9
7
  import { CommonUtil } from '../common.ts';
8
+ import { EventUtil } from '../event.ts';
9
+ import { Log } from '../log.ts';
10
+ import type { CompilerEvent, CompilerEventType, CompilerProgressEvent, CompilerServerInfo } from '../types.ts';
10
11
  import { CompilerClient } from './client.ts';
11
12
  import { ProcessHandle } from './process-handle.ts';
12
- import { EventUtil } from '../event.ts';
13
13
 
14
14
  const log = Log.scoped('server');
15
15
 
@@ -17,7 +17,6 @@ const log = Log.scoped('server');
17
17
  * Compiler Server Class
18
18
  */
19
19
  export class CompilerServer {
20
-
21
20
  #ctx: ManifestContext;
22
21
  #server: http.Server;
23
22
  #listenersAll = new Set<http.ServerResponse>();
@@ -46,11 +45,14 @@ export class CompilerServer {
46
45
  url: this.#url
47
46
  };
48
47
 
49
- this.#server = http.createServer({
50
- keepAlive: true,
51
- requestTimeout: 1000 * 60 * 60,
52
- keepAliveTimeout: 1000 * 60 * 60,
53
- }, (request, response) => this.#onRequest(request, response));
48
+ this.#server = http.createServer(
49
+ {
50
+ keepAlive: true,
51
+ requestTimeout: 1000 * 60 * 60,
52
+ keepAliveTimeout: 1000 * 60 * 60
53
+ },
54
+ (request, response) => this.#onRequest(request, response)
55
+ );
54
56
 
55
57
  setMaxListeners(1000, this.signal);
56
58
  }
@@ -74,7 +76,7 @@ export class CompilerServer {
74
76
  .on('error', async error => {
75
77
  if ('code' in error && error.code === 'EADDRINUSE') {
76
78
  const info = await this.#client.info();
77
- resolve((info && !info.watching && this.watching) ? 'retry' : 'running');
79
+ resolve(info && !info.watching && this.watching ? 'retry' : 'running');
78
80
  } else {
79
81
  log.warn('Failed in running server', error);
80
82
  reject(error);
@@ -106,7 +108,8 @@ export class CompilerServer {
106
108
  const id = `id_${Date.now()}_${Math.random()}`.replace('.', '1');
107
109
  (this.#listeners[type] ??= {})[id] = response;
108
110
  this.#listenersAll.add(response);
109
- if (type === 'state' || type === 'all') { // Send on initial connect
111
+ if (type === 'state' || type === 'all') {
112
+ // Send on initial connect
110
113
  this.#emitEvent({ type: 'state', payload: { state: this.info.state } }, id);
111
114
  } else {
112
115
  response.write('\n'); // Send at least one byte on listen
@@ -146,15 +149,20 @@ export class CompilerServer {
146
149
  this.info.iteration = Date.now();
147
150
  await CommonUtil.blockingTimeout(20);
148
151
  for (const listener of this.#listenersAll) {
149
- try { listener.end(); } catch { }
152
+ try {
153
+ listener.end();
154
+ } catch {}
150
155
  }
151
156
  this.#listeners = {}; // Ensure its empty
152
157
  this.#listenersAll.clear();
153
158
  }
154
159
 
155
160
  async #clean(): Promise<{ clean: boolean }> {
156
- await Promise.all([this.#ctx.build.outputFolder, this.#ctx.build.typesFolder]
157
- .map(folder => fs.rm(CommonUtil.resolveWorkspace(this.#ctx, folder), { recursive: true, force: true })));
161
+ await Promise.all(
162
+ [this.#ctx.build.outputFolder, this.#ctx.build.typesFolder].map(folder =>
163
+ fs.rm(CommonUtil.resolveWorkspace(this.#ctx, folder), { recursive: true, force: true })
164
+ )
165
+ );
158
166
  return { clean: true };
159
167
  }
160
168
 
@@ -175,10 +183,16 @@ export class CompilerServer {
175
183
  }
176
184
  return;
177
185
  }
178
- case 'clean': out = await this.#clean(); break;
179
- case 'stop': out = JSON.stringify({ closing: true }); close = true; break;
180
- case 'info':
181
- default: out = this.info ?? {}; break;
186
+ case 'clean':
187
+ out = await this.#clean();
188
+ break;
189
+ case 'stop':
190
+ out = JSON.stringify({ closing: true });
191
+ close = true;
192
+ break;
193
+ default:
194
+ out = this.info ?? {};
195
+ break;
182
196
  }
183
197
  response.end(JSON.stringify(out));
184
198
  if (close) {
@@ -199,7 +213,12 @@ export class CompilerServer {
199
213
 
200
214
  if (event.type === 'state') {
201
215
  this.info.state = event.payload.state;
202
- if (event.payload.state === 'init' && event.payload.extra && 'processId' in event.payload.extra && typeof event.payload.extra.processId === 'number') {
216
+ if (
217
+ event.payload.state === 'init' &&
218
+ event.payload.extra &&
219
+ 'processId' in event.payload.extra &&
220
+ typeof event.payload.extra.processId === 'number'
221
+ ) {
203
222
  if (this.info.watching && !this.info.compilerProcessId) {
204
223
  // Ensure we are killing in watch mode on first set
205
224
  await this.#handle.compiler.kill();
@@ -247,7 +266,8 @@ export class CompilerServer {
247
266
  this.#shutdown.abort();
248
267
  });
249
268
  });
250
- } catch { // Timeout or other error
269
+ } catch {
270
+ // Timeout or other error
251
271
  // Force shutdown
252
272
  this.#server.closeAllConnections();
253
273
  await this.#handle.compiler.kill();
@@ -260,7 +280,7 @@ export class CompilerServer {
260
280
  * Start the server listening
261
281
  */
262
282
  async listen(): Promise<CompilerServer | undefined> {
263
- const running = await this.#tryListen() === 'ok';
283
+ const running = (await this.#tryListen()) === 'ok';
264
284
  log.info(running ? 'Starting server' : 'Server already running under a different process', this.#url);
265
285
  return running ? this : undefined;
266
286
  }
package/src/state.ts CHANGED
@@ -1,25 +1,29 @@
1
1
  import fs from 'node:fs';
2
- import type { CompilerHost, SourceFile, CompilerOptions, Program, ScriptTarget } from 'typescript';
3
2
 
4
- import { path, ManifestModuleUtil, type ManifestModule, type ManifestRoot, type ManifestIndex, type ManifestModuleFolderType } from '@travetto/manifest';
3
+ import type { CompilerHost, CompilerOptions, Program, ScriptTarget, SourceFile } from 'typescript';
4
+
5
+ import {
6
+ type ManifestIndex,
7
+ type ManifestModule,
8
+ type ManifestModuleFolderType,
9
+ ManifestModuleUtil,
10
+ type ManifestRoot,
11
+ path
12
+ } from '@travetto/manifest';
5
13
  import type { TransformerManager } from '@travetto/transformer';
6
14
 
7
- import { CompilerUtil } from './util.ts';
8
- import type { CompileStateEntry } from './types.ts';
9
15
  import { CommonUtil } from './common.ts';
10
16
  import { tsProxy as ts, tsProxyInit } from './ts-proxy.ts';
17
+ import type { CompileStateEntry } from './types.ts';
18
+ import { CompilerUtil } from './util.ts';
11
19
 
12
20
  const TYPINGS_FOLDER_KEYS = new Set<ManifestModuleFolderType>(['$index', 'support', 'src', '$package']);
13
21
 
14
22
  export class CompilerState implements CompilerHost {
15
-
16
23
  static async get(idx: ManifestIndex): Promise<CompilerState> {
17
24
  return new CompilerState().init(idx);
18
25
  }
19
26
 
20
- /** @private */
21
- constructor() { }
22
-
23
27
  #outputPath: string;
24
28
  #typingsPath: string;
25
29
  #sourceFiles = new Set<string>();
@@ -44,7 +48,9 @@ export class CompilerState implements CompilerHost {
44
48
  try {
45
49
  return ts.sys.readFile(location, 'utf8');
46
50
  } catch {
47
- try { return fs.readFileSync(location, 'utf8'); } catch { }
51
+ try {
52
+ return fs.readFileSync(location, 'utf8');
53
+ } catch {}
48
54
  }
49
55
  return undefined;
50
56
  }
@@ -61,13 +67,17 @@ export class CompilerState implements CompilerHost {
61
67
  #fileExists(location: string): boolean {
62
68
  try {
63
69
  return ts.sys.fileExists(location);
64
- } catch { return fs.existsSync(location); }
70
+ } catch {
71
+ return fs.existsSync(location);
72
+ }
65
73
  }
66
74
 
67
75
  #directoryExists(location: string): boolean {
68
76
  try {
69
77
  return ts.sys.directoryExists(location);
70
- } catch { return fs.existsSync(location); }
78
+ } catch {
79
+ return fs.existsSync(location);
80
+ }
71
81
  }
72
82
 
73
83
  #writeExternalTypings(location: string, text: string, bom?: boolean): void {
@@ -120,14 +130,14 @@ export class CompilerState implements CompilerHost {
120
130
  for (const module of this.#modules) {
121
131
  const base = module?.files ?? {};
122
132
  const files = [
123
- ...base.bin ?? [],
124
- ...base.src ?? [],
125
- ...base.support ?? [],
126
- ...base.doc ?? [],
127
- ...base.test ?? [],
128
- ...base.$transformer ?? [],
129
- ...base.$index ?? [],
130
- ...base.$package ?? []
133
+ ...(base.bin ?? []),
134
+ ...(base.src ?? []),
135
+ ...(base.support ?? []),
136
+ ...(base.doc ?? []),
137
+ ...(base.test ?? []),
138
+ ...(base.$transformer ?? []),
139
+ ...(base.$index ?? []),
140
+ ...(base.$package ?? [])
131
141
  ];
132
142
  for (const [file, type] of files) {
133
143
  if (ManifestModuleUtil.isSourceType(type)) {
@@ -158,9 +168,7 @@ export class CompilerState implements CompilerHost {
158
168
  }
159
169
 
160
170
  getArbitraryInputFile(): string {
161
- const randomSource = this.#manifestIndex.getWorkspaceModules()
162
- .filter(module => module.files.src?.length)[0]
163
- .files.src[0].sourceFile;
171
+ const randomSource = this.#manifestIndex.getWorkspaceModules().filter(module => module.files.src?.length)[0].files.src[0].sourceFile;
164
172
 
165
173
  return this.getBySource(randomSource)!.sourceFile;
166
174
  }
@@ -168,7 +176,12 @@ export class CompilerState implements CompilerHost {
168
176
  async getProgram(force = false): Promise<Program> {
169
177
  if (force || !this.#program) {
170
178
  await this.initializeTypescript();
171
- this.#program = ts.createProgram({ rootNames: this.getAllFiles(), host: this, options: this.#compilerOptions, oldProgram: this.#program });
179
+ this.#program = ts.createProgram({
180
+ rootNames: this.getAllFiles(),
181
+ host: this,
182
+ options: this.#compilerOptions,
183
+ oldProgram: this.#program
184
+ });
172
185
  this.#transformerManager.init(this.#program.getTypeChecker());
173
186
  await CommonUtil.queueMacroTask();
174
187
  }
@@ -191,30 +204,34 @@ export class CompilerState implements CompilerHost {
191
204
  break;
192
205
  }
193
206
  case 'js':
194
- case 'typings': this.writeFile(output, this.readFile(sourceFile)!); break;
207
+ case 'typings':
208
+ this.writeFile(output, this.readFile(sourceFile)!);
209
+ break;
195
210
  case 'ts': {
196
211
  const program = await this.getProgram(needsNewProgram);
197
212
  const tsSourceFile = program.getSourceFile(sourceFile)!;
198
213
  program.emit(
199
214
  tsSourceFile,
200
- (...args) => this.writeFile(args[0], args[1], args[2]), undefined, false,
215
+ (...args) => this.writeFile(args[0], args[1], args[2]),
216
+ undefined,
217
+ false,
201
218
  this.#transformerManager.get()
202
219
  );
203
220
  return [
204
221
  ...program.getSemanticDiagnostics(tsSourceFile),
205
222
  ...program.getSyntacticDiagnostics(tsSourceFile),
206
- ...program.getDeclarationDiagnostics(tsSourceFile),
223
+ ...program.getDeclarationDiagnostics(tsSourceFile)
207
224
  ]
208
225
  .filter(d => d.category === ts.DiagnosticCategory.Error)
209
226
  .map(diag => {
210
227
  let message = ts.flattenDiagnosticMessageText(diag.messageText, '\n');
211
228
  if (
212
- message.includes("is not under 'rootDir'")
213
- || message.includes("does not exist on type 'EnvDataCombinedType'")
214
- || message.startsWith('Could not find a declaration file for module')
215
- || message.startsWith("Cannot find module '@travetto")
216
- || message.startsWith("This JSX tag requires the module path '@travetto")
217
- || message.startsWith("JSX element implicitly has type 'any'")
229
+ message.includes("is not under 'rootDir'") ||
230
+ message.includes("does not exist on type 'EnvDataCombinedType'") ||
231
+ message.startsWith('Could not find a declaration file for module') ||
232
+ message.startsWith("Cannot find module '@travetto") ||
233
+ message.startsWith("This JSX tag requires the module path '@travetto") ||
234
+ message.startsWith("JSX element implicitly has type 'any'")
218
235
  ) {
219
236
  return '';
220
237
  }
@@ -235,7 +252,11 @@ export class CompilerState implements CompilerHost {
235
252
 
236
253
  isCompilerFile(file: string): boolean {
237
254
  const entry = this.getBySource(file);
238
- return (entry?.moduleFile && ManifestModuleUtil.getFileRole(entry.moduleFile) === 'compile') || entry?.module.roles.includes('compile') || false;
255
+ return (
256
+ (entry?.moduleFile && ManifestModuleUtil.getFileRole(entry.moduleFile) === 'compile') ||
257
+ entry?.module.roles.includes('compile') ||
258
+ false
259
+ );
239
260
  }
240
261
 
241
262
  registerInput(module: ManifestModule, moduleFile: string): CompileStateEntry {
@@ -309,12 +330,24 @@ export class CompilerState implements CompilerHost {
309
330
  }
310
331
 
311
332
  /* Start Compiler Host */
312
- getCanonicalFileName(file: string): string { return file; }
313
- getCurrentDirectory(): string { return this.#manifest.workspace.path; }
314
- getDefaultLibFileName(options: CompilerOptions): string { return ts.getDefaultLibFileName(options); }
315
- getNewLine(): string { return ts.sys.newLine; }
316
- useCaseSensitiveFileNames(): boolean { return ts.sys.useCaseSensitiveFileNames; }
317
- getDefaultLibLocation(): string { return path.dirname(ts.getDefaultLibFilePath(this.#compilerOptions)); }
333
+ getCanonicalFileName(file: string): string {
334
+ return file;
335
+ }
336
+ getCurrentDirectory(): string {
337
+ return this.#manifest.workspace.path;
338
+ }
339
+ getDefaultLibFileName(options: CompilerOptions): string {
340
+ return ts.getDefaultLibFileName(options);
341
+ }
342
+ getNewLine(): string {
343
+ return ts.sys.newLine;
344
+ }
345
+ useCaseSensitiveFileNames(): boolean {
346
+ return ts.sys.useCaseSensitiveFileNames;
347
+ }
348
+ getDefaultLibLocation(): string {
349
+ return path.dirname(ts.getDefaultLibFilePath(this.#compilerOptions));
350
+ }
318
351
 
319
352
  fileExists(sourceFile: string): boolean {
320
353
  return this.#sourceToEntry.has(sourceFile) || this.#fileExists(sourceFile);
@@ -334,7 +367,7 @@ export class CompilerState implements CompilerHost {
334
367
  this.#writeExternalTypings(location, text, bom);
335
368
  }
336
369
 
337
- return this.#writeFile(location, text, bom);
370
+ this.#writeFile(location, text, bom);
338
371
  }
339
372
 
340
373
  readFile(sourceFile: string): string | undefined {
@@ -349,4 +382,4 @@ export class CompilerState implements CompilerHost {
349
382
  return ts.createSourceFile(sourceFile, content ?? '', language);
350
383
  });
351
384
  }
352
- }
385
+ }
package/src/ts-proxy.ts CHANGED
@@ -1,12 +1,14 @@
1
- /* eslint-disable @typescript-eslint/consistent-type-assertions */
2
1
  import type ts from 'typescript';
3
2
 
4
3
  let state: typeof ts | undefined;
5
4
  let promise: Promise<unknown> | undefined;
6
- export const tsProxyInit = (): Promise<unknown> => promise ??= import('typescript').then(module => { state = module.default; });
5
+ export const tsProxyInit = (): Promise<unknown> =>
6
+ (promise ??= import('typescript').then(module => {
7
+ state = module.default;
8
+ }));
7
9
 
8
10
  export const tsProxy = new Proxy({}!, {
9
11
  get(_, prop: string): unknown {
10
12
  return state![prop as keyof typeof ts];
11
13
  }
12
- }) as typeof ts;
14
+ }) as typeof ts;
package/src/types.ts CHANGED
@@ -3,23 +3,30 @@ import type { ChangeEventType, ManifestModule } from '@travetto/manifest';
3
3
  export type CompilerStateType = 'startup' | 'init' | 'compile-start' | 'compile-end' | 'watch-start' | 'watch-end' | 'reset' | 'closed';
4
4
  export type CompilerLogLevel = 'info' | 'debug' | 'warn' | 'error';
5
5
 
6
- export type CompileEmitEvent = { file: string, i: number, total: number, errors?: string[], duration: number };
7
- export type CompileStateEntry = { sourceFile: string, tscOutputFile: string, outputFile?: string, module: ManifestModule, import: string, moduleFile: string };
8
- export type CompilerWatchEvent = { action: ChangeEventType, file: string, entry: CompileStateEntry, moduleFile: string };
6
+ export type CompileEmitEvent = { file: string; i: number; total: number; errors?: string[]; duration: number };
7
+ export type CompileStateEntry = {
8
+ sourceFile: string;
9
+ tscOutputFile: string;
10
+ outputFile?: string;
11
+ module: ManifestModule;
12
+ import: string;
13
+ moduleFile: string;
14
+ };
15
+ export type CompilerWatchEvent = { action: ChangeEventType; file: string; entry: CompileStateEntry; moduleFile: string };
9
16
 
10
- export type CompilerChangeEvent = { file: string, action: ChangeEventType, output: string, module: string, import: string, time: number };
11
- export type CompilerLogEvent = { level: CompilerLogLevel, message: string, time?: number, args?: unknown[], scope?: string };
12
- export type CompilerProgressEvent = { idx: number, total: number, message: string, operation: 'compile', complete?: boolean };
13
- export type CompilerStateEvent = { state: CompilerStateType, extra?: Record<string, unknown> };
14
- export type FileChangeEvent = { files: { file: string, action: ChangeEventType }[], time: number };
17
+ export type CompilerChangeEvent = { file: string; action: ChangeEventType; output: string; module: string; import: string; time: number };
18
+ export type CompilerLogEvent = { level: CompilerLogLevel; message: string; time?: number; args?: unknown[]; scope?: string };
19
+ export type CompilerProgressEvent = { idx: number; total: number; message: string; operation: 'compile'; complete?: boolean };
20
+ export type CompilerStateEvent = { state: CompilerStateType; extra?: Record<string, unknown> };
21
+ export type FileChangeEvent = { files: { file: string; action: ChangeEventType }[]; time: number };
15
22
 
16
23
  export type CompilerEvent =
17
- { type: 'file', payload: FileChangeEvent } |
18
- { type: 'change', payload: CompilerChangeEvent } |
19
- { type: 'log', payload: CompilerLogEvent } |
20
- { type: 'progress', payload: CompilerProgressEvent } |
21
- { type: 'state', payload: CompilerStateEvent } |
22
- { type: 'all', payload: unknown };
24
+ | { type: 'file'; payload: FileChangeEvent }
25
+ | { type: 'change'; payload: CompilerChangeEvent }
26
+ | { type: 'log'; payload: CompilerLogEvent }
27
+ | { type: 'progress'; payload: CompilerProgressEvent }
28
+ | { type: 'state'; payload: CompilerStateEvent }
29
+ | { type: 'all'; payload: unknown };
23
30
 
24
31
  export type CompilerEventType = CompilerEvent['type'];
25
32
  export type CompilerEventPayload<V> = (CompilerEvent & { type: V })['payload'];
@@ -35,4 +42,4 @@ export type CompilerServerInfo = {
35
42
  env?: Record<string, string>;
36
43
  };
37
44
 
38
- export class CompilerReset extends Error { }
45
+ export class CompilerReset extends Error {}
package/src/util.ts CHANGED
@@ -4,7 +4,6 @@ import { ManifestModuleUtil, type ManifestRoot, type Package } from '@travetto/m
4
4
  * Standard utilities for compiler
5
5
  */
6
6
  export class CompilerUtil {
7
-
8
7
  /**
9
8
  * Rewrites the package.json to target output file names, and pins versions
10
9
  * @param manifest
@@ -40,10 +39,9 @@ export class CompilerUtil {
40
39
  let hash = 5381;
41
40
 
42
41
  for (let i = 0; i < text.length; i++) {
43
- // eslint-disable-next-line no-bitwise
44
42
  hash = (hash * 33) ^ text.charCodeAt(i);
45
43
  }
46
44
 
47
45
  return Math.abs(hash);
48
46
  }
49
- }
47
+ }