@jsenv/core 27.0.0-alpha.70 → 27.0.0-alpha.73
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 +36 -49
- package/package.json +10 -10
- package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +2 -2
- package/src/execute/runtimes/node/kill_process_tree.js +2 -4
- package/src/main.js +27 -0
- package/src/omega/server/user_agent.js +2 -5
- package/src/plugins/bundling/js_module/bundle_js_module.js +2 -1
- package/src/plugins/inline/jsenv_plugin_data_urls.js +3 -3
- package/src/plugins/inline/jsenv_plugin_inline_query_param.js +2 -2
- package/src/plugins/minification/html/minify_html.js +2 -4
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +5 -7
- package/src/plugins/transpilation/babel/helpers/babel_plugin_structure.js +2 -1
- package/src/plugins/transpilation/babel/require_babel_plugin.js +8 -0
- package/src/plugins/transpilation/jsenv_plugin_top_level_await.js +1 -2
- package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +2 -1
- package/src/require_from_jsenv.js +3 -0
- package/src/test/execute_plan.js +2 -1
- package/src/test/execute_test_plan.js +2 -1
- package/main.js +0 -27
package/dist/main.js
CHANGED
|
@@ -2,8 +2,9 @@ import { parentPort } from "node:worker_threads";
|
|
|
2
2
|
import { registerFileLifecycle, readFileSync as readFileSync$1, bufferToEtag, writeFileSync, ensureWindowsDriveLetter, collectFiles, assertAndNormalizeDirectoryUrl, registerDirectoryLifecycle, writeFile, ensureEmptyDirectory, writeDirectory } from "@jsenv/filesystem";
|
|
3
3
|
import { createDetailedMessage, createLogger, loggerToLevels } from "@jsenv/logger";
|
|
4
4
|
import { createTaskLog, ANSI, msAsDuration, msAsEllapsedTime, byteAsMemoryUsage, UNICODE, createLog, startSpinner, distributePercentages, byteAsFileSize } from "@jsenv/log";
|
|
5
|
-
import { urlToRelativeUrl,
|
|
5
|
+
import { urlToRelativeUrl, generateInlineContentUrl, ensurePathnameTrailingSlash, urlIsInsideOf, urlToFilename, urlToExtension, DATA_URL, injectQueryParams, injectQueryParamsIntoSpecifier, fileSystemPathToUrl, urlToFileSystemPath, isFileSystemPath, normalizeUrl, stringifyUrlSite, setUrlFilename, moveUrl, getCallerPosition, resolveUrl, resolveDirectoryUrl, asUrlWithoutSearch, asUrlUntilPathname, urlToBasename } from "@jsenv/urls";
|
|
6
6
|
import { initReloadableProcess } from "@jsenv/utils/process_reload/process_reload.js";
|
|
7
|
+
import { URL_META } from "@jsenv/url-meta";
|
|
7
8
|
import { parseHtmlString, stringifyHtmlAst, visitHtmlAst, getHtmlNodeAttributeByName, htmlNodePosition, findNode, getHtmlNodeTextNode, removeHtmlNode, setHtmlNodeGeneratedText, removeHtmlNodeAttributeByName, parseScriptNode, injectScriptAsEarlyAsPossible, createHtmlNode, removeHtmlNodeText, assignHtmlNodeAttributes, parseLinkNode } from "@jsenv/utils/html_ast/html_ast.js";
|
|
8
9
|
import { htmlAttributeSrcSet } from "@jsenv/utils/html_ast/html_attribute_src_set.js";
|
|
9
10
|
import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js";
|
|
@@ -1787,7 +1788,7 @@ const jsenvPluginDataUrls = () => {
|
|
|
1787
1788
|
contentType,
|
|
1788
1789
|
base64Flag,
|
|
1789
1790
|
data: urlData
|
|
1790
|
-
} =
|
|
1791
|
+
} = DATA_URL.parse(urlInfo.url);
|
|
1791
1792
|
urlInfo.data.base64Flag = base64Flag;
|
|
1792
1793
|
return {
|
|
1793
1794
|
contentType,
|
|
@@ -1817,7 +1818,7 @@ const jsenvPluginDataUrls = () => {
|
|
|
1817
1818
|
return reference.generatedUrl;
|
|
1818
1819
|
}
|
|
1819
1820
|
|
|
1820
|
-
const specifier =
|
|
1821
|
+
const specifier = DATA_URL.stringify({
|
|
1821
1822
|
contentType: urlInfo.contentType,
|
|
1822
1823
|
base64Flag: urlInfo.data.base64Flag,
|
|
1823
1824
|
data: urlInfo.data.base64Flag ? dataToBase64(urlInfo.content) : String(urlInfo.content)
|
|
@@ -1883,7 +1884,7 @@ const jsenvPluginInlineQueryParam = () => {
|
|
|
1883
1884
|
await context.cook(urlInfo, {
|
|
1884
1885
|
reference
|
|
1885
1886
|
});
|
|
1886
|
-
const specifier =
|
|
1887
|
+
const specifier = DATA_URL.stringify({
|
|
1887
1888
|
mediaType: urlInfo.contentType,
|
|
1888
1889
|
base64Flag: true,
|
|
1889
1890
|
data: Buffer.from(urlInfo.content).toString("base64")
|
|
@@ -2724,30 +2725,11 @@ export default inlineContent.text`
|
|
|
2724
2725
|
return [asJsonModule, asCssModule, asTextModule];
|
|
2725
2726
|
};
|
|
2726
2727
|
|
|
2727
|
-
|
|
2728
|
-
// the list of possible helpers:
|
|
2729
|
-
// https://github.com/babel/babel/blob/99f4f6c3b03c7f3f67cf1b9f1a21b80cfd5b0224/packages/babel-helpers/src/helpers.js#L13
|
|
2730
|
-
const babelHelperClientDirectoryUrl = new URL("./babel_helpers/", import.meta.url).href; // we cannot use "@jsenv/core/src/*" because babel helper might be injected
|
|
2731
|
-
// into node_modules not depending on "@jsenv/core"
|
|
2732
|
-
|
|
2733
|
-
const getBabelHelperFileUrl = babelHelperName => {
|
|
2734
|
-
const babelHelperFileUrl = new URL(`./${babelHelperName}/${babelHelperName}.js`, babelHelperClientDirectoryUrl).href;
|
|
2735
|
-
return babelHelperFileUrl;
|
|
2736
|
-
};
|
|
2737
|
-
const babelHelperNameFromUrl = url => {
|
|
2738
|
-
if (!url.startsWith(babelHelperClientDirectoryUrl)) {
|
|
2739
|
-
return null;
|
|
2740
|
-
}
|
|
2741
|
-
|
|
2742
|
-
const afterBabelHelperDirectory = url.slice(babelHelperClientDirectoryUrl.length);
|
|
2743
|
-
const babelHelperName = afterBabelHelperDirectory.slice(0, afterBabelHelperDirectory.indexOf("/"));
|
|
2744
|
-
return babelHelperName;
|
|
2745
|
-
};
|
|
2746
|
-
|
|
2747
|
-
const require$4 = createRequire(import.meta.url); // eslint-disable-next-line import/no-dynamic-require
|
|
2728
|
+
const requireFromJsenv = createRequire(import.meta.url);
|
|
2748
2729
|
|
|
2749
|
-
|
|
2750
|
-
const
|
|
2730
|
+
const babelPluginPackagePath = requireFromJsenv.resolve("@jsenv/babel-plugins");
|
|
2731
|
+
const babelPluginPackageUrl = pathToFileURL(babelPluginPackagePath);
|
|
2732
|
+
const requireBabelPlugin = createRequire(babelPluginPackageUrl);
|
|
2751
2733
|
|
|
2752
2734
|
const babelPluginTransformImportMetaUrl = babel => {
|
|
2753
2735
|
return {
|
|
@@ -3129,9 +3111,6 @@ const jsenvPluginAsJsClassicWorkers = ({
|
|
|
3129
3111
|
* But ideally babel should not generate this in the first place
|
|
3130
3112
|
* and prefer to unique identifier based solely on the specifier basename for instance
|
|
3131
3113
|
*/
|
|
3132
|
-
|
|
3133
|
-
const require$3 = createRequire(import.meta.url);
|
|
3134
|
-
|
|
3135
3114
|
const jsenvPluginAsJsClassic = ({
|
|
3136
3115
|
systemJsInjection
|
|
3137
3116
|
}) => {
|
|
@@ -3271,11 +3250,11 @@ const convertJsModuleToJsClassic = async ({
|
|
|
3271
3250
|
} = await applyBabelPlugins({
|
|
3272
3251
|
babelPlugins: [...(jsClassicFormat === "system" ? [// propposal-dynamic-import required with systemjs for babel8:
|
|
3273
3252
|
// https://github.com/babel/babel/issues/10746
|
|
3274
|
-
|
|
3253
|
+
requireFromJsenv("@babel/plugin-proposal-dynamic-import"), [requireBabelPlugin("babel-plugin-transform-async-to-promises"), {
|
|
3275
3254
|
topLevelAwait: "return"
|
|
3276
|
-
}],
|
|
3255
|
+
}], requireFromJsenv("@babel/plugin-transform-modules-systemjs")] : [[requireBabelPlugin("babel-plugin-transform-async-to-promises"), {
|
|
3277
3256
|
topLevelAwait: "simple"
|
|
3278
|
-
}], babelPluginTransformImportMetaUrl,
|
|
3257
|
+
}], babelPluginTransformImportMetaUrl, requireFromJsenv("@babel/plugin-transform-modules-umd")])],
|
|
3279
3258
|
urlInfo
|
|
3280
3259
|
});
|
|
3281
3260
|
let sourcemap = urlInfo.sourcemap;
|
|
@@ -3499,6 +3478,26 @@ const getFeatureCompat = feature => {
|
|
|
3499
3478
|
return feature;
|
|
3500
3479
|
};
|
|
3501
3480
|
|
|
3481
|
+
// https://github.com/babel/babel/blob/99f4f6c3b03c7f3f67cf1b9f1a21b80cfd5b0224/packages/babel-core/src/tools/build-external-helpers.js
|
|
3482
|
+
// the list of possible helpers:
|
|
3483
|
+
// https://github.com/babel/babel/blob/99f4f6c3b03c7f3f67cf1b9f1a21b80cfd5b0224/packages/babel-helpers/src/helpers.js#L13
|
|
3484
|
+
const babelHelperClientDirectoryUrl = new URL("./babel_helpers/", import.meta.url).href; // we cannot use "@jsenv/core/src/*" because babel helper might be injected
|
|
3485
|
+
// into node_modules not depending on "@jsenv/core"
|
|
3486
|
+
|
|
3487
|
+
const getBabelHelperFileUrl = babelHelperName => {
|
|
3488
|
+
const babelHelperFileUrl = new URL(`./${babelHelperName}/${babelHelperName}.js`, babelHelperClientDirectoryUrl).href;
|
|
3489
|
+
return babelHelperFileUrl;
|
|
3490
|
+
};
|
|
3491
|
+
const babelHelperNameFromUrl = url => {
|
|
3492
|
+
if (!url.startsWith(babelHelperClientDirectoryUrl)) {
|
|
3493
|
+
return null;
|
|
3494
|
+
}
|
|
3495
|
+
|
|
3496
|
+
const afterBabelHelperDirectory = url.slice(babelHelperClientDirectoryUrl.length);
|
|
3497
|
+
const babelHelperName = afterBabelHelperDirectory.slice(0, afterBabelHelperDirectory.indexOf("/"));
|
|
3498
|
+
return babelHelperName;
|
|
3499
|
+
};
|
|
3500
|
+
|
|
3502
3501
|
/* eslint-disable camelcase */
|
|
3503
3502
|
// copied from
|
|
3504
3503
|
// https://github.com/babel/babel/blob/e498bee10f0123bb208baa228ce6417542a2c3c4/packages/babel-compat-data/data/plugins.json#L1
|
|
@@ -5130,9 +5129,6 @@ const jsenvPluginBundling = bundling => {
|
|
|
5130
5129
|
};
|
|
5131
5130
|
};
|
|
5132
5131
|
|
|
5133
|
-
const require$2 = createRequire(import.meta.url); // https://github.com/kangax/html-minifier#options-quick-reference
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
5132
|
const minifyHtml = ({
|
|
5137
5133
|
htmlUrlInfo,
|
|
5138
5134
|
options
|
|
@@ -5141,11 +5137,9 @@ const minifyHtml = ({
|
|
|
5141
5137
|
collapseWhitespace = true,
|
|
5142
5138
|
removeComments = true
|
|
5143
5139
|
} = options;
|
|
5144
|
-
|
|
5145
5140
|
const {
|
|
5146
5141
|
minify
|
|
5147
|
-
} =
|
|
5148
|
-
|
|
5142
|
+
} = requireFromJsenv("html-minifier");
|
|
5149
5143
|
const htmlMinified = minify(htmlUrlInfo.content, {
|
|
5150
5144
|
collapseWhitespace,
|
|
5151
5145
|
removeComments
|
|
@@ -7962,8 +7956,6 @@ const determineFileUrlForOutDirectory = ({
|
|
|
7962
7956
|
// }
|
|
7963
7957
|
// }
|
|
7964
7958
|
|
|
7965
|
-
const require$1 = createRequire(import.meta.url);
|
|
7966
|
-
|
|
7967
7959
|
const parseUserAgentHeader = memoizeByFirstArgument(userAgent => {
|
|
7968
7960
|
if (userAgent.includes("node-fetch/")) {
|
|
7969
7961
|
// it's not really node and conceptually we can't assume the node version
|
|
@@ -7974,8 +7966,7 @@ const parseUserAgentHeader = memoizeByFirstArgument(userAgent => {
|
|
|
7974
7966
|
};
|
|
7975
7967
|
}
|
|
7976
7968
|
|
|
7977
|
-
const UA =
|
|
7978
|
-
|
|
7969
|
+
const UA = requireFromJsenv("@financial-times/polyfill-useragent-normaliser");
|
|
7979
7970
|
const {
|
|
7980
7971
|
ua
|
|
7981
7972
|
} = new UA(userAgent);
|
|
@@ -8356,7 +8347,7 @@ const jsenvPluginExplorer = ({
|
|
|
8356
8347
|
meta
|
|
8357
8348
|
}));
|
|
8358
8349
|
let html = String(readFileSync(new URL(htmlClientFileUrl)));
|
|
8359
|
-
html = html.replace("virtual:FAVICON_HREF",
|
|
8350
|
+
html = html.replace("virtual:FAVICON_HREF", DATA_URL.stringify({
|
|
8360
8351
|
contentType: CONTENT_TYPE.fromUrlExtension(faviconClientFileUrl),
|
|
8361
8352
|
base64Flag: true,
|
|
8362
8353
|
data: readFileSync(new URL(faviconClientFileUrl)).toString("base64")
|
|
@@ -10690,15 +10681,11 @@ const getDebugInfo = processOptions => {
|
|
|
10690
10681
|
// return typeof process.env.VSCODE_PID === "string"
|
|
10691
10682
|
// }
|
|
10692
10683
|
|
|
10693
|
-
const require = createRequire(import.meta.url); // see also https://github.com/sindresorhus/execa/issues/96
|
|
10694
|
-
|
|
10695
|
-
|
|
10696
10684
|
const killProcessTree = async (processId, {
|
|
10697
10685
|
signal,
|
|
10698
10686
|
timeout = 2000
|
|
10699
10687
|
}) => {
|
|
10700
|
-
const pidtree =
|
|
10701
|
-
|
|
10688
|
+
const pidtree = requireFromJsenv("pidtree");
|
|
10702
10689
|
let descendantProcessIds;
|
|
10703
10690
|
|
|
10704
10691
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "27.0.0-alpha.
|
|
3
|
+
"version": "27.0.0-alpha.73",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -24,17 +24,16 @@
|
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
26
|
"import": {
|
|
27
|
-
"development": "./main.js",
|
|
27
|
+
"development": "./src/main.js",
|
|
28
28
|
"default": "./dist/main.js"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"./*": "./*"
|
|
32
32
|
},
|
|
33
|
-
"main": "main.js",
|
|
33
|
+
"main": "./src/main.js",
|
|
34
34
|
"files": [
|
|
35
35
|
"/dist/",
|
|
36
|
-
"/src/"
|
|
37
|
-
"/main.js"
|
|
36
|
+
"/src/"
|
|
38
37
|
],
|
|
39
38
|
"workspaces": [
|
|
40
39
|
"./packages/*",
|
|
@@ -68,8 +67,8 @@
|
|
|
68
67
|
"@c88/v8-coverage": "0.1.1",
|
|
69
68
|
"@financial-times/polyfill-useragent-normaliser": "2.0.1",
|
|
70
69
|
"@jsenv/abort": "4.1.2",
|
|
71
|
-
"@jsenv/babel-plugins": "1.0.
|
|
72
|
-
"@jsenv/filesystem": "4.0.
|
|
70
|
+
"@jsenv/babel-plugins": "1.0.3",
|
|
71
|
+
"@jsenv/filesystem": "4.0.3",
|
|
73
72
|
"@jsenv/importmap": "1.2.0",
|
|
74
73
|
"@jsenv/integrity": "0.0.1",
|
|
75
74
|
"@jsenv/log": "1.6.3",
|
|
@@ -77,8 +76,9 @@
|
|
|
77
76
|
"@jsenv/node-esm-resolution": "0.0.10",
|
|
78
77
|
"@jsenv/server": "12.6.3",
|
|
79
78
|
"@jsenv/uneval": "1.6.0",
|
|
80
|
-
"@jsenv/utils": "1.8.
|
|
81
|
-
"@jsenv/
|
|
79
|
+
"@jsenv/utils": "1.8.6",
|
|
80
|
+
"@jsenv/url-meta": "7.0.0",
|
|
81
|
+
"@jsenv/urls": "1.2.0",
|
|
82
82
|
"construct-style-sheets-polyfill": "3.1.0",
|
|
83
83
|
"cssnano": "5.1.7",
|
|
84
84
|
"cssnano-preset-default": "5.2.7",
|
|
@@ -118,4 +118,4 @@
|
|
|
118
118
|
"redux": "4.1.2",
|
|
119
119
|
"rollup": "2.70.1"
|
|
120
120
|
}
|
|
121
|
-
}
|
|
121
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs"
|
|
2
|
-
import {
|
|
2
|
+
import { DATA_URL } from "@jsenv/urls"
|
|
3
3
|
import { collectFiles } from "@jsenv/filesystem"
|
|
4
4
|
|
|
5
5
|
import { CONTENT_TYPE } from "@jsenv/utils/content_type/content_type.js"
|
|
@@ -38,7 +38,7 @@ export const jsenvPluginExplorer = ({ groups }) => {
|
|
|
38
38
|
let html = String(readFileSync(new URL(htmlClientFileUrl)))
|
|
39
39
|
html = html.replace(
|
|
40
40
|
"virtual:FAVICON_HREF",
|
|
41
|
-
|
|
41
|
+
DATA_URL.stringify({
|
|
42
42
|
contentType: CONTENT_TYPE.fromUrlExtension(faviconClientFileUrl),
|
|
43
43
|
base64Flag: true,
|
|
44
44
|
data: readFileSync(new URL(faviconClientFileUrl)).toString("base64"),
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const require = createRequire(import.meta.url)
|
|
1
|
+
import { requireFromJsenv } from "@jsenv/core/src/require_from_jsenv.js"
|
|
4
2
|
|
|
5
3
|
// see also https://github.com/sindresorhus/execa/issues/96
|
|
6
4
|
export const killProcessTree = async (
|
|
7
5
|
processId,
|
|
8
6
|
{ signal, timeout = 2000 },
|
|
9
7
|
) => {
|
|
10
|
-
const pidtree =
|
|
8
|
+
const pidtree = requireFromJsenv("pidtree")
|
|
11
9
|
|
|
12
10
|
let descendantProcessIds
|
|
13
11
|
try {
|
package/src/main.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// dev
|
|
2
|
+
export { startDevServer } from "./dev/start_dev_server.js"
|
|
3
|
+
// test
|
|
4
|
+
export {
|
|
5
|
+
executeTestPlan,
|
|
6
|
+
defaultCoverageConfig,
|
|
7
|
+
} from "./test/execute_test_plan.js"
|
|
8
|
+
export {
|
|
9
|
+
chromium,
|
|
10
|
+
chromiumIsolatedTab,
|
|
11
|
+
} from "./execute/runtimes/browsers/chromium.js"
|
|
12
|
+
export {
|
|
13
|
+
firefox,
|
|
14
|
+
firefoxIsolatedTab,
|
|
15
|
+
} from "./execute/runtimes/browsers/firefox.js"
|
|
16
|
+
export {
|
|
17
|
+
webkit,
|
|
18
|
+
webkitIsolatedTab,
|
|
19
|
+
} from "./execute/runtimes/browsers/webkit.js"
|
|
20
|
+
export { nodeProcess } from "./execute/runtimes/node/node_process.js"
|
|
21
|
+
// build
|
|
22
|
+
export { build } from "./build/build.js"
|
|
23
|
+
export { startBuildServer } from "./build/start_build_server.js"
|
|
24
|
+
|
|
25
|
+
// advanced
|
|
26
|
+
export { execute } from "./execute/execute.js"
|
|
27
|
+
export { injectGlobals } from "./plugins/inject_globals/jsenv_plugin_inject_globals.js"
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { createRequire } from "node:module"
|
|
2
|
-
|
|
3
1
|
import { memoizeByFirstArgument } from "@jsenv/utils/memoize/memoize_by_first_argument.js"
|
|
4
|
-
|
|
5
|
-
const require = createRequire(import.meta.url)
|
|
2
|
+
import { requireFromJsenv } from "@jsenv/core/src/require_from_jsenv.js"
|
|
6
3
|
|
|
7
4
|
export const parseUserAgentHeader = memoizeByFirstArgument((userAgent) => {
|
|
8
5
|
if (userAgent.includes("node-fetch/")) {
|
|
@@ -13,7 +10,7 @@ export const parseUserAgentHeader = memoizeByFirstArgument((userAgent) => {
|
|
|
13
10
|
runtimeVersion: process.version.slice(1),
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
const UA =
|
|
13
|
+
const UA = requireFromJsenv("@financial-times/polyfill-useragent-normaliser")
|
|
17
14
|
const { ua } = new UA(userAgent)
|
|
18
15
|
const { family, major, minor, patch } = ua
|
|
19
16
|
return {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pathToFileURL } from "node:url"
|
|
2
|
-
import {
|
|
2
|
+
import { URL_META } from "@jsenv/url-meta"
|
|
3
|
+
import { isFileSystemPath } from "@jsenv/urls"
|
|
3
4
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
4
5
|
|
|
5
6
|
import { babelHelperNameFromUrl } from "@jsenv/babel-plugins"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DATA_URL } from "@jsenv/urls"
|
|
2
2
|
import { CONTENT_TYPE } from "@jsenv/utils/content_type/content_type.js"
|
|
3
3
|
|
|
4
4
|
export const jsenvPluginDataUrls = () => {
|
|
@@ -19,7 +19,7 @@ export const jsenvPluginDataUrls = () => {
|
|
|
19
19
|
contentType,
|
|
20
20
|
base64Flag,
|
|
21
21
|
data: urlData,
|
|
22
|
-
} =
|
|
22
|
+
} = DATA_URL.parse(urlInfo.url)
|
|
23
23
|
urlInfo.data.base64Flag = base64Flag
|
|
24
24
|
return {
|
|
25
25
|
contentType,
|
|
@@ -39,7 +39,7 @@ export const jsenvPluginDataUrls = () => {
|
|
|
39
39
|
if (urlInfo.originalContent === urlInfo.content) {
|
|
40
40
|
return reference.generatedUrl
|
|
41
41
|
}
|
|
42
|
-
const specifier =
|
|
42
|
+
const specifier = DATA_URL.stringify({
|
|
43
43
|
contentType: urlInfo.contentType,
|
|
44
44
|
base64Flag: urlInfo.data.base64Flag,
|
|
45
45
|
data: urlInfo.data.base64Flag
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DATA_URL } from "@jsenv/urls"
|
|
2
2
|
|
|
3
3
|
export const jsenvPluginInlineQueryParam = () => {
|
|
4
4
|
return {
|
|
@@ -26,7 +26,7 @@ export const jsenvPluginInlineQueryParam = () => {
|
|
|
26
26
|
return (async () => {
|
|
27
27
|
const urlInfo = context.urlGraph.getUrlInfo(reference.url)
|
|
28
28
|
await context.cook(urlInfo, { reference })
|
|
29
|
-
const specifier =
|
|
29
|
+
const specifier = DATA_URL.stringify({
|
|
30
30
|
mediaType: urlInfo.contentType,
|
|
31
31
|
base64Flag: true,
|
|
32
32
|
data: Buffer.from(urlInfo.content).toString("base64"),
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const require = createRequire(import.meta.url)
|
|
1
|
+
import { requireFromJsenv } from "@jsenv/core/src/require_from_jsenv.js"
|
|
4
2
|
|
|
5
3
|
// https://github.com/kangax/html-minifier#options-quick-reference
|
|
6
4
|
export const minifyHtml = ({ htmlUrlInfo, options } = {}) => {
|
|
7
5
|
const { collapseWhitespace = true, removeComments = true } = options
|
|
8
6
|
|
|
9
|
-
const { minify } =
|
|
7
|
+
const { minify } = requireFromJsenv("html-minifier")
|
|
10
8
|
const htmlMinified = minify(htmlUrlInfo.content, {
|
|
11
9
|
collapseWhitespace,
|
|
12
10
|
removeComments,
|
|
@@ -11,21 +11,19 @@
|
|
|
11
11
|
* and prefer to unique identifier based solely on the specifier basename for instance
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { createRequire } from "node:module"
|
|
15
14
|
import { urlToFilename, injectQueryParams } from "@jsenv/urls"
|
|
16
15
|
import { readFileSync } from "@jsenv/filesystem"
|
|
17
16
|
|
|
18
|
-
import {
|
|
17
|
+
import { requireFromJsenv } from "@jsenv/core/src/require_from_jsenv.js"
|
|
19
18
|
import { applyBabelPlugins } from "@jsenv/utils/js_ast/apply_babel_plugins.js"
|
|
20
19
|
import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
|
|
21
20
|
import { composeTwoSourcemaps } from "@jsenv/utils/sourcemap/sourcemap_composition_v3.js"
|
|
22
21
|
|
|
22
|
+
import { requireBabelPlugin } from "../babel/require_babel_plugin.js"
|
|
23
23
|
import { babelPluginTransformImportMetaUrl } from "./helpers/babel_plugin_transform_import_meta_url.js"
|
|
24
24
|
import { jsenvPluginAsJsClassicHtml } from "./jsenv_plugin_as_js_classic_html.js"
|
|
25
25
|
import { jsenvPluginAsJsClassicWorkers } from "./jsenv_plugin_as_js_classic_workers.js"
|
|
26
26
|
|
|
27
|
-
const require = createRequire(import.meta.url)
|
|
28
|
-
|
|
29
27
|
export const jsenvPluginAsJsClassic = ({ systemJsInjection }) => {
|
|
30
28
|
const systemJsClientFileUrl = new URL(
|
|
31
29
|
"./client/s.js?js_classic",
|
|
@@ -171,14 +169,14 @@ const convertJsModuleToJsClassic = async ({
|
|
|
171
169
|
? [
|
|
172
170
|
// propposal-dynamic-import required with systemjs for babel8:
|
|
173
171
|
// https://github.com/babel/babel/issues/10746
|
|
174
|
-
|
|
172
|
+
requireFromJsenv("@babel/plugin-proposal-dynamic-import"),
|
|
175
173
|
[
|
|
176
174
|
requireBabelPlugin("babel-plugin-transform-async-to-promises"),
|
|
177
175
|
{
|
|
178
176
|
topLevelAwait: "return",
|
|
179
177
|
},
|
|
180
178
|
],
|
|
181
|
-
|
|
179
|
+
requireFromJsenv("@babel/plugin-transform-modules-systemjs"),
|
|
182
180
|
]
|
|
183
181
|
: [
|
|
184
182
|
[
|
|
@@ -188,7 +186,7 @@ const convertJsModuleToJsClassic = async ({
|
|
|
188
186
|
},
|
|
189
187
|
],
|
|
190
188
|
babelPluginTransformImportMetaUrl,
|
|
191
|
-
|
|
189
|
+
requireFromJsenv("@babel/plugin-transform-modules-umd"),
|
|
192
190
|
]),
|
|
193
191
|
],
|
|
194
192
|
urlInfo,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getBabelHelperFileUrl
|
|
1
|
+
import { getBabelHelperFileUrl } from "@jsenv/babel-plugins"
|
|
2
|
+
import { requireBabelPlugin } from "../require_babel_plugin.js"
|
|
2
3
|
import { babelPluginCompatMap } from "./babel_plugins_compatibility.js"
|
|
3
4
|
|
|
4
5
|
export const getBaseBabelPluginStructure = ({
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRequire } from "node:module"
|
|
2
|
+
import { pathToFileURL } from "node:url"
|
|
3
|
+
import { requireFromJsenv } from "@jsenv/core/src/require_from_jsenv.js"
|
|
4
|
+
|
|
5
|
+
const babelPluginPackagePath = requireFromJsenv.resolve("@jsenv/babel-plugins")
|
|
6
|
+
const babelPluginPackageUrl = pathToFileURL(babelPluginPackagePath)
|
|
7
|
+
|
|
8
|
+
export const requireBabelPlugin = createRequire(babelPluginPackageUrl)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { requireBabelPlugin } from "@jsenv/babel-plugins"
|
|
2
|
-
|
|
3
1
|
import { applyBabelPlugins } from "@jsenv/utils/js_ast/apply_babel_plugins.js"
|
|
2
|
+
import { requireBabelPlugin } from "./babel/require_babel_plugin.js"
|
|
4
3
|
|
|
5
4
|
export const jsenvPluginTopLevelAwait = () => {
|
|
6
5
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { URL_META } from "@jsenv/url-meta"
|
|
2
|
+
import { urlToRelativeUrl } from "@jsenv/urls"
|
|
2
3
|
|
|
3
4
|
import { parseAndTransformHtmlUrls } from "./html/html_urls.js"
|
|
4
5
|
import { parseAndTransformCssUrls } from "./css/css_urls.js"
|
package/src/test/execute_plan.js
CHANGED
|
@@ -3,7 +3,8 @@ import { memoryUsage } from "node:process"
|
|
|
3
3
|
import wrapAnsi from "wrap-ansi"
|
|
4
4
|
import stripAnsi from "strip-ansi"
|
|
5
5
|
import cuid from "cuid"
|
|
6
|
-
import { URL_META
|
|
6
|
+
import { URL_META } from "@jsenv/url-meta"
|
|
7
|
+
import { urlToFileSystemPath } from "@jsenv/urls"
|
|
7
8
|
import { createDetailedMessage, loggerToLevels } from "@jsenv/logger"
|
|
8
9
|
import { createLog, startSpinner } from "@jsenv/log"
|
|
9
10
|
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
package/main.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// dev
|
|
2
|
-
export { startDevServer } from "./src/dev/start_dev_server.js"
|
|
3
|
-
// test
|
|
4
|
-
export {
|
|
5
|
-
executeTestPlan,
|
|
6
|
-
defaultCoverageConfig,
|
|
7
|
-
} from "./src/test/execute_test_plan.js"
|
|
8
|
-
export {
|
|
9
|
-
chromium,
|
|
10
|
-
chromiumIsolatedTab,
|
|
11
|
-
} from "./src/execute/runtimes/browsers/chromium.js"
|
|
12
|
-
export {
|
|
13
|
-
firefox,
|
|
14
|
-
firefoxIsolatedTab,
|
|
15
|
-
} from "./src/execute/runtimes/browsers/firefox.js"
|
|
16
|
-
export {
|
|
17
|
-
webkit,
|
|
18
|
-
webkitIsolatedTab,
|
|
19
|
-
} from "./src/execute/runtimes/browsers/webkit.js"
|
|
20
|
-
export { nodeProcess } from "./src/execute/runtimes/node/node_process.js"
|
|
21
|
-
// build
|
|
22
|
-
export { build } from "./src/build/build.js"
|
|
23
|
-
export { startBuildServer } from "./src/build/start_build_server.js"
|
|
24
|
-
|
|
25
|
-
// advanced
|
|
26
|
-
export { execute } from "./src/execute/execute.js"
|
|
27
|
-
export { injectGlobals } from "./src/plugins/inject_globals/jsenv_plugin_inject_globals.js"
|