@sasjs/cli 6.32.0 → 6.32.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.
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
*/
|
|
38
38
|
importScripts('host/runtime-core.js')
|
|
39
39
|
importScripts('host/api-browser.js')
|
|
40
|
+
importScripts('host/lint-browser.js')
|
|
40
41
|
|
|
41
42
|
const R = self.SASjsMockRuntime
|
|
42
43
|
|
|
@@ -967,19 +968,18 @@ const LINT_CONFIG_FILE = '.sasjslint'
|
|
|
967
968
|
* The linter, bundled at build time from the installed @sasjs/api/code and
|
|
968
969
|
* @sasjs/lint (see mockSite.ts).
|
|
969
970
|
*
|
|
970
|
-
* Imported
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
*
|
|
975
|
-
*
|
|
971
|
+
* Imported with the rest of the host, not on the first code route: a service
|
|
972
|
+
* worker may only `importScripts` while its own script is being evaluated, so a
|
|
973
|
+
* call made from a request handler fails with "The script at ... failed to load"
|
|
974
|
+
* - the linter would be missing exactly where it is needed. What stays lazy is the
|
|
975
|
+
* service built from it: `createCodeService` is cheap, and only a code route
|
|
976
|
+
* calls it.
|
|
976
977
|
*/
|
|
977
978
|
let codeService
|
|
978
979
|
let linter
|
|
979
980
|
|
|
980
981
|
const code = () => {
|
|
981
982
|
if (codeService) return codeService
|
|
982
|
-
importScripts('host/lint-browser.js')
|
|
983
983
|
linter = self.SASjsCode
|
|
984
984
|
codeService = linter.createCodeService({ lintConfig })
|
|
985
985
|
return codeService
|
|
@@ -1442,25 +1442,27 @@ describe('service worker host', function () {
|
|
|
1442
1442
|
});
|
|
1443
1443
|
}); });
|
|
1444
1444
|
/**
|
|
1445
|
-
* The linter is
|
|
1445
|
+
* The linter is imported with the host, because it has to be.
|
|
1446
1446
|
*
|
|
1447
|
-
*
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
1450
|
-
*
|
|
1447
|
+
* A service worker may only `importScripts` while its own script is being
|
|
1448
|
+
* evaluated: a call made from a request handler fails with "The script at ...
|
|
1449
|
+
* failed to load", which is what a lazy import gave a real browser - the two
|
|
1450
|
+
* code routes answered 500. So the import is at boot, and the assertion is
|
|
1451
|
+
* that a code route answers *without* importing anything at request time.
|
|
1451
1452
|
*/
|
|
1452
|
-
it('
|
|
1453
|
-
var worker, response;
|
|
1453
|
+
it('imports the linter at boot and answers a code route without importing', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
1454
|
+
var worker, before, response;
|
|
1454
1455
|
return __generator(this, function (_a) {
|
|
1455
1456
|
switch (_a.label) {
|
|
1456
1457
|
case 0:
|
|
1457
1458
|
worker = seeded();
|
|
1458
|
-
expect(worker.imported.some(function (path) { return path.includes('lint-browser'); })).toBe(
|
|
1459
|
+
expect(worker.imported.some(function (path) { return path.includes('lint-browser'); })).toBe(true);
|
|
1460
|
+
before = worker.imported.length;
|
|
1459
1461
|
return [4 /*yield*/, worker.dispatch('/SASjsApi/code/lint', runRequest({ code: 'data a;\nrun;\n' }))];
|
|
1460
1462
|
case 1:
|
|
1461
1463
|
response = _a.sent();
|
|
1462
1464
|
expect(response.status).toBe(200);
|
|
1463
|
-
expect(worker.imported.
|
|
1465
|
+
expect(worker.imported.length).toBe(before);
|
|
1464
1466
|
return [2 /*return*/];
|
|
1465
1467
|
}
|
|
1466
1468
|
});
|