@jsenv/core 38.2.0 → 38.2.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 +3 -7
- package/dist/babel_helpers/dispose/dispose.js +45 -0
- package/dist/babel_helpers/regeneratorRuntime/regeneratorRuntime.js +2 -6
- package/dist/babel_helpers/using/using.js +23 -0
- package/dist/js/ws.js +60 -33
- package/dist/jsenv_core.js +20 -0
- package/package.json +15 -15
- package/src/plugins/reference_analysis/js/jsenv_plugin_js_reference_analysis.js +17 -0
package/README.md
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
# @jsenv/core [](https://www.npmjs.com/package/@jsenv/core)
|
|
2
2
|
|
|
3
|
-
Jsenv is a tool to develop test and build projects using JavaScript.
|
|
3
|
+
Jsenv is a tool to develop test and build projects using JavaScript.
|
|
4
|
+
Jsenv is simple, easy to understand and well documented.
|
|
4
5
|
|
|
5
|
-
[Documentation](<https://github.com/jsenv/core/wiki/A)-Introduction>)
|
|
6
|
-
|
|
7
|
-
See also
|
|
8
|
-
|
|
9
|
-
- [Documentation for contributors](./docs/contributors/README.md)
|
|
10
|
-
- [Documentation for maintainers](./docs/maintainers/README.md)
|
|
6
|
+
[Documentation](<https://github.com/jsenv/core/wiki/A)-Introduction>)
|
|
11
7
|
|
|
12
8
|
<!-- # Installation
|
|
13
9
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* @minVersion 7.22.0 */
|
|
2
|
+
function dispose_SuppressedError(suppressed, error) {
|
|
3
|
+
if (typeof SuppressedError !== "undefined") {
|
|
4
|
+
// eslint-disable-next-line no-undef
|
|
5
|
+
dispose_SuppressedError = SuppressedError;
|
|
6
|
+
} else {
|
|
7
|
+
dispose_SuppressedError = function SuppressedError(suppressed, error) {
|
|
8
|
+
this.suppressed = suppressed;
|
|
9
|
+
this.error = error;
|
|
10
|
+
this.stack = new Error().stack;
|
|
11
|
+
};
|
|
12
|
+
dispose_SuppressedError.prototype = Object.create(Error.prototype, {
|
|
13
|
+
constructor: {
|
|
14
|
+
value: dispose_SuppressedError,
|
|
15
|
+
writable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return new dispose_SuppressedError(suppressed, error);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default function _dispose(stack, error, hasError) {
|
|
24
|
+
function next() {
|
|
25
|
+
while (stack.length > 0) {
|
|
26
|
+
try {
|
|
27
|
+
var r = stack.pop();
|
|
28
|
+
var p = r.d.call(r.v);
|
|
29
|
+
if (r.a) return Promise.resolve(p).then(next, err);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
return err(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (hasError) throw error;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function err(e) {
|
|
38
|
+
error = hasError ? new dispose_SuppressedError(e, error) : e;
|
|
39
|
+
hasError = true;
|
|
40
|
+
|
|
41
|
+
return next();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return next();
|
|
45
|
+
}
|
|
@@ -483,7 +483,7 @@ export default function _regeneratorRuntime() {
|
|
|
483
483
|
};
|
|
484
484
|
};
|
|
485
485
|
function values(iterable) {
|
|
486
|
-
if (iterable) {
|
|
486
|
+
if (iterable || iterable === "") {
|
|
487
487
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
488
488
|
if (iteratorMethod) {
|
|
489
489
|
return iteratorMethod.call(iterable);
|
|
@@ -508,11 +508,7 @@ export default function _regeneratorRuntime() {
|
|
|
508
508
|
return (next.next = next);
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
|
|
512
|
-
// Return an iterator with no values.
|
|
513
|
-
return {
|
|
514
|
-
next: doneResult,
|
|
515
|
-
};
|
|
511
|
+
throw new TypeError(typeof iterable + " is not iterable");
|
|
516
512
|
}
|
|
517
513
|
exports.values = values;
|
|
518
514
|
function doneResult() {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* @minVersion 7.22.0 */
|
|
2
|
+
|
|
3
|
+
export default function _using(stack, value, isAwait) {
|
|
4
|
+
if (value === null || value === void 0) return value;
|
|
5
|
+
if (typeof value !== "object") {
|
|
6
|
+
throw new TypeError(
|
|
7
|
+
"using declarations can only be used with objects, null, or undefined."
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
// core-js-pure uses Symbol.for for polyfilling well-known symbols
|
|
11
|
+
if (isAwait) {
|
|
12
|
+
var dispose =
|
|
13
|
+
value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
|
|
14
|
+
}
|
|
15
|
+
if (dispose === null || dispose === void 0) {
|
|
16
|
+
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
|
|
17
|
+
}
|
|
18
|
+
if (typeof dispose !== "function") {
|
|
19
|
+
throw new TypeError(`Property [Symbol.dispose] is not a function.`);
|
|
20
|
+
}
|
|
21
|
+
stack.push({ v: value, d: dispose, a: isAwait });
|
|
22
|
+
return value;
|
|
23
|
+
}
|
package/dist/js/ws.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import require$$0 from "stream";
|
|
2
2
|
import require$$0$3 from "events";
|
|
3
3
|
import require$$2 from "http";
|
|
4
|
-
import require$$1 from "
|
|
5
|
-
import require$$3 from "net";
|
|
6
|
-
import require$$4 from "tls";
|
|
7
|
-
import require$$5 from "crypto";
|
|
4
|
+
import require$$1 from "crypto";
|
|
8
5
|
import require$$0$1 from "zlib";
|
|
9
6
|
import require$$0$2 from "buffer";
|
|
7
|
+
import require$$1$1 from "https";
|
|
8
|
+
import require$$3 from "net";
|
|
9
|
+
import require$$4 from "tls";
|
|
10
10
|
import require$$7 from "url";
|
|
11
11
|
|
|
12
12
|
function getDefaultExportFromCjs (x) {
|
|
@@ -876,12 +876,15 @@ const { concat, toArrayBuffer, unmask } = bufferUtilExports;
|
|
|
876
876
|
const { isValidStatusCode: isValidStatusCode$1, isValidUTF8 } = validationExports;
|
|
877
877
|
|
|
878
878
|
const FastBuffer = Buffer[Symbol.species];
|
|
879
|
+
const promise = Promise.resolve();
|
|
880
|
+
|
|
879
881
|
const GET_INFO = 0;
|
|
880
882
|
const GET_PAYLOAD_LENGTH_16 = 1;
|
|
881
883
|
const GET_PAYLOAD_LENGTH_64 = 2;
|
|
882
884
|
const GET_MASK = 3;
|
|
883
885
|
const GET_DATA = 4;
|
|
884
886
|
const INFLATING = 5;
|
|
887
|
+
const WAIT_MICROTASK = 6;
|
|
885
888
|
|
|
886
889
|
/**
|
|
887
890
|
* HyBi Receiver implementation.
|
|
@@ -1020,9 +1023,23 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1020
1023
|
case GET_DATA:
|
|
1021
1024
|
err = this.getData(cb);
|
|
1022
1025
|
break;
|
|
1026
|
+
case INFLATING:
|
|
1027
|
+
this._loop = false;
|
|
1028
|
+
return;
|
|
1023
1029
|
default:
|
|
1024
|
-
//
|
|
1030
|
+
//
|
|
1031
|
+
// `WAIT_MICROTASK`.
|
|
1032
|
+
//
|
|
1025
1033
|
this._loop = false;
|
|
1034
|
+
|
|
1035
|
+
//
|
|
1036
|
+
// `queueMicrotask()` is not available in Node.js < 11 and is no
|
|
1037
|
+
// better anyway.
|
|
1038
|
+
//
|
|
1039
|
+
promise.then(() => {
|
|
1040
|
+
this._state = GET_INFO;
|
|
1041
|
+
this.startLoop(cb);
|
|
1042
|
+
});
|
|
1026
1043
|
return;
|
|
1027
1044
|
}
|
|
1028
1045
|
} while (this._loop);
|
|
@@ -1405,7 +1422,7 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1405
1422
|
}
|
|
1406
1423
|
}
|
|
1407
1424
|
|
|
1408
|
-
this._state =
|
|
1425
|
+
this._state = WAIT_MICROTASK;
|
|
1409
1426
|
}
|
|
1410
1427
|
|
|
1411
1428
|
/**
|
|
@@ -1422,6 +1439,8 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1422
1439
|
if (data.length === 0) {
|
|
1423
1440
|
this.emit('conclude', 1005, EMPTY_BUFFER$2);
|
|
1424
1441
|
this.end();
|
|
1442
|
+
|
|
1443
|
+
this._state = GET_INFO;
|
|
1425
1444
|
} else {
|
|
1426
1445
|
const code = data.readUInt16BE(0);
|
|
1427
1446
|
|
|
@@ -1453,14 +1472,16 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1453
1472
|
|
|
1454
1473
|
this.emit('conclude', code, buf);
|
|
1455
1474
|
this.end();
|
|
1475
|
+
|
|
1476
|
+
this._state = GET_INFO;
|
|
1456
1477
|
}
|
|
1457
1478
|
} else if (this._opcode === 0x09) {
|
|
1458
1479
|
this.emit('ping', data);
|
|
1480
|
+
this._state = WAIT_MICROTASK;
|
|
1459
1481
|
} else {
|
|
1460
1482
|
this.emit('pong', data);
|
|
1483
|
+
this._state = WAIT_MICROTASK;
|
|
1461
1484
|
}
|
|
1462
|
-
|
|
1463
|
-
this._state = GET_INFO;
|
|
1464
1485
|
}
|
|
1465
1486
|
};
|
|
1466
1487
|
|
|
@@ -1489,8 +1510,8 @@ function error(ErrorCtor, message, prefix, statusCode, errorCode) {
|
|
|
1489
1510
|
return err;
|
|
1490
1511
|
}
|
|
1491
1512
|
|
|
1492
|
-
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^
|
|
1493
|
-
const { randomFillSync } = require$$
|
|
1513
|
+
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex" }] */
|
|
1514
|
+
const { randomFillSync } = require$$1;
|
|
1494
1515
|
|
|
1495
1516
|
const PerMessageDeflate$2 = permessageDeflate;
|
|
1496
1517
|
const { EMPTY_BUFFER: EMPTY_BUFFER$1 } = constants;
|
|
@@ -1507,7 +1528,7 @@ let Sender$1 = class Sender {
|
|
|
1507
1528
|
/**
|
|
1508
1529
|
* Creates a Sender instance.
|
|
1509
1530
|
*
|
|
1510
|
-
* @param {
|
|
1531
|
+
* @param {Duplex} socket The connection socket
|
|
1511
1532
|
* @param {Object} [extensions] An object containing the negotiated extensions
|
|
1512
1533
|
* @param {Function} [generateMask] The function used to generate the masking
|
|
1513
1534
|
* key
|
|
@@ -2456,14 +2477,14 @@ function format$1(extensions) {
|
|
|
2456
2477
|
|
|
2457
2478
|
var extension$1 = { format: format$1, parse: parse$2 };
|
|
2458
2479
|
|
|
2459
|
-
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */
|
|
2480
|
+
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex|Readable$" }] */
|
|
2460
2481
|
|
|
2461
2482
|
const EventEmitter$1 = require$$0$3;
|
|
2462
|
-
const https = require$$1;
|
|
2483
|
+
const https = require$$1$1;
|
|
2463
2484
|
const http$1 = require$$2;
|
|
2464
2485
|
const net = require$$3;
|
|
2465
2486
|
const tls = require$$4;
|
|
2466
|
-
const { randomBytes, createHash: createHash$1 } = require$$
|
|
2487
|
+
const { randomBytes, createHash: createHash$1 } = require$$1;
|
|
2467
2488
|
const { URL } = require$$7;
|
|
2468
2489
|
|
|
2469
2490
|
const PerMessageDeflate$1 = permessageDeflate;
|
|
@@ -2644,8 +2665,7 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
2644
2665
|
/**
|
|
2645
2666
|
* Set up the socket and the internal resources.
|
|
2646
2667
|
*
|
|
2647
|
-
* @param {
|
|
2648
|
-
* server and client
|
|
2668
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
2649
2669
|
* @param {Buffer} head The first packet of the upgraded stream
|
|
2650
2670
|
* @param {Object} options Options object
|
|
2651
2671
|
* @param {Function} [options.generateMask] The function used to generate the
|
|
@@ -2678,8 +2698,11 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
2678
2698
|
receiver.on('ping', receiverOnPing);
|
|
2679
2699
|
receiver.on('pong', receiverOnPong);
|
|
2680
2700
|
|
|
2681
|
-
|
|
2682
|
-
socket
|
|
2701
|
+
//
|
|
2702
|
+
// These methods may not be available if `socket` is just a `Duplex`.
|
|
2703
|
+
//
|
|
2704
|
+
if (socket.setTimeout) socket.setTimeout(0);
|
|
2705
|
+
if (socket.setNoDelay) socket.setNoDelay();
|
|
2683
2706
|
|
|
2684
2707
|
if (head.length > 0) socket.unshift(head);
|
|
2685
2708
|
|
|
@@ -3122,24 +3145,30 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
3122
3145
|
|
|
3123
3146
|
if (address instanceof URL) {
|
|
3124
3147
|
parsedUrl = address;
|
|
3125
|
-
websocket._url = address.href;
|
|
3126
3148
|
} else {
|
|
3127
3149
|
try {
|
|
3128
3150
|
parsedUrl = new URL(address);
|
|
3129
3151
|
} catch (e) {
|
|
3130
3152
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
3131
3153
|
}
|
|
3154
|
+
}
|
|
3132
3155
|
|
|
3133
|
-
|
|
3156
|
+
if (parsedUrl.protocol === 'http:') {
|
|
3157
|
+
parsedUrl.protocol = 'ws:';
|
|
3158
|
+
} else if (parsedUrl.protocol === 'https:') {
|
|
3159
|
+
parsedUrl.protocol = 'wss:';
|
|
3134
3160
|
}
|
|
3135
3161
|
|
|
3162
|
+
websocket._url = parsedUrl.href;
|
|
3163
|
+
|
|
3136
3164
|
const isSecure = parsedUrl.protocol === 'wss:';
|
|
3137
3165
|
const isIpcUrl = parsedUrl.protocol === 'ws+unix:';
|
|
3138
3166
|
let invalidUrlMessage;
|
|
3139
3167
|
|
|
3140
3168
|
if (parsedUrl.protocol !== 'ws:' && !isSecure && !isIpcUrl) {
|
|
3141
3169
|
invalidUrlMessage =
|
|
3142
|
-
'The URL\'s protocol must be one of "ws:", "wss:",
|
|
3170
|
+
'The URL\'s protocol must be one of "ws:", "wss:", ' +
|
|
3171
|
+
'"http:", "https", or "ws+unix:"';
|
|
3143
3172
|
} else if (isIpcUrl && !parsedUrl.pathname) {
|
|
3144
3173
|
invalidUrlMessage = "The URL's pathname is empty";
|
|
3145
3174
|
} else if (parsedUrl.hash) {
|
|
@@ -3673,7 +3702,7 @@ function resume(stream) {
|
|
|
3673
3702
|
}
|
|
3674
3703
|
|
|
3675
3704
|
/**
|
|
3676
|
-
* The listener of the
|
|
3705
|
+
* The listener of the socket `'close'` event.
|
|
3677
3706
|
*
|
|
3678
3707
|
* @private
|
|
3679
3708
|
*/
|
|
@@ -3724,7 +3753,7 @@ function socketOnClose() {
|
|
|
3724
3753
|
}
|
|
3725
3754
|
|
|
3726
3755
|
/**
|
|
3727
|
-
* The listener of the
|
|
3756
|
+
* The listener of the socket `'data'` event.
|
|
3728
3757
|
*
|
|
3729
3758
|
* @param {Buffer} chunk A chunk of data
|
|
3730
3759
|
* @private
|
|
@@ -3736,7 +3765,7 @@ function socketOnData(chunk) {
|
|
|
3736
3765
|
}
|
|
3737
3766
|
|
|
3738
3767
|
/**
|
|
3739
|
-
* The listener of the
|
|
3768
|
+
* The listener of the socket `'end'` event.
|
|
3740
3769
|
*
|
|
3741
3770
|
* @private
|
|
3742
3771
|
*/
|
|
@@ -3749,7 +3778,7 @@ function socketOnEnd() {
|
|
|
3749
3778
|
}
|
|
3750
3779
|
|
|
3751
3780
|
/**
|
|
3752
|
-
* The listener of the
|
|
3781
|
+
* The listener of the socket `'error'` event.
|
|
3753
3782
|
*
|
|
3754
3783
|
* @private
|
|
3755
3784
|
*/
|
|
@@ -3826,11 +3855,11 @@ function parse(header) {
|
|
|
3826
3855
|
|
|
3827
3856
|
var subprotocol$1 = { parse };
|
|
3828
3857
|
|
|
3829
|
-
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^
|
|
3858
|
+
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$" }] */
|
|
3830
3859
|
|
|
3831
3860
|
const EventEmitter = require$$0$3;
|
|
3832
3861
|
const http = require$$2;
|
|
3833
|
-
const { createHash } = require$$
|
|
3862
|
+
const { createHash } = require$$1;
|
|
3834
3863
|
|
|
3835
3864
|
const extension = extension$1;
|
|
3836
3865
|
const PerMessageDeflate = permessageDeflate;
|
|
@@ -4044,8 +4073,7 @@ class WebSocketServer extends EventEmitter {
|
|
|
4044
4073
|
* Handle a HTTP Upgrade request.
|
|
4045
4074
|
*
|
|
4046
4075
|
* @param {http.IncomingMessage} req The request object
|
|
4047
|
-
* @param {
|
|
4048
|
-
* server and client
|
|
4076
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
4049
4077
|
* @param {Buffer} head The first packet of the upgraded stream
|
|
4050
4078
|
* @param {Function} cb Callback
|
|
4051
4079
|
* @public
|
|
@@ -4169,8 +4197,7 @@ class WebSocketServer extends EventEmitter {
|
|
|
4169
4197
|
* @param {String} key The value of the `Sec-WebSocket-Key` header
|
|
4170
4198
|
* @param {Set} protocols The subprotocols
|
|
4171
4199
|
* @param {http.IncomingMessage} req The request object
|
|
4172
|
-
* @param {
|
|
4173
|
-
* server and client
|
|
4200
|
+
* @param {Duplex} socket The network socket between the server and client
|
|
4174
4201
|
* @param {Buffer} head The first packet of the upgraded stream
|
|
4175
4202
|
* @param {Function} cb Callback
|
|
4176
4203
|
* @throws {Error} If called more than once with the same socket
|
|
@@ -4300,7 +4327,7 @@ function socketOnError() {
|
|
|
4300
4327
|
/**
|
|
4301
4328
|
* Close the connection when preconditions are not fulfilled.
|
|
4302
4329
|
*
|
|
4303
|
-
* @param {
|
|
4330
|
+
* @param {Duplex} socket The socket of the upgrade request
|
|
4304
4331
|
* @param {Number} code The HTTP response status code
|
|
4305
4332
|
* @param {String} [message] The HTTP response body
|
|
4306
4333
|
* @param {Object} [headers] Additional HTTP response headers
|
|
@@ -4341,7 +4368,7 @@ function abortHandshake(socket, code, message, headers) {
|
|
|
4341
4368
|
*
|
|
4342
4369
|
* @param {WebSocketServer} server The WebSocket server
|
|
4343
4370
|
* @param {http.IncomingMessage} req The request object
|
|
4344
|
-
* @param {
|
|
4371
|
+
* @param {Duplex} socket The socket of the upgrade request
|
|
4345
4372
|
* @param {Number} code The HTTP response status code
|
|
4346
4373
|
* @param {String} message The HTTP response body
|
|
4347
4374
|
* @private
|
package/dist/jsenv_core.js
CHANGED
|
@@ -10579,9 +10579,13 @@ const jsenvPluginJsModuleFallbackOnWorkers = () => {
|
|
|
10579
10579
|
name: `jsenv:js_module_fallback_on_${subtype}`,
|
|
10580
10580
|
appliesDuring: "*",
|
|
10581
10581
|
init: (context) => {
|
|
10582
|
+
if (Object.keys(context.runtimeCompat).toString() === "node") {
|
|
10583
|
+
return false;
|
|
10584
|
+
}
|
|
10582
10585
|
if (context.isSupportedOnCurrentClients(`${subtype}_type_module`)) {
|
|
10583
10586
|
return false;
|
|
10584
10587
|
}
|
|
10588
|
+
|
|
10585
10589
|
return true;
|
|
10586
10590
|
},
|
|
10587
10591
|
redirectReference: {
|
|
@@ -15482,6 +15486,8 @@ const parseAndTransformJsReferences = async (
|
|
|
15482
15486
|
const magicSource = createMagicSource(urlInfo.content);
|
|
15483
15487
|
const parallelActions = [];
|
|
15484
15488
|
const sequentialActions = [];
|
|
15489
|
+
const isNodeJs =
|
|
15490
|
+
Object.keys(urlInfo.context.runtimeCompat).toString() === "node";
|
|
15485
15491
|
|
|
15486
15492
|
const onInlineReference = (inlineReferenceInfo) => {
|
|
15487
15493
|
const inlineUrl = getUrlForContentInsideJs(inlineReferenceInfo, {
|
|
@@ -15529,6 +15535,19 @@ const parseAndTransformJsReferences = async (
|
|
|
15529
15535
|
) {
|
|
15530
15536
|
urlInfo.data.usesImport = true;
|
|
15531
15537
|
}
|
|
15538
|
+
if (
|
|
15539
|
+
isNodeJs &&
|
|
15540
|
+
externalReferenceInfo.type === "js_url" &&
|
|
15541
|
+
externalReferenceInfo.expectedSubtype === "worker" &&
|
|
15542
|
+
externalReferenceInfo.expectedType === "js_classic" &&
|
|
15543
|
+
// TODO: it's true also if closest package.json
|
|
15544
|
+
// is type: module
|
|
15545
|
+
urlToExtension$1(
|
|
15546
|
+
new URL(externalReferenceInfo.specifier, urlInfo.url).href,
|
|
15547
|
+
) === ".mjs"
|
|
15548
|
+
) {
|
|
15549
|
+
externalReferenceInfo.expectedType = "js_module";
|
|
15550
|
+
}
|
|
15532
15551
|
const reference = urlInfo.dependencies.found({
|
|
15533
15552
|
type: externalReferenceInfo.type,
|
|
15534
15553
|
subtype: externalReferenceInfo.subtype,
|
|
@@ -15571,6 +15590,7 @@ const parseAndTransformJsReferences = async (
|
|
|
15571
15590
|
isJsModule: urlInfo.type === "js_module",
|
|
15572
15591
|
isWebWorker: isWebWorkerUrlInfo(urlInfo),
|
|
15573
15592
|
inlineContent,
|
|
15593
|
+
isNodeJs,
|
|
15574
15594
|
});
|
|
15575
15595
|
for (const jsReferenceInfo of jsReferenceInfos) {
|
|
15576
15596
|
if (jsReferenceInfo.isInline) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "38.2.
|
|
3
|
+
"version": "38.2.1",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -61,26 +61,26 @@
|
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
63
63
|
"@jsenv/abort": "4.2.4",
|
|
64
|
-
"@jsenv/ast": "5.1.
|
|
64
|
+
"@jsenv/ast": "5.1.3",
|
|
65
65
|
"@jsenv/filesystem": "4.2.6",
|
|
66
66
|
"@jsenv/importmap": "1.2.1",
|
|
67
67
|
"@jsenv/integrity": "0.0.1",
|
|
68
68
|
"@jsenv/log": "3.4.0",
|
|
69
69
|
"@jsenv/node-esm-resolution": "1.0.1",
|
|
70
|
-
"@jsenv/js-module-fallback": "1.3.
|
|
70
|
+
"@jsenv/js-module-fallback": "1.3.4",
|
|
71
71
|
"@jsenv/runtime-compat": "1.2.0",
|
|
72
|
-
"@jsenv/server": "15.1.
|
|
73
|
-
"@jsenv/sourcemap": "1.2.
|
|
74
|
-
"@jsenv/plugin-bundling": "2.5.
|
|
75
|
-
"@jsenv/plugin-minification": "1.5.
|
|
76
|
-
"@jsenv/plugin-transpilation": "1.3.
|
|
77
|
-
"@jsenv/plugin-supervisor": "1.3.
|
|
72
|
+
"@jsenv/server": "15.1.1",
|
|
73
|
+
"@jsenv/sourcemap": "1.2.2",
|
|
74
|
+
"@jsenv/plugin-bundling": "2.5.3",
|
|
75
|
+
"@jsenv/plugin-minification": "1.5.1",
|
|
76
|
+
"@jsenv/plugin-transpilation": "1.3.3",
|
|
77
|
+
"@jsenv/plugin-supervisor": "1.3.3",
|
|
78
78
|
"@jsenv/url-meta": "8.1.0",
|
|
79
79
|
"@jsenv/urls": "2.2.1",
|
|
80
80
|
"@jsenv/utils": "2.0.1"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@babel/eslint-parser": "7.22.
|
|
83
|
+
"@babel/eslint-parser": "7.22.15",
|
|
84
84
|
"@babel/plugin-syntax-import-assertions": "7.22.5",
|
|
85
85
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
86
86
|
"@jsenv/assert": "./packages/independent/assert/",
|
|
@@ -92,12 +92,12 @@
|
|
|
92
92
|
"@jsenv/performance-impact": "4.1.1",
|
|
93
93
|
"@jsenv/plugin-as-js-classic": "./packages/related/plugin-as-js-classic/",
|
|
94
94
|
"@jsenv/test": "./packages/related/test/",
|
|
95
|
-
"eslint": "8.
|
|
95
|
+
"eslint": "8.49.0",
|
|
96
96
|
"eslint-plugin-html": "7.1.0",
|
|
97
|
-
"eslint-plugin-import": "2.28.
|
|
98
|
-
"eslint-plugin-react": "7.33.
|
|
97
|
+
"eslint-plugin-import": "2.28.1",
|
|
98
|
+
"eslint-plugin-react": "7.33.2",
|
|
99
99
|
"open": "9.1.0",
|
|
100
|
-
"playwright": "1.
|
|
101
|
-
"prettier": "3.0.
|
|
100
|
+
"playwright": "1.37.1",
|
|
101
|
+
"prettier": "3.0.3"
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createMagicSource } from "@jsenv/sourcemap";
|
|
2
2
|
import { parseJsUrls, getUrlForContentInsideJs } from "@jsenv/ast";
|
|
3
|
+
import { urlToExtension } from "@jsenv/urls";
|
|
3
4
|
import { JS_QUOTES } from "@jsenv/utils/src/string/js_quotes.js";
|
|
4
5
|
|
|
5
6
|
import { isWebWorkerUrlInfo } from "@jsenv/core/src/kitchen/web_workers.js";
|
|
@@ -34,6 +35,8 @@ const parseAndTransformJsReferences = async (
|
|
|
34
35
|
const magicSource = createMagicSource(urlInfo.content);
|
|
35
36
|
const parallelActions = [];
|
|
36
37
|
const sequentialActions = [];
|
|
38
|
+
const isNodeJs =
|
|
39
|
+
Object.keys(urlInfo.context.runtimeCompat).toString() === "node";
|
|
37
40
|
|
|
38
41
|
const onInlineReference = (inlineReferenceInfo) => {
|
|
39
42
|
const inlineUrl = getUrlForContentInsideJs(inlineReferenceInfo, {
|
|
@@ -81,6 +84,19 @@ const parseAndTransformJsReferences = async (
|
|
|
81
84
|
) {
|
|
82
85
|
urlInfo.data.usesImport = true;
|
|
83
86
|
}
|
|
87
|
+
if (
|
|
88
|
+
isNodeJs &&
|
|
89
|
+
externalReferenceInfo.type === "js_url" &&
|
|
90
|
+
externalReferenceInfo.expectedSubtype === "worker" &&
|
|
91
|
+
externalReferenceInfo.expectedType === "js_classic" &&
|
|
92
|
+
// TODO: it's true also if closest package.json
|
|
93
|
+
// is type: module
|
|
94
|
+
urlToExtension(
|
|
95
|
+
new URL(externalReferenceInfo.specifier, urlInfo.url).href,
|
|
96
|
+
) === ".mjs"
|
|
97
|
+
) {
|
|
98
|
+
externalReferenceInfo.expectedType = "js_module";
|
|
99
|
+
}
|
|
84
100
|
const reference = urlInfo.dependencies.found({
|
|
85
101
|
type: externalReferenceInfo.type,
|
|
86
102
|
subtype: externalReferenceInfo.subtype,
|
|
@@ -123,6 +139,7 @@ const parseAndTransformJsReferences = async (
|
|
|
123
139
|
isJsModule: urlInfo.type === "js_module",
|
|
124
140
|
isWebWorker: isWebWorkerUrlInfo(urlInfo),
|
|
125
141
|
inlineContent,
|
|
142
|
+
isNodeJs,
|
|
126
143
|
});
|
|
127
144
|
for (const jsReferenceInfo of jsReferenceInfos) {
|
|
128
145
|
if (jsReferenceInfo.isInline) {
|