@jsenv/core 31.1.0 → 31.1.2
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 +26 -5
- package/package.json +1 -2
- package/src/build/build.js +2 -0
- package/src/plugins/plugins.js +2 -1
package/dist/main.js
CHANGED
|
@@ -20,7 +20,6 @@ import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes
|
|
|
20
20
|
import { createRequire } from "node:module";
|
|
21
21
|
import babelParser from "@babel/parser";
|
|
22
22
|
import { bundleJsModules } from "@jsenv/plugin-bundling";
|
|
23
|
-
import { replacePlaceholders } from "@jsenv/plugin-placeholders";
|
|
24
23
|
import v8, { takeCoverage } from "node:v8";
|
|
25
24
|
import wrapAnsi from "wrap-ansi";
|
|
26
25
|
import stripAnsi from "strip-ansi";
|
|
@@ -17978,6 +17977,25 @@ const babelPluginMetadataImportMetaScenarios = () => {
|
|
|
17978
17977
|
};
|
|
17979
17978
|
};
|
|
17980
17979
|
|
|
17980
|
+
const replacePlaceholders = (urlInfo, replacements) => {
|
|
17981
|
+
const content = urlInfo.content;
|
|
17982
|
+
const magicSource = createMagicSource(content);
|
|
17983
|
+
Object.keys(replacements).forEach(key => {
|
|
17984
|
+
let index = content.indexOf(key);
|
|
17985
|
+
while (index !== -1) {
|
|
17986
|
+
const start = index;
|
|
17987
|
+
const end = index + key.length;
|
|
17988
|
+
magicSource.replace({
|
|
17989
|
+
start,
|
|
17990
|
+
end,
|
|
17991
|
+
replacement: urlInfo.type === "js_classic" || urlInfo.type === "js_module" || urlInfo.type === "html" ? JSON.stringify(replacements[key], null, " ") : replacements[key]
|
|
17992
|
+
});
|
|
17993
|
+
index = content.indexOf(key, end);
|
|
17994
|
+
}
|
|
17995
|
+
});
|
|
17996
|
+
return magicSource.toContentAndSourcemap();
|
|
17997
|
+
};
|
|
17998
|
+
|
|
17981
17999
|
/*
|
|
17982
18000
|
* Source code can contain the following
|
|
17983
18001
|
* - __dev__
|
|
@@ -17987,8 +18005,8 @@ const babelPluginMetadataImportMetaScenarios = () => {
|
|
|
17987
18005
|
const jsenvPluginGlobalScenarios = () => {
|
|
17988
18006
|
const transformIfNeeded = (urlInfo, context) => {
|
|
17989
18007
|
return replacePlaceholders(urlInfo, {
|
|
17990
|
-
|
|
17991
|
-
|
|
18008
|
+
__DEV__: context.dev,
|
|
18009
|
+
__BUILD__: context.build
|
|
17992
18010
|
});
|
|
17993
18011
|
};
|
|
17994
18012
|
return {
|
|
@@ -20292,6 +20310,7 @@ const getCorePlugins = ({
|
|
|
20292
20310
|
clientFilesPruneCallbackList,
|
|
20293
20311
|
explorer,
|
|
20294
20312
|
cacheControl,
|
|
20313
|
+
scenarioPlaceholders = true,
|
|
20295
20314
|
ribbon = true
|
|
20296
20315
|
} = {}) => {
|
|
20297
20316
|
if (explorer === true) {
|
|
@@ -20334,7 +20353,7 @@ const getCorePlugins = ({
|
|
|
20334
20353
|
runtimeCompat,
|
|
20335
20354
|
clientMainFileUrl,
|
|
20336
20355
|
urlResolution
|
|
20337
|
-
}), jsenvPluginUrlVersion(), jsenvPluginCommonJsGlobals(), jsenvPluginImportMetaScenarios(), jsenvPluginGlobalScenarios(), jsenvPluginNodeRuntime({
|
|
20356
|
+
}), jsenvPluginUrlVersion(), jsenvPluginCommonJsGlobals(), jsenvPluginImportMetaScenarios(), ...(scenarioPlaceholders ? [jsenvPluginGlobalScenarios()] : []), jsenvPluginNodeRuntime({
|
|
20338
20357
|
runtimeCompat
|
|
20339
20358
|
}), jsenvPluginImportMetaHot(), ...(clientAutoreload ? [jsenvPluginAutoreload({
|
|
20340
20359
|
...clientAutoreload,
|
|
@@ -20744,6 +20763,7 @@ const build = async ({
|
|
|
20744
20763
|
urlResolution,
|
|
20745
20764
|
fileSystemMagicRedirection,
|
|
20746
20765
|
directoryReferenceAllowed,
|
|
20766
|
+
scenarioPlaceholders,
|
|
20747
20767
|
transpilation = {},
|
|
20748
20768
|
versioning = !runtimeCompat.node,
|
|
20749
20769
|
versioningMethod = "search_param",
|
|
@@ -20886,7 +20906,8 @@ build ${entryPointKeys.length} entry points`);
|
|
|
20886
20906
|
...transpilation,
|
|
20887
20907
|
babelHelpersAsImport: !useExplicitJsClassicConversion,
|
|
20888
20908
|
jsClassicFallback: false
|
|
20889
|
-
}
|
|
20909
|
+
},
|
|
20910
|
+
scenarioPlaceholders
|
|
20890
20911
|
})],
|
|
20891
20912
|
sourcemaps,
|
|
20892
20913
|
sourcemapsSourcesContent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "31.1.
|
|
3
|
+
"version": "31.1.2",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -75,7 +75,6 @@
|
|
|
75
75
|
"@jsenv/log": "3.3.4",
|
|
76
76
|
"@jsenv/node-esm-resolution": "1.0.1",
|
|
77
77
|
"@jsenv/plugin-bundling": "2.0.0",
|
|
78
|
-
"@jsenv/plugin-globals": "1.1.0",
|
|
79
78
|
"@jsenv/server": "15.0.0",
|
|
80
79
|
"@jsenv/sourcemap": "1.0.9",
|
|
81
80
|
"@jsenv/uneval": "1.6.0",
|
package/src/build/build.js
CHANGED
|
@@ -138,6 +138,7 @@ export const build = async ({
|
|
|
138
138
|
urlResolution,
|
|
139
139
|
fileSystemMagicRedirection,
|
|
140
140
|
directoryReferenceAllowed,
|
|
141
|
+
scenarioPlaceholders,
|
|
141
142
|
transpilation = {},
|
|
142
143
|
versioning = !runtimeCompat.node,
|
|
143
144
|
versioningMethod = "search_param", // "filename", "search_param"
|
|
@@ -316,6 +317,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
316
317
|
babelHelpersAsImport: !useExplicitJsClassicConversion,
|
|
317
318
|
jsClassicFallback: false,
|
|
318
319
|
},
|
|
320
|
+
scenarioPlaceholders,
|
|
319
321
|
}),
|
|
320
322
|
],
|
|
321
323
|
sourcemaps,
|
package/src/plugins/plugins.js
CHANGED
|
@@ -40,6 +40,7 @@ export const getCorePlugins = ({
|
|
|
40
40
|
clientFilesPruneCallbackList,
|
|
41
41
|
explorer,
|
|
42
42
|
cacheControl,
|
|
43
|
+
scenarioPlaceholders = true,
|
|
43
44
|
ribbon = true,
|
|
44
45
|
} = {}) => {
|
|
45
46
|
if (explorer === true) {
|
|
@@ -90,7 +91,7 @@ export const getCorePlugins = ({
|
|
|
90
91
|
jsenvPluginUrlVersion(),
|
|
91
92
|
jsenvPluginCommonJsGlobals(),
|
|
92
93
|
jsenvPluginImportMetaScenarios(),
|
|
93
|
-
jsenvPluginGlobalScenarios(),
|
|
94
|
+
...(scenarioPlaceholders ? [jsenvPluginGlobalScenarios()] : []),
|
|
94
95
|
|
|
95
96
|
jsenvPluginNodeRuntime({ runtimeCompat }),
|
|
96
97
|
|