@jsenv/core 39.13.3 → 39.14.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.
package/README.md
CHANGED
|
@@ -4,32 +4,31 @@
|
|
|
4
4
|
|
|
5
5
|
Jsenv is a suite of tools that can be used in projects involving JavaScript.
|
|
6
6
|
|
|
7
|
-
`@jsenv/core`
|
|
7
|
+
The goal of `@jsenv/core` is to provide the following tools:
|
|
8
8
|
|
|
9
|
-
1. **dev server**;
|
|
10
|
-
2. **build**;
|
|
11
|
-
3. **build server**;
|
|
12
|
-
4. **test runner**;
|
|
9
|
+
1. **dev server**; A server that serves source files, facilitating development with live reloading.
|
|
10
|
+
2. **build**; Optimizes source files into a specified directory for production.
|
|
11
|
+
3. **build server**; Serves the built files, allowing for testing and verifying the production build.
|
|
12
|
+
4. **test runner**; Runs test files concurrently, ensuring code reliability.
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
As a result it can be enjoyed by people without much experience in tooling or seeking for simple tools without hidden complexities.
|
|
14
|
+
Jsenv prioritizes standards and simplicity, making it ideal for both beginners and those who need straightforward tools without unnecessary complexities.
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
To try jsenv on your machine, use [@jsenv/cli](./packages/related/cli/#jsenvcli).
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
For additional details, consult the [documentation](./docs/users/users.md)
|
|
20
19
|
|
|
21
20
|
# The best parts
|
|
22
21
|
|
|
23
|
-
-
|
|
24
|
-
- [
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
22
|
+
- **Robust versioning during build**: Avoids <a href="https://bundlers.tooling.report/hashing/avoid-cascade/" target="_blank">cascading hash changes</a><sup>↗</sup>.
|
|
23
|
+
- **Load js module with classic script**: See the [asJsClassic plugin](./docs/users/g_plugins/g_plugins.md#asjsclassic).
|
|
24
|
+
- **Large browser support after build**: Ensures compatibility with older versions of Firefox, Chrome, and Safari.
|
|
25
|
+
- **Advanced support of top level await**.
|
|
26
|
+
- **Advanced support of web workers**.
|
|
27
|
+
- **Test files are executed like standard files**.
|
|
28
|
+
- **Isolated environment for each test file**: Ensures tests run independently, preventing side effects.
|
|
29
|
+
- Single set of files after build: Simplifies support and deployement with a single set of files.
|
|
30
|
+
- Execute tests in multiple browsers: Supports Chrome, Safari, and Firefox.
|
|
31
|
+
- Extensive browser support during dev: Allows the use of various browsers beyond the latest Chrome, which is useful for reproducing browser-specific bugs.
|
|
33
32
|
|
|
34
33
|
<!--
|
|
35
34
|
The following commands can be used to skip the prompt
|
package/dist/jsenv_core.js
CHANGED
|
@@ -11360,7 +11360,7 @@ const JS_QUOTE_REPLACEMENTS = {
|
|
|
11360
11360
|
|
|
11361
11361
|
const jsenvPluginImportAttributes = ({
|
|
11362
11362
|
json = "auto",
|
|
11363
|
-
css =
|
|
11363
|
+
css = true,
|
|
11364
11364
|
text = "auto",
|
|
11365
11365
|
}) => {
|
|
11366
11366
|
const transpilations = { json, css, text };
|
|
@@ -11370,7 +11370,11 @@ const jsenvPluginImportAttributes = ({
|
|
|
11370
11370
|
reference.filenameHint = `${urlToFilename$1(reference.url)}.js`;
|
|
11371
11371
|
}
|
|
11372
11372
|
};
|
|
11373
|
-
const turnIntoJsModuleProxy = (
|
|
11373
|
+
const turnIntoJsModuleProxy = (
|
|
11374
|
+
reference,
|
|
11375
|
+
type,
|
|
11376
|
+
{ injectSearchParamForSideEffectImports },
|
|
11377
|
+
) => {
|
|
11374
11378
|
reference.mutation = (magicSource) => {
|
|
11375
11379
|
if (reference.subtype === "import_dynamic") {
|
|
11376
11380
|
const { importTypeAttributeNode } = reference.astInfo;
|
|
@@ -11397,12 +11401,19 @@ const jsenvPluginImportAttributes = ({
|
|
|
11397
11401
|
};
|
|
11398
11402
|
const newUrl = injectQueryParams(reference.url, {
|
|
11399
11403
|
[`as_${type}_module`]: "",
|
|
11404
|
+
...(injectSearchParamForSideEffectImports && reference.isSideEffectImport
|
|
11405
|
+
? { side_effect: "" }
|
|
11406
|
+
: {}),
|
|
11400
11407
|
});
|
|
11401
11408
|
markAsJsModuleProxy(reference);
|
|
11402
11409
|
return newUrl;
|
|
11403
11410
|
};
|
|
11404
11411
|
|
|
11405
|
-
const createImportTypePlugin = ({
|
|
11412
|
+
const createImportTypePlugin = ({
|
|
11413
|
+
type,
|
|
11414
|
+
createUrlContent,
|
|
11415
|
+
injectSearchParamForSideEffectImports,
|
|
11416
|
+
}) => {
|
|
11406
11417
|
return {
|
|
11407
11418
|
name: `jsenv:import_type_${type}`,
|
|
11408
11419
|
appliesDuring: "*",
|
|
@@ -11440,7 +11451,9 @@ const jsenvPluginImportAttributes = ({
|
|
|
11440
11451
|
return null;
|
|
11441
11452
|
}
|
|
11442
11453
|
if (reference.importAttributes.type === type) {
|
|
11443
|
-
return turnIntoJsModuleProxy(reference, type
|
|
11454
|
+
return turnIntoJsModuleProxy(reference, type, {
|
|
11455
|
+
injectSearchParamForSideEffectImports,
|
|
11456
|
+
});
|
|
11444
11457
|
}
|
|
11445
11458
|
return null;
|
|
11446
11459
|
},
|
|
@@ -11489,6 +11502,7 @@ const jsenvPluginImportAttributes = ({
|
|
|
11489
11502
|
|
|
11490
11503
|
const asCssModule = createImportTypePlugin({
|
|
11491
11504
|
type: "css",
|
|
11505
|
+
injectSearchParamForSideEffectImports: true,
|
|
11492
11506
|
createUrlContent: (cssUrlInfo) => {
|
|
11493
11507
|
const cssText = JS_QUOTES.escapeSpecialChars(cssUrlInfo.content, {
|
|
11494
11508
|
// If template string is choosen and runtime do not support template literals
|
|
@@ -11506,15 +11520,38 @@ const jsenvPluginImportAttributes = ({
|
|
|
11506
11520
|
} else {
|
|
11507
11521
|
inlineContentCall = `new __InlineContent__(${cssText}, { type: "text/css" })`;
|
|
11508
11522
|
}
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11523
|
+
|
|
11524
|
+
let autoInject = cssUrlInfo.searchParams.has("side_effect");
|
|
11525
|
+
let cssModuleAutoInjectCode = ``;
|
|
11526
|
+
if (autoInject) {
|
|
11527
|
+
if (cssUrlInfo.context.dev) {
|
|
11528
|
+
cssModuleAutoInjectCode = `
|
|
11529
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
|
|
11530
|
+
|
|
11531
|
+
if (import.meta.hot) {
|
|
11532
|
+
import.meta.hot.dispose(() => {
|
|
11533
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
|
|
11534
|
+
(s) => s !== stylesheet,
|
|
11535
|
+
);
|
|
11536
|
+
});
|
|
11537
|
+
};
|
|
11538
|
+
`;
|
|
11539
|
+
} else {
|
|
11540
|
+
cssModuleAutoInjectCode = `
|
|
11541
|
+
document.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];
|
|
11542
|
+
`;
|
|
11543
|
+
}
|
|
11544
|
+
}
|
|
11545
|
+
let cssModuleContent = `import ${JSON.stringify(cssUrlInfo.context.inlineContentClientFileUrl)};
|
|
11512
11546
|
|
|
11513
11547
|
const inlineContent = ${inlineContentCall};
|
|
11514
11548
|
const stylesheet = new CSSStyleSheet();
|
|
11515
11549
|
stylesheet.replaceSync(inlineContent.text);
|
|
11550
|
+
${cssModuleAutoInjectCode}
|
|
11551
|
+
export default stylesheet;`;
|
|
11516
11552
|
|
|
11517
|
-
|
|
11553
|
+
return {
|
|
11554
|
+
content: cssModuleContent,
|
|
11518
11555
|
contentType: "text/javascript",
|
|
11519
11556
|
type: "js_module",
|
|
11520
11557
|
originalUrl: cssUrlInfo.originalUrl,
|
|
@@ -13229,6 +13266,7 @@ const createReference = ({
|
|
|
13229
13266
|
urlInfo = null,
|
|
13230
13267
|
escape = null,
|
|
13231
13268
|
importAttributes,
|
|
13269
|
+
isSideEffectImport = false,
|
|
13232
13270
|
astInfo = {},
|
|
13233
13271
|
mutation,
|
|
13234
13272
|
}) => {
|
|
@@ -13292,6 +13330,7 @@ const createReference = ({
|
|
|
13292
13330
|
// used mostly by worker and import assertions
|
|
13293
13331
|
astInfo,
|
|
13294
13332
|
importAttributes,
|
|
13333
|
+
isSideEffectImport,
|
|
13295
13334
|
mutation,
|
|
13296
13335
|
};
|
|
13297
13336
|
|
|
@@ -17710,6 +17749,7 @@ const parseAndTransformJsReferences = async (
|
|
|
17710
17749
|
"document.currentScript.src": urlInfo.url,
|
|
17711
17750
|
}[externalReferenceInfo.baseUrlType],
|
|
17712
17751
|
importAttributes: externalReferenceInfo.importAttributes,
|
|
17752
|
+
isSideEffectImport: externalReferenceInfo.isSideEffectImport,
|
|
17713
17753
|
astInfo: externalReferenceInfo.astInfo,
|
|
17714
17754
|
});
|
|
17715
17755
|
parallelActions.push(async () => {
|
|
@@ -17941,7 +17981,7 @@ const jsenvPluginInlineContentFetcher = () => {
|
|
|
17941
17981
|
// https://nodejs.org/api/packages.html#resolving-user-conditions
|
|
17942
17982
|
const readCustomConditionsFromProcessArgs = () => {
|
|
17943
17983
|
const packageConditions = [];
|
|
17944
|
-
process.execArgv
|
|
17984
|
+
for (const arg of process.execArgv) {
|
|
17945
17985
|
if (arg.includes("-C=")) {
|
|
17946
17986
|
const packageCondition = arg.slice(0, "-C=".length);
|
|
17947
17987
|
packageConditions.push(packageCondition);
|
|
@@ -17950,7 +17990,7 @@ const readCustomConditionsFromProcessArgs = () => {
|
|
|
17950
17990
|
const packageCondition = arg.slice("--conditions=".length);
|
|
17951
17991
|
packageConditions.push(packageCondition);
|
|
17952
17992
|
}
|
|
17953
|
-
}
|
|
17993
|
+
}
|
|
17954
17994
|
return packageConditions;
|
|
17955
17995
|
};
|
|
17956
17996
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "39.
|
|
3
|
+
"version": "39.14.1",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -38,7 +38,10 @@
|
|
|
38
38
|
},
|
|
39
39
|
"workspaces": [
|
|
40
40
|
"./packages/independent/*",
|
|
41
|
-
"./packages/independent/
|
|
41
|
+
"./packages/independent/backend/*",
|
|
42
|
+
"./packages/independent/frontend/*",
|
|
43
|
+
"./packages/independent/tooling/*",
|
|
44
|
+
"./packages/independent/universal/*",
|
|
42
45
|
"./packages/internal/*",
|
|
43
46
|
"./packages/related/*",
|
|
44
47
|
"./packages/related/cli/*"
|
|
@@ -69,19 +72,19 @@
|
|
|
69
72
|
"dependencies": {
|
|
70
73
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
71
74
|
"@jsenv/abort": "4.3.0",
|
|
72
|
-
"@jsenv/ast": "6.5.
|
|
75
|
+
"@jsenv/ast": "6.5.2",
|
|
73
76
|
"@jsenv/filesystem": "4.13.4",
|
|
74
77
|
"@jsenv/humanize": "1.2.8",
|
|
75
78
|
"@jsenv/importmap": "1.2.1",
|
|
76
79
|
"@jsenv/integrity": "0.0.2",
|
|
77
|
-
"@jsenv/js-module-fallback": "1.3.
|
|
80
|
+
"@jsenv/js-module-fallback": "1.3.59",
|
|
78
81
|
"@jsenv/node-esm-resolution": "1.0.6",
|
|
79
82
|
"@jsenv/plugin-bundling": "2.7.25",
|
|
80
83
|
"@jsenv/plugin-minification": "1.5.13",
|
|
81
|
-
"@jsenv/plugin-supervisor": "1.6.
|
|
82
|
-
"@jsenv/plugin-transpilation": "1.4.
|
|
84
|
+
"@jsenv/plugin-supervisor": "1.6.6",
|
|
85
|
+
"@jsenv/plugin-transpilation": "1.4.95",
|
|
83
86
|
"@jsenv/runtime-compat": "1.3.1",
|
|
84
|
-
"@jsenv/server": "15.5.
|
|
87
|
+
"@jsenv/server": "15.5.2",
|
|
85
88
|
"@jsenv/sourcemap": "1.2.30",
|
|
86
89
|
"@jsenv/url-meta": "8.5.3",
|
|
87
90
|
"@jsenv/urls": "2.6.0",
|
|
@@ -304,6 +304,7 @@ const createReference = ({
|
|
|
304
304
|
urlInfo = null,
|
|
305
305
|
escape = null,
|
|
306
306
|
importAttributes,
|
|
307
|
+
isSideEffectImport = false,
|
|
307
308
|
astInfo = {},
|
|
308
309
|
mutation,
|
|
309
310
|
}) => {
|
|
@@ -367,6 +368,7 @@ const createReference = ({
|
|
|
367
368
|
// used mostly by worker and import assertions
|
|
368
369
|
astInfo,
|
|
369
370
|
importAttributes,
|
|
371
|
+
isSideEffectImport,
|
|
370
372
|
mutation,
|
|
371
373
|
};
|
|
372
374
|
|
|
@@ -117,6 +117,7 @@ const parseAndTransformJsReferences = async (
|
|
|
117
117
|
"document.currentScript.src": urlInfo.url,
|
|
118
118
|
}[externalReferenceInfo.baseUrlType],
|
|
119
119
|
importAttributes: externalReferenceInfo.importAttributes,
|
|
120
|
+
isSideEffectImport: externalReferenceInfo.isSideEffectImport,
|
|
120
121
|
astInfo: externalReferenceInfo.astInfo,
|
|
121
122
|
});
|
|
122
123
|
parallelActions.push(async () => {
|