@jsenv/core 40.12.11 → 40.12.13
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/build/build.js +5 -1
- package/dist/client/import_meta_css/import_meta_css_dev.js +1 -0
- package/dist/start_build_server/jsenv_core_packages.js +1 -71
- package/dist/start_build_server/start_build_server.js +6 -51
- package/dist/start_dev_server/start_dev_server.js +6 -2
- package/package.json +2 -2
- package/src/build/start_build_server.js +5 -51
- package/src/dev/start_dev_server.js +1 -1
- package/src/plugins/import_meta_css/client/import_meta_css_dev.js +1 -0
- package/src/plugins/import_meta_css/jsenv_plugin_import_meta_css.js +5 -1
package/dist/build/build.js
CHANGED
|
@@ -7916,7 +7916,11 @@ const jsenvPluginImportMetaCss = () => {
|
|
|
7916
7916
|
appliesDuring: "*",
|
|
7917
7917
|
transformUrlContent: {
|
|
7918
7918
|
js_module: async (urlInfo) => {
|
|
7919
|
-
if (
|
|
7919
|
+
if (
|
|
7920
|
+
!urlInfo.content.includes("import.meta.css") ||
|
|
7921
|
+
// there is already our installImportMetaCssBuild in the file
|
|
7922
|
+
urlInfo.content.includes("installImportMetaCssBuild")
|
|
7923
|
+
) {
|
|
7920
7924
|
return null;
|
|
7921
7925
|
}
|
|
7922
7926
|
const { metadata } = await applyBabelPlugins({
|
|
@@ -1394,76 +1394,6 @@ const createTaskLog = (
|
|
|
1394
1394
|
};
|
|
1395
1395
|
};
|
|
1396
1396
|
|
|
1397
|
-
const pathnameToExtension = (pathname) => {
|
|
1398
|
-
const slashLastIndex = pathname.lastIndexOf("/");
|
|
1399
|
-
const filename =
|
|
1400
|
-
slashLastIndex === -1 ? pathname : pathname.slice(slashLastIndex + 1);
|
|
1401
|
-
if (filename.match(/@([0-9])+(\.[0-9]+)?(\.[0-9]+)?$/)) {
|
|
1402
|
-
return "";
|
|
1403
|
-
}
|
|
1404
|
-
const dotLastIndex = filename.lastIndexOf(".");
|
|
1405
|
-
if (dotLastIndex === -1) {
|
|
1406
|
-
return "";
|
|
1407
|
-
}
|
|
1408
|
-
// if (dotLastIndex === pathname.length - 1) return ""
|
|
1409
|
-
const extension = filename.slice(dotLastIndex);
|
|
1410
|
-
return extension;
|
|
1411
|
-
};
|
|
1412
|
-
|
|
1413
|
-
const resourceToPathname = (resource) => {
|
|
1414
|
-
const searchSeparatorIndex = resource.indexOf("?");
|
|
1415
|
-
if (searchSeparatorIndex > -1) {
|
|
1416
|
-
return resource.slice(0, searchSeparatorIndex);
|
|
1417
|
-
}
|
|
1418
|
-
const hashIndex = resource.indexOf("#");
|
|
1419
|
-
if (hashIndex > -1) {
|
|
1420
|
-
return resource.slice(0, hashIndex);
|
|
1421
|
-
}
|
|
1422
|
-
return resource;
|
|
1423
|
-
};
|
|
1424
|
-
|
|
1425
|
-
const urlToScheme = (url) => {
|
|
1426
|
-
const urlString = String(url);
|
|
1427
|
-
const colonIndex = urlString.indexOf(":");
|
|
1428
|
-
if (colonIndex === -1) {
|
|
1429
|
-
return "";
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
const scheme = urlString.slice(0, colonIndex);
|
|
1433
|
-
return scheme;
|
|
1434
|
-
};
|
|
1435
|
-
|
|
1436
|
-
const urlToResource = (url) => {
|
|
1437
|
-
const scheme = urlToScheme(url);
|
|
1438
|
-
|
|
1439
|
-
if (scheme === "file") {
|
|
1440
|
-
const urlAsStringWithoutFileProtocol = String(url).slice("file://".length);
|
|
1441
|
-
return urlAsStringWithoutFileProtocol;
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
if (scheme === "https" || scheme === "http") {
|
|
1445
|
-
// remove origin
|
|
1446
|
-
const afterProtocol = String(url).slice(scheme.length + "://".length);
|
|
1447
|
-
const pathnameSlashIndex = afterProtocol.indexOf("/", "://".length);
|
|
1448
|
-
const urlAsStringWithoutOrigin = afterProtocol.slice(pathnameSlashIndex);
|
|
1449
|
-
return urlAsStringWithoutOrigin;
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
const urlAsStringWithoutProtocol = String(url).slice(scheme.length + 1);
|
|
1453
|
-
return urlAsStringWithoutProtocol;
|
|
1454
|
-
};
|
|
1455
|
-
|
|
1456
|
-
const urlToPathname = (url) => {
|
|
1457
|
-
const resource = urlToResource(url);
|
|
1458
|
-
const pathname = resourceToPathname(resource);
|
|
1459
|
-
return pathname;
|
|
1460
|
-
};
|
|
1461
|
-
|
|
1462
|
-
const urlToExtension = (url) => {
|
|
1463
|
-
const pathname = urlToPathname(url);
|
|
1464
|
-
return pathnameToExtension(pathname);
|
|
1465
|
-
};
|
|
1466
|
-
|
|
1467
1397
|
const transformUrlPathname = (url, transformer) => {
|
|
1468
1398
|
if (typeof url === "string") {
|
|
1469
1399
|
const urlObject = new URL(url);
|
|
@@ -1576,4 +1506,4 @@ const assertAndNormalizeDirectoryUrl = (
|
|
|
1576
1506
|
return value;
|
|
1577
1507
|
};
|
|
1578
1508
|
|
|
1579
|
-
export { Abort, assertAndNormalizeDirectoryUrl, createLogger, createTaskLog, raceProcessTeardownEvents
|
|
1509
|
+
export { Abort, assertAndNormalizeDirectoryUrl, createLogger, createTaskLog, raceProcessTeardownEvents };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { startServer, jsenvServiceCORS, jsenvAccessControlAllowedHeaders,
|
|
1
|
+
import { startServer, jsenvServiceCORS, jsenvAccessControlAllowedHeaders, jsenvServiceStaticFiles, jsenvServiceErrorHandler } from "@jsenv/server";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import { assertAndNormalizeDirectoryUrl, createLogger, Abort, raceProcessTeardownEvents, createTaskLog
|
|
3
|
+
import { assertAndNormalizeDirectoryUrl, createLogger, Abort, raceProcessTeardownEvents, createTaskLog } from "./jsenv_core_packages.js";
|
|
4
4
|
import "./jsenv_core_node_modules.js";
|
|
5
5
|
import "node:process";
|
|
6
6
|
import "node:os";
|
|
@@ -129,12 +129,12 @@ const startBuildServer = async ({
|
|
|
129
129
|
timingAllowOrigin: true,
|
|
130
130
|
}),
|
|
131
131
|
...services,
|
|
132
|
-
|
|
133
|
-
buildDirectoryUrl,
|
|
134
|
-
buildMainFilePath,
|
|
132
|
+
jsenvServiceStaticFiles({
|
|
133
|
+
directoryUrl: buildDirectoryUrl,
|
|
134
|
+
mainFilePath: buildMainFilePath,
|
|
135
135
|
}),
|
|
136
136
|
jsenvServiceErrorHandler({
|
|
137
|
-
sendErrorDetails:
|
|
137
|
+
sendErrorDetails: false,
|
|
138
138
|
}),
|
|
139
139
|
],
|
|
140
140
|
});
|
|
@@ -156,49 +156,4 @@ const startBuildServer = async ({
|
|
|
156
156
|
};
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
-
const jsenvBuildFileService = ({ buildDirectoryUrl, buildMainFilePath }) => {
|
|
160
|
-
return {
|
|
161
|
-
name: "jsenv:build_files",
|
|
162
|
-
routes: [
|
|
163
|
-
{
|
|
164
|
-
endpoint: "GET *",
|
|
165
|
-
description: "Serve static files.",
|
|
166
|
-
fetch: (request, helpers) => {
|
|
167
|
-
const urlIsVersioned = new URL(request.url).searchParams.has("v");
|
|
168
|
-
if (buildMainFilePath && request.resource === "/") {
|
|
169
|
-
request = {
|
|
170
|
-
...request,
|
|
171
|
-
resource: `/${buildMainFilePath}`,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
const urlObject = new URL(
|
|
175
|
-
request.resource.slice(1),
|
|
176
|
-
buildDirectoryUrl,
|
|
177
|
-
);
|
|
178
|
-
return createFileSystemFetch(buildDirectoryUrl, {
|
|
179
|
-
cacheControl: urlIsVersioned
|
|
180
|
-
? `private,max-age=${SECONDS_IN_30_DAYS},immutable`
|
|
181
|
-
: "private,max-age=0,must-revalidate",
|
|
182
|
-
etagEnabled: true,
|
|
183
|
-
compressionEnabled: true,
|
|
184
|
-
rootDirectoryUrl: buildDirectoryUrl,
|
|
185
|
-
canReadDirectory: true,
|
|
186
|
-
ENOENTFallback: () => {
|
|
187
|
-
if (
|
|
188
|
-
!urlToExtension(urlObject) &&
|
|
189
|
-
!urlToPathname(urlObject).endsWith("/")
|
|
190
|
-
) {
|
|
191
|
-
return new URL(buildMainFilePath, buildDirectoryUrl);
|
|
192
|
-
}
|
|
193
|
-
return null;
|
|
194
|
-
},
|
|
195
|
-
})(request, helpers);
|
|
196
|
-
},
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const SECONDS_IN_30_DAYS = 60 * 60 * 24 * 30;
|
|
203
|
-
|
|
204
159
|
export { startBuildServer };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebSocketResponse, pickContentType, ServerEvents, jsenvServiceCORS, jsenvAccessControlAllowedHeaders, composeTwoResponses, serveDirectory, jsenvServiceErrorHandler, startServer } from "@jsenv/server";
|
|
2
|
-
import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/
|
|
2
|
+
import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/services/filesystem/filesystem_error_to_response.js";
|
|
3
3
|
import { lookupPackageDirectory, registerDirectoryLifecycle, urlToRelativeUrl, moveUrl, urlIsOrIsInsideOf, ensureWindowsDriveLetter, createDetailedMessage, stringifyUrlSite, generateContentFrame, validateResponseIntegrity, setUrlFilename, getCallerPosition, urlToBasename, urlToExtension, asSpecifierWithoutSearch, asUrlWithoutSearch, injectQueryParamsIntoSpecifier, bufferToEtag, isFileSystemPath, urlToPathname, setUrlBasename, urlToFileSystemPath, writeFileSync, createLogger, URL_META, applyNodeEsmResolution, normalizeUrl, ANSI, RUNTIME_COMPAT, CONTENT_TYPE, readPackageAtOrNull, errorToHTML, DATA_URL, normalizeImportMap, composeTwoImportMaps, resolveImport, JS_QUOTES, readCustomConditionsFromProcessArgs, readEntryStatSync, ensurePathnameTrailingSlash, compareFileUrls, urlToFilename, applyFileSystemMagicResolution, getExtensionsToTry, setUrlExtension, isSpecifierForNodeBuiltin, injectQueryParams, memoizeByFirstArgument, assertAndNormalizeDirectoryUrl, createTaskLog, formatError } from "./jsenv_core_packages.js";
|
|
4
4
|
import { readFileSync, existsSync, readdirSync, lstatSync, realpathSync } from "node:fs";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
@@ -7957,7 +7957,11 @@ const jsenvPluginImportMetaCss = () => {
|
|
|
7957
7957
|
appliesDuring: "*",
|
|
7958
7958
|
transformUrlContent: {
|
|
7959
7959
|
js_module: async (urlInfo) => {
|
|
7960
|
-
if (
|
|
7960
|
+
if (
|
|
7961
|
+
!urlInfo.content.includes("import.meta.css") ||
|
|
7962
|
+
// there is already our installImportMetaCssBuild in the file
|
|
7963
|
+
urlInfo.content.includes("installImportMetaCssBuild")
|
|
7964
|
+
) {
|
|
7961
7965
|
return null;
|
|
7962
7966
|
}
|
|
7963
7967
|
const { metadata } = await applyBabelPlugins({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "40.12.
|
|
3
|
+
"version": "40.12.13",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@jsenv/plugin-minification": "1.7.3",
|
|
82
82
|
"@jsenv/plugin-supervisor": "1.7.15",
|
|
83
83
|
"@jsenv/plugin-transpilation": "1.5.70",
|
|
84
|
-
"@jsenv/server": "16.
|
|
84
|
+
"@jsenv/server": "16.4.0",
|
|
85
85
|
"@jsenv/sourcemap": "1.3.17",
|
|
86
86
|
"react-table": "7.8.0"
|
|
87
87
|
},
|
|
@@ -17,13 +17,12 @@ import { Abort, raceProcessTeardownEvents } from "@jsenv/abort";
|
|
|
17
17
|
import { assertAndNormalizeDirectoryUrl } from "@jsenv/filesystem";
|
|
18
18
|
import { createLogger, createTaskLog } from "@jsenv/humanize";
|
|
19
19
|
import {
|
|
20
|
-
createFileSystemFetch,
|
|
21
20
|
jsenvAccessControlAllowedHeaders,
|
|
22
21
|
jsenvServiceCORS,
|
|
23
22
|
jsenvServiceErrorHandler,
|
|
23
|
+
jsenvServiceStaticFiles,
|
|
24
24
|
startServer,
|
|
25
25
|
} from "@jsenv/server";
|
|
26
|
-
import { urlToExtension, urlToPathname } from "@jsenv/urls";
|
|
27
26
|
import { existsSync } from "node:fs";
|
|
28
27
|
|
|
29
28
|
/**
|
|
@@ -132,12 +131,12 @@ export const startBuildServer = async ({
|
|
|
132
131
|
timingAllowOrigin: true,
|
|
133
132
|
}),
|
|
134
133
|
...services,
|
|
135
|
-
|
|
136
|
-
buildDirectoryUrl,
|
|
137
|
-
buildMainFilePath,
|
|
134
|
+
jsenvServiceStaticFiles({
|
|
135
|
+
directoryUrl: buildDirectoryUrl,
|
|
136
|
+
mainFilePath: buildMainFilePath,
|
|
138
137
|
}),
|
|
139
138
|
jsenvServiceErrorHandler({
|
|
140
|
-
sendErrorDetails:
|
|
139
|
+
sendErrorDetails: false,
|
|
141
140
|
}),
|
|
142
141
|
],
|
|
143
142
|
});
|
|
@@ -158,48 +157,3 @@ export const startBuildServer = async ({
|
|
|
158
157
|
},
|
|
159
158
|
};
|
|
160
159
|
};
|
|
161
|
-
|
|
162
|
-
const jsenvBuildFileService = ({ buildDirectoryUrl, buildMainFilePath }) => {
|
|
163
|
-
return {
|
|
164
|
-
name: "jsenv:build_files",
|
|
165
|
-
routes: [
|
|
166
|
-
{
|
|
167
|
-
endpoint: "GET *",
|
|
168
|
-
description: "Serve static files.",
|
|
169
|
-
fetch: (request, helpers) => {
|
|
170
|
-
const urlIsVersioned = new URL(request.url).searchParams.has("v");
|
|
171
|
-
if (buildMainFilePath && request.resource === "/") {
|
|
172
|
-
request = {
|
|
173
|
-
...request,
|
|
174
|
-
resource: `/${buildMainFilePath}`,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
const urlObject = new URL(
|
|
178
|
-
request.resource.slice(1),
|
|
179
|
-
buildDirectoryUrl,
|
|
180
|
-
);
|
|
181
|
-
return createFileSystemFetch(buildDirectoryUrl, {
|
|
182
|
-
cacheControl: urlIsVersioned
|
|
183
|
-
? `private,max-age=${SECONDS_IN_30_DAYS},immutable`
|
|
184
|
-
: "private,max-age=0,must-revalidate",
|
|
185
|
-
etagEnabled: true,
|
|
186
|
-
compressionEnabled: true,
|
|
187
|
-
rootDirectoryUrl: buildDirectoryUrl,
|
|
188
|
-
canReadDirectory: true,
|
|
189
|
-
ENOENTFallback: () => {
|
|
190
|
-
if (
|
|
191
|
-
!urlToExtension(urlObject) &&
|
|
192
|
-
!urlToPathname(urlObject).endsWith("/")
|
|
193
|
-
) {
|
|
194
|
-
return new URL(buildMainFilePath, buildDirectoryUrl);
|
|
195
|
-
}
|
|
196
|
-
return null;
|
|
197
|
-
},
|
|
198
|
-
})(request, helpers);
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const SECONDS_IN_30_DAYS = 60 * 60 * 24 * 30;
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
serveDirectory,
|
|
13
13
|
startServer,
|
|
14
14
|
} from "@jsenv/server";
|
|
15
|
-
import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/
|
|
15
|
+
import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/services/filesystem/filesystem_error_to_response.js";
|
|
16
16
|
import { URL_META } from "@jsenv/url-meta";
|
|
17
17
|
import { urlIsOrIsInsideOf, urlToRelativeUrl } from "@jsenv/urls";
|
|
18
18
|
import { existsSync, readFileSync } from "node:fs";
|
|
@@ -36,7 +36,11 @@ export const jsenvPluginImportMetaCss = () => {
|
|
|
36
36
|
appliesDuring: "*",
|
|
37
37
|
transformUrlContent: {
|
|
38
38
|
js_module: async (urlInfo) => {
|
|
39
|
-
if (
|
|
39
|
+
if (
|
|
40
|
+
!urlInfo.content.includes("import.meta.css") ||
|
|
41
|
+
// there is already our installImportMetaCssBuild in the file
|
|
42
|
+
urlInfo.content.includes("installImportMetaCssBuild")
|
|
43
|
+
) {
|
|
40
44
|
return null;
|
|
41
45
|
}
|
|
42
46
|
const { metadata } = await applyBabelPlugins({
|