@jsenv/core 27.2.1 → 27.3.1

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 CHANGED
@@ -23,7 +23,7 @@ npm create jsenv@latest
23
23
  npm install --save-dev @jsenv/core
24
24
  ```
25
25
 
26
- _@jsenv/core_ is tested on Mac, Windows, Linux on Node.js 16.14.0. Other operating systems and Node.js versions are not tested.
26
+ _@jsenv/core_ is tested on Mac, Windows, Linux on Node.js 18.5.0. Other operating systems and Node.js versions are not tested.
27
27
 
28
28
  # Documentation
29
29
 
package/dist/main.js CHANGED
@@ -9,6 +9,7 @@ import net, { createServer } from "node:net";
9
9
  import { Readable, Stream, Writable } from "node:stream";
10
10
  import { Http2ServerResponse } from "node:http2";
11
11
  import { createReadStream, readdirSync, statSync, readFile as readFile$1, chmod, stat, lstat, readdir, promises, unlink, openSync, closeSync, rmdir, readFileSync as readFileSync$1, watch, writeFile as writeFile$1, writeFileSync as writeFileSync$1, mkdirSync, existsSync, realpathSync } from "node:fs";
12
+ import { lookup } from "node:dns";
12
13
  import { performance } from "node:perf_hooks";
13
14
  import { extname, dirname, basename } from "node:path";
14
15
  import { pathToFileURL, fileURLToPath } from "node:url";
@@ -2653,15 +2654,16 @@ const statusIsClientError = status => status >= 400 && status < 500;
2653
2654
 
2654
2655
  const statusIsServerError = status => status >= 500 && status < 600;
2655
2656
 
2656
- const getServerOrigins = ({
2657
+ const getServerOrigins = async ({
2657
2658
  protocol,
2658
2659
  ip,
2659
2660
  port
2660
2661
  }) => {
2661
2662
  const isInternalIp = ip === "127.0.0.1";
2663
+ const localhostDnsResolution = await applyDnsResolution("localhost");
2662
2664
  const internalOrigin = createServerOrigin({
2663
2665
  protocol,
2664
- hostname: "localhost",
2666
+ hostname: localhostDnsResolution.address === "127.0.0.1" ? "localhost" : "127.0.0.1",
2665
2667
  port
2666
2668
  });
2667
2669
 
@@ -2682,6 +2684,22 @@ const getServerOrigins = ({
2682
2684
  };
2683
2685
  };
2684
2686
 
2687
+ const applyDnsResolution = async hostname => {
2688
+ const dnsResolution = await new Promise((resolve, reject) => {
2689
+ lookup(hostname, (error, address, family) => {
2690
+ if (error) {
2691
+ reject(error);
2692
+ } else {
2693
+ resolve({
2694
+ address,
2695
+ family
2696
+ });
2697
+ }
2698
+ });
2699
+ });
2700
+ return dnsResolution;
2701
+ };
2702
+
2685
2703
  const createServerOrigin = ({
2686
2704
  protocol,
2687
2705
  hostname,
@@ -3536,7 +3554,7 @@ const startServer = async ({
3536
3554
  };
3537
3555
 
3538
3556
  status = "opened";
3539
- const serverOrigins = getServerOrigins({
3557
+ const serverOrigins = await getServerOrigins({
3540
3558
  protocol,
3541
3559
  ip,
3542
3560
  port
@@ -26760,7 +26778,6 @@ nodeWorkerThread.run = async ({
26760
26778
  env: envForWorkerThread,
26761
26779
  execArgv: execArgvForWorkerThread,
26762
26780
  // workerData: { options },
26763
- // trackUnmanagedFds: true,
26764
26781
  stdin: true,
26765
26782
  stdout: true,
26766
26783
  stderr: true
@@ -26778,7 +26795,6 @@ nodeWorkerThread.run = async ({
26778
26795
  onceWorkerThreadMessage(workerThread, "ready", resolve);
26779
26796
  });
26780
26797
  const stop = memoize(async () => {
26781
- await workerThreadReadyPromise;
26782
26798
  await workerThread.terminate();
26783
26799
  });
26784
26800
  const winnerPromise = new Promise(resolve => {
@@ -26916,25 +26932,27 @@ nodeWorkerThread.run = async ({
26916
26932
  const installWorkerThreadOutputListener = (workerThread, callback) => {
26917
26933
  // beware that we may receive ansi output here, should not be a problem but keep that in mind
26918
26934
  const stdoutDataCallback = chunk => {
26935
+ const text = String(chunk);
26919
26936
  callback({
26920
26937
  type: "log",
26921
- text: String(chunk)
26938
+ text
26922
26939
  });
26923
26940
  };
26924
26941
 
26925
26942
  workerThread.stdout.on("data", stdoutDataCallback);
26926
26943
 
26927
26944
  const stdErrorDataCallback = chunk => {
26945
+ const text = String(chunk);
26928
26946
  callback({
26929
26947
  type: "error",
26930
- text: String(chunk)
26948
+ text
26931
26949
  });
26932
26950
  };
26933
26951
 
26934
26952
  workerThread.stderr.on("data", stdErrorDataCallback);
26935
26953
  return () => {
26936
26954
  workerThread.stdout.removeListener("data", stdoutDataCallback);
26937
- workerThread.stderr.removeListener("data", stdoutDataCallback);
26955
+ workerThread.stderr.removeListener("data", stdErrorDataCallback);
26938
26956
  };
26939
26957
  };
26940
26958
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "27.2.1",
3
+ "version": "27.3.1",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -13,7 +13,7 @@
13
13
  "url": "https://github.com/jsenv/jsenv-core"
14
14
  },
15
15
  "engines": {
16
- "node": ">=16.13.0"
16
+ "node": ">=18.5.0"
17
17
  },
18
18
  "publishConfig": {
19
19
  "access": "public",
@@ -66,14 +66,14 @@
66
66
  "@c88/v8-coverage": "0.1.1",
67
67
  "@financial-times/polyfill-useragent-normaliser": "2.0.1",
68
68
  "@jsenv/abort": "4.2.3",
69
- "@jsenv/ast": "1.1.1",
70
- "@jsenv/babel-plugins": "1.0.5",
69
+ "@jsenv/ast": "1.1.2",
70
+ "@jsenv/babel-plugins": "1.0.6",
71
71
  "@jsenv/filesystem": "4.1.0",
72
72
  "@jsenv/importmap": "1.2.1",
73
73
  "@jsenv/integrity": "0.0.1",
74
74
  "@jsenv/log": "3.1.0",
75
75
  "@jsenv/node-esm-resolution": "0.1.0",
76
- "@jsenv/server": "12.7.5",
76
+ "@jsenv/server": "12.8.0",
77
77
  "@jsenv/sourcemap": "1.0.1",
78
78
  "@jsenv/uneval": "1.6.0",
79
79
  "@jsenv/url-meta": "7.0.0",
@@ -87,7 +87,7 @@
87
87
  "istanbul-lib-report": "3.0.0",
88
88
  "istanbul-reports": "3.1.4",
89
89
  "pidtree": "0.6.0",
90
- "rollup": "2.75.7",
90
+ "rollup": "2.76.0",
91
91
  "string-width": "5.1.2",
92
92
  "strip-ansi": "7.0.1",
93
93
  "terser": "5.14.1",
@@ -108,7 +108,7 @@
108
108
  "eslint-plugin-html": "6.2.0",
109
109
  "eslint-plugin-import": "2.26.0",
110
110
  "eslint-plugin-react": "7.30.1",
111
- "playwright": "1.23.1",
111
+ "playwright": "1.23.2",
112
112
  "prettier": "2.7.1"
113
113
  }
114
114
  }
@@ -86,7 +86,6 @@ nodeWorkerThread.run = async ({
86
86
  env: envForWorkerThread,
87
87
  execArgv: execArgvForWorkerThread,
88
88
  // workerData: { options },
89
- // trackUnmanagedFds: true,
90
89
  stdin: true,
91
90
  stdout: true,
92
91
  stderr: true,
@@ -103,7 +102,6 @@ nodeWorkerThread.run = async ({
103
102
  })
104
103
 
105
104
  const stop = memoize(async () => {
106
- await workerThreadReadyPromise
107
105
  await workerThread.terminate()
108
106
  })
109
107
 
@@ -232,16 +230,18 @@ nodeWorkerThread.run = async ({
232
230
  const installWorkerThreadOutputListener = (workerThread, callback) => {
233
231
  // beware that we may receive ansi output here, should not be a problem but keep that in mind
234
232
  const stdoutDataCallback = (chunk) => {
235
- callback({ type: "log", text: String(chunk) })
233
+ const text = String(chunk)
234
+ callback({ type: "log", text })
236
235
  }
237
236
  workerThread.stdout.on("data", stdoutDataCallback)
238
237
  const stdErrorDataCallback = (chunk) => {
239
- callback({ type: "error", text: String(chunk) })
238
+ const text = String(chunk)
239
+ callback({ type: "error", text })
240
240
  }
241
241
  workerThread.stderr.on("data", stdErrorDataCallback)
242
242
  return () => {
243
243
  workerThread.stdout.removeListener("data", stdoutDataCallback)
244
- workerThread.stderr.removeListener("data", stdoutDataCallback)
244
+ workerThread.stderr.removeListener("data", stdErrorDataCallback)
245
245
  }
246
246
  }
247
247