@jsenv/core 29.1.10 → 29.1.11
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/dist/main.js
CHANGED
|
@@ -1586,7 +1586,7 @@ const collectFiles = async ({
|
|
|
1586
1586
|
const relativeUrl = urlToRelativeUrl(directoryChildNodeUrl, rootDirectoryUrl);
|
|
1587
1587
|
matchingFileResultArray.push({
|
|
1588
1588
|
url: new URL(relativeUrl, rootDirectoryUrl).href,
|
|
1589
|
-
relativeUrl,
|
|
1589
|
+
relativeUrl: decodeURIComponent(relativeUrl),
|
|
1590
1590
|
meta,
|
|
1591
1591
|
fileStats: directoryChildNodeStats
|
|
1592
1592
|
});
|
|
@@ -9144,10 +9144,19 @@ const createFetchUrlContentError = ({
|
|
|
9144
9144
|
fetchError.code = code;
|
|
9145
9145
|
fetchError.reason = reason;
|
|
9146
9146
|
fetchError.url = urlInfo.url;
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9147
|
+
|
|
9148
|
+
if (code === "PARSE_ERROR") {
|
|
9149
|
+
fetchError.traceUrl = error.traceUrl;
|
|
9150
|
+
fetchError.traceLine = error.traceLine;
|
|
9151
|
+
fetchError.traceColumn = error.traceColumn;
|
|
9152
|
+
fetchError.traceMessage = error.traceMessage;
|
|
9153
|
+
} else {
|
|
9154
|
+
fetchError.traceUrl = reference.trace.url;
|
|
9155
|
+
fetchError.traceLine = reference.trace.line;
|
|
9156
|
+
fetchError.traceColumn = reference.trace.column;
|
|
9157
|
+
fetchError.traceMessage = reference.trace.message;
|
|
9158
|
+
}
|
|
9159
|
+
|
|
9151
9160
|
fetchError.asResponse = error.asResponse;
|
|
9152
9161
|
return fetchError;
|
|
9153
9162
|
};
|
|
@@ -9173,6 +9182,15 @@ const createFetchUrlContentError = ({
|
|
|
9173
9182
|
});
|
|
9174
9183
|
}
|
|
9175
9184
|
|
|
9185
|
+
if (error.code === "PARSE_ERROR") {
|
|
9186
|
+
return createFailedToFetchUrlContentError({
|
|
9187
|
+
"code": "PARSE_ERROR",
|
|
9188
|
+
"reason": error.reason,
|
|
9189
|
+
"parse error message": error.cause.message,
|
|
9190
|
+
"parse error trace": error.traceMessage
|
|
9191
|
+
});
|
|
9192
|
+
}
|
|
9193
|
+
|
|
9176
9194
|
return createFailedToFetchUrlContentError({
|
|
9177
9195
|
reason: `An error occured during "fetchUrlContent"`,
|
|
9178
9196
|
...detailsFromValueThrown(error)
|
|
@@ -9207,7 +9225,8 @@ const createTransformUrlContentError = ({
|
|
|
9207
9225
|
transformError.traceMessage = reference.trace.message;
|
|
9208
9226
|
|
|
9209
9227
|
if (code === "PARSE_ERROR") {
|
|
9210
|
-
transformError.reason =
|
|
9228
|
+
transformError.reason = `parse error on ${urlInfo.type}`;
|
|
9229
|
+
transformError.cause = error;
|
|
9211
9230
|
|
|
9212
9231
|
if (urlInfo.isInline) {
|
|
9213
9232
|
transformError.traceLine = reference.trace.line + error.line - 1;
|
|
@@ -16788,7 +16807,13 @@ const jsenvPluginAsJsClassicHtml = ({
|
|
|
16788
16807
|
break;
|
|
16789
16808
|
}
|
|
16790
16809
|
} catch (e) {
|
|
16791
|
-
if (context.scenarios.dev)
|
|
16810
|
+
if (context.scenarios.dev) {
|
|
16811
|
+
needsSystemJs = true; // ignore cooking error, the browser will trigger it again on fetch
|
|
16812
|
+
// + disable cache for this html file because when browser will reload
|
|
16813
|
+
// the error might be gone and we might need to inject systemjs
|
|
16814
|
+
|
|
16815
|
+
urlInfo.headers["cache-control"] = "no-store";
|
|
16816
|
+
} else {
|
|
16792
16817
|
throw e;
|
|
16793
16818
|
}
|
|
16794
16819
|
}
|
|
@@ -25763,17 +25788,32 @@ const createFileService = ({
|
|
|
25763
25788
|
const code = originalError.code;
|
|
25764
25789
|
|
|
25765
25790
|
if (code === "PARSE_ERROR") {
|
|
25791
|
+
// when possible let browser re-throw the syntax error
|
|
25792
|
+
// it's not possible to do that when url info content is not available
|
|
25793
|
+
// (happens for as_js_classic library for instance)
|
|
25794
|
+
if (urlInfo.content !== undefined) {
|
|
25795
|
+
return {
|
|
25796
|
+
url: reference.url,
|
|
25797
|
+
status: 200,
|
|
25798
|
+
// reason becomes the http response statusText, it must not contain invalid chars
|
|
25799
|
+
// https://github.com/nodejs/node/blob/0c27ca4bc9782d658afeaebcec85ec7b28f1cc35/lib/_http_common.js#L221
|
|
25800
|
+
statusText: e.reason,
|
|
25801
|
+
statusMessage: originalError.message,
|
|
25802
|
+
headers: {
|
|
25803
|
+
"content-type": urlInfo.contentType,
|
|
25804
|
+
"content-length": Buffer.byteLength(urlInfo.content),
|
|
25805
|
+
"cache-control": "no-store"
|
|
25806
|
+
},
|
|
25807
|
+
body: urlInfo.content
|
|
25808
|
+
};
|
|
25809
|
+
}
|
|
25810
|
+
|
|
25766
25811
|
return {
|
|
25767
25812
|
url: reference.url,
|
|
25768
|
-
status:
|
|
25769
|
-
// let the browser re-throw the syntax error
|
|
25770
|
-
// reason becomes the http response statusText, it must not contain invalid chars
|
|
25771
|
-
// https://github.com/nodejs/node/blob/0c27ca4bc9782d658afeaebcec85ec7b28f1cc35/lib/_http_common.js#L221
|
|
25813
|
+
status: 500,
|
|
25772
25814
|
statusText: e.reason,
|
|
25773
25815
|
statusMessage: originalError.message,
|
|
25774
25816
|
headers: {
|
|
25775
|
-
"content-type": urlInfo.contentType,
|
|
25776
|
-
"content-length": Buffer.byteLength(urlInfo.content),
|
|
25777
25817
|
"cache-control": "no-store"
|
|
25778
25818
|
},
|
|
25779
25819
|
body: urlInfo.content
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "29.1.
|
|
3
|
+
"version": "29.1.11",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@jsenv/abort": "4.2.4",
|
|
69
69
|
"@jsenv/ast": "1.3.2",
|
|
70
70
|
"@jsenv/babel-plugins": "1.0.7",
|
|
71
|
-
"@jsenv/filesystem": "4.1.
|
|
71
|
+
"@jsenv/filesystem": "4.1.5",
|
|
72
72
|
"@jsenv/importmap": "1.2.1",
|
|
73
73
|
"@jsenv/integrity": "0.0.1",
|
|
74
74
|
"@jsenv/log": "3.3.1",
|
package/src/dev/file_service.js
CHANGED
|
@@ -361,16 +361,31 @@ export const createFileService = ({
|
|
|
361
361
|
}
|
|
362
362
|
const code = originalError.code
|
|
363
363
|
if (code === "PARSE_ERROR") {
|
|
364
|
+
// when possible let browser re-throw the syntax error
|
|
365
|
+
// it's not possible to do that when url info content is not available
|
|
366
|
+
// (happens for as_js_classic library for instance)
|
|
367
|
+
if (urlInfo.content !== undefined) {
|
|
368
|
+
return {
|
|
369
|
+
url: reference.url,
|
|
370
|
+
status: 200,
|
|
371
|
+
// reason becomes the http response statusText, it must not contain invalid chars
|
|
372
|
+
// https://github.com/nodejs/node/blob/0c27ca4bc9782d658afeaebcec85ec7b28f1cc35/lib/_http_common.js#L221
|
|
373
|
+
statusText: e.reason,
|
|
374
|
+
statusMessage: originalError.message,
|
|
375
|
+
headers: {
|
|
376
|
+
"content-type": urlInfo.contentType,
|
|
377
|
+
"content-length": Buffer.byteLength(urlInfo.content),
|
|
378
|
+
"cache-control": "no-store",
|
|
379
|
+
},
|
|
380
|
+
body: urlInfo.content,
|
|
381
|
+
}
|
|
382
|
+
}
|
|
364
383
|
return {
|
|
365
384
|
url: reference.url,
|
|
366
|
-
status:
|
|
367
|
-
// reason becomes the http response statusText, it must not contain invalid chars
|
|
368
|
-
// https://github.com/nodejs/node/blob/0c27ca4bc9782d658afeaebcec85ec7b28f1cc35/lib/_http_common.js#L221
|
|
385
|
+
status: 500,
|
|
369
386
|
statusText: e.reason,
|
|
370
387
|
statusMessage: originalError.message,
|
|
371
388
|
headers: {
|
|
372
|
-
"content-type": urlInfo.contentType,
|
|
373
|
-
"content-length": Buffer.byteLength(urlInfo.content),
|
|
374
389
|
"cache-control": "no-store",
|
|
375
390
|
},
|
|
376
391
|
body: urlInfo.content,
|
package/src/kitchen/errors.js
CHANGED
|
@@ -61,10 +61,17 @@ export const createFetchUrlContentError = ({
|
|
|
61
61
|
fetchError.code = code
|
|
62
62
|
fetchError.reason = reason
|
|
63
63
|
fetchError.url = urlInfo.url
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
if (code === "PARSE_ERROR") {
|
|
65
|
+
fetchError.traceUrl = error.traceUrl
|
|
66
|
+
fetchError.traceLine = error.traceLine
|
|
67
|
+
fetchError.traceColumn = error.traceColumn
|
|
68
|
+
fetchError.traceMessage = error.traceMessage
|
|
69
|
+
} else {
|
|
70
|
+
fetchError.traceUrl = reference.trace.url
|
|
71
|
+
fetchError.traceLine = reference.trace.line
|
|
72
|
+
fetchError.traceColumn = reference.trace.column
|
|
73
|
+
fetchError.traceMessage = reference.trace.message
|
|
74
|
+
}
|
|
68
75
|
fetchError.asResponse = error.asResponse
|
|
69
76
|
return fetchError
|
|
70
77
|
}
|
|
@@ -87,6 +94,14 @@ export const createFetchUrlContentError = ({
|
|
|
87
94
|
reason: "no entry on filesystem",
|
|
88
95
|
})
|
|
89
96
|
}
|
|
97
|
+
if (error.code === "PARSE_ERROR") {
|
|
98
|
+
return createFailedToFetchUrlContentError({
|
|
99
|
+
"code": "PARSE_ERROR",
|
|
100
|
+
"reason": error.reason,
|
|
101
|
+
"parse error message": error.cause.message,
|
|
102
|
+
"parse error trace": error.traceMessage,
|
|
103
|
+
})
|
|
104
|
+
}
|
|
90
105
|
return createFailedToFetchUrlContentError({
|
|
91
106
|
reason: `An error occured during "fetchUrlContent"`,
|
|
92
107
|
...detailsFromValueThrown(error),
|
|
@@ -126,7 +141,8 @@ export const createTransformUrlContentError = ({
|
|
|
126
141
|
transformError.traceColumn = reference.trace.column
|
|
127
142
|
transformError.traceMessage = reference.trace.message
|
|
128
143
|
if (code === "PARSE_ERROR") {
|
|
129
|
-
transformError.reason =
|
|
144
|
+
transformError.reason = `parse error on ${urlInfo.type}`
|
|
145
|
+
transformError.cause = error
|
|
130
146
|
if (urlInfo.isInline) {
|
|
131
147
|
transformError.traceLine = reference.trace.line + error.line - 1
|
|
132
148
|
transformError.traceColumn = reference.trace.column + error.column
|
|
@@ -167,7 +167,11 @@ export const jsenvPluginAsJsClassicHtml = ({
|
|
|
167
167
|
}
|
|
168
168
|
} catch (e) {
|
|
169
169
|
if (context.scenarios.dev) {
|
|
170
|
+
needsSystemJs = true
|
|
170
171
|
// ignore cooking error, the browser will trigger it again on fetch
|
|
172
|
+
// + disable cache for this html file because when browser will reload
|
|
173
|
+
// the error might be gone and we might need to inject systemjs
|
|
174
|
+
urlInfo.headers["cache-control"] = "no-store"
|
|
171
175
|
} else {
|
|
172
176
|
throw e
|
|
173
177
|
}
|