@travetto/compiler 3.4.0-rc.1 → 3.4.0-rc.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/compiler",
3
- "version": "3.4.0-rc.1",
3
+ "version": "3.4.0-rc.3",
4
4
  "description": "The compiler infrastructure for the Travetto framework",
5
5
  "keywords": [
6
6
  "compiler",
@@ -31,13 +31,13 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@parcel/watcher": "^2.3.0",
34
- "@travetto/manifest": "^3.4.0-rc.1",
34
+ "@travetto/manifest": "^3.4.0-rc.3",
35
35
  "@travetto/terminal": "^3.4.0-rc.0",
36
- "@travetto/transformer": "^3.4.0-rc.1",
36
+ "@travetto/transformer": "^3.4.0-rc.2",
37
37
  "@types/node": "^20.8.10"
38
38
  },
39
39
  "peerDependencies": {
40
- "@travetto/cli": "^3.4.0-rc.2"
40
+ "@travetto/cli": "^3.4.0-rc.4"
41
41
  },
42
42
  "peerDependenciesMeta": {
43
43
  "@travetto/cli": {
package/src/watch.ts CHANGED
@@ -139,6 +139,8 @@ export class CompilerWatcher {
139
139
  if (this.#sourceHashes.get(sourceFile) !== hash) {
140
140
  this.#state.resetInputSource(entry.input);
141
141
  this.#sourceHashes.set(sourceFile, hash);
142
+ } else {
143
+ entry = undefined;
142
144
  }
143
145
  }
144
146
  break;
@@ -16,6 +16,21 @@ const log = LogUtil.log.bind(LogUtil, 'compiler-server');
16
16
  */
17
17
  export class CompilerServer {
18
18
 
19
+ static readJSONRequest<T>(req: http.IncomingMessage): Promise<T> {
20
+ return new Promise<T>((res, rej) => {
21
+ const body: Buffer[] = [];
22
+ req.on('data', (chunk) => body.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk));
23
+ req.on('end', () => {
24
+ try {
25
+ res(JSON.parse(Buffer.concat(body).toString('utf8')))
26
+ } catch (err) {
27
+ rej(err);
28
+ }
29
+ });
30
+ req.on('error', rej);
31
+ });
32
+ }
33
+
19
34
  #ctx: ManifestContext;
20
35
  #server: http.Server;
21
36
  #listeners: { res: http.ServerResponse, type: CompilerServerEventType }[] = [];
@@ -126,11 +141,18 @@ export class CompilerServer {
126
141
 
127
142
  let out: unknown;
128
143
  switch (action) {
144
+ case 'send-event': await this.#emitEvent(await CompilerServer.readJSONRequest(req)); out = { received: true }; break;
129
145
  case 'event': return await this.#addListener(subAction, res);
130
146
  case 'stop': out = await this.close(); break;
131
147
  case 'clean': out = await this.#clean(); break;
132
148
  case 'info':
133
- default: out = this.info ?? {}; break;
149
+ default: {
150
+ out = this.info ?? {};
151
+ if (req.url?.includes('?env')) {
152
+ Object.assign(out!, { env: process.env });
153
+ }
154
+ break;
155
+ }
134
156
  }
135
157
  res.end(JSON.stringify(out));
136
158
  }
package/support/types.ts CHANGED
@@ -24,4 +24,5 @@ export type CompilerServerInfo = {
24
24
  mode: CompilerMode,
25
25
  iteration: number;
26
26
  url: string;
27
+ env?: Record<string, string>;
27
28
  };