@jsenv/core 39.2.12 → 39.2.14
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 +9 -56
- package/dist/jsenv_core.js +243 -229
- package/package.json +12 -12
- package/src/build/build.js +7 -3
package/README.md
CHANGED
|
@@ -12,69 +12,22 @@ Jsenv is a suite of tools that can be used in projects involving JavaScript.
|
|
|
12
12
|
It favors standards and simplicity.
|
|
13
13
|
As a result it can be enjoyed by people without much experience in tooling or seeking for simple tools without hidden complexities.
|
|
14
14
|
|
|
15
|
-
If you want to try jsenv on your machine, use [
|
|
15
|
+
If you want to try jsenv on your machine, use [@jsenv/cli](./packages/related/cli/readme.md).
|
|
16
16
|
|
|
17
|
-
Link to [documentation](./
|
|
18
|
-
|
|
19
|
-
# CLI
|
|
20
|
-
|
|
21
|
-
The following command init jsenv on your machine.
|
|
22
|
-
|
|
23
|
-
```console
|
|
24
|
-
npx @jsenv/cli
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
> If you don't have `npx` command you must [install Node.js](https://nodejs.org/en/download/package-manager)
|
|
28
|
-
|
|
29
|
-
The command init jsenv in a directory. It can be a new directory or an existing one.
|
|
30
|
-
|
|
31
|
-
```console
|
|
32
|
-
> npx @jsenv/cli
|
|
33
|
-
Welcome in jsenv CLI
|
|
34
|
-
? Enter a directory: ›
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Then you'll be prompted to select a template.
|
|
38
|
-
|
|
39
|
-
```console
|
|
40
|
-
> npx @jsenv/cli
|
|
41
|
-
✔ Enter a directory: › demo
|
|
42
|
-
? Select a template: › - Use arrow-keys. Return to submit.
|
|
43
|
-
❯ web
|
|
44
|
-
web-components
|
|
45
|
-
web-react
|
|
46
|
-
web-preact
|
|
47
|
-
node-package
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
A template is a project pre-configured with jsenv.
|
|
51
|
-
Selecting "web" would init [template-web/](./packages/related/cli/template-web/):
|
|
52
|
-
|
|
53
|
-
```console
|
|
54
|
-
> npx @jsenv/cli
|
|
55
|
-
✔ Enter a directory: › demo
|
|
56
|
-
✔ Select a template: › web
|
|
57
|
-
✔ init jsenv in "[...]/demo/" (done in 0.01 second)
|
|
58
|
-
----- 2 commands to run -----
|
|
59
|
-
cd demo
|
|
60
|
-
npm install
|
|
61
|
-
-----------------------------
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
<!-- For example in order to start a dev server you would rather do `npm run dev` that would be declared in [package.json#scripts.dev](./packages/related/create-jsenv/demo-web/package.json#L8) to execute [scripts/dev.mjs](./packages/related/create-jsenv/demo-web/scripts/dev.mjs). -->
|
|
17
|
+
Link to [documentation](./md/users/users.md)
|
|
65
18
|
|
|
66
19
|
# The best parts
|
|
67
20
|
|
|
68
|
-
- Test files are [executed like standard files](./
|
|
69
|
-
- [Isolated environment](./
|
|
70
|
-
- Execute [tests in multiple browsers](./
|
|
71
|
-
- [Large browser support during dev](./
|
|
72
|
-
- [Large browser support after build](./
|
|
73
|
-
- [Single set of files after build](./
|
|
21
|
+
- Test files are [executed like standard files](./md/users/d_test/d_test.md#14-executing-a-single-test)
|
|
22
|
+
- [Isolated environment](./md/users/d_test/d_test.md#33-isolated-environment) for each test file
|
|
23
|
+
- Execute [tests in multiple browsers](./md/users/d_test/d_test.md#32-execute-on-more-browsers>): Chrome, Safari, Firefox
|
|
24
|
+
- [Large browser support during dev](./md/users/b_dev/b_dev.md#21-browser-support>). Because some people might be happy to use an other browser than the latest chrome during dev. Moreover it is useful to reproduce bug specific to certain browsers.
|
|
25
|
+
- [Large browser support after build](./md/users/c_build/c_build.md#211-maximal-browser-support). Because some product still needs to support old versions of Firefox, Chrome and Safari.
|
|
26
|
+
- [Single set of files after build](./md/users/c_build/c_build.md#212-same-build-for-all-browsers). Because a single one is simpler to properly support in every aspects.
|
|
74
27
|
- Versioning during build is robust and <a href="https://bundlers.tooling.report/hashing/avoid-cascade/" target="_blank">avoids cascading hash changes</a><sup>↗</sup>
|
|
75
28
|
- Advanced support of top level await, allowing to use it everywhere
|
|
76
29
|
- Advanced support of web workers including worker type module
|
|
77
|
-
- Unlock [js module features on a classic `<script>`](./
|
|
30
|
+
- Unlock [js module features on a classic `<script>`](./md/users/g_plugins/g_plugins.md#22-asjsclassic>).
|
|
78
31
|
|
|
79
32
|
<!--
|
|
80
33
|
The following commands can be used to skip the prompt
|
package/dist/jsenv_core.js
CHANGED
|
@@ -1401,6 +1401,38 @@ const resourceToPathname = (resource) => {
|
|
|
1401
1401
|
return resource;
|
|
1402
1402
|
};
|
|
1403
1403
|
|
|
1404
|
+
const urlToFilename$1 = (url) => {
|
|
1405
|
+
const pathname = urlToPathname$1(url);
|
|
1406
|
+
return pathnameToFilename(pathname);
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1409
|
+
const pathnameToFilename = (pathname) => {
|
|
1410
|
+
const pathnameBeforeLastSlash = pathname.endsWith("/")
|
|
1411
|
+
? pathname.slice(0, -1)
|
|
1412
|
+
: pathname;
|
|
1413
|
+
const slashLastIndex = pathnameBeforeLastSlash.lastIndexOf("/");
|
|
1414
|
+
const filename =
|
|
1415
|
+
slashLastIndex === -1
|
|
1416
|
+
? pathnameBeforeLastSlash
|
|
1417
|
+
: pathnameBeforeLastSlash.slice(slashLastIndex + 1);
|
|
1418
|
+
return filename;
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1421
|
+
const urlToBasename = (url, removeAllExtensions) => {
|
|
1422
|
+
const filename = urlToFilename$1(url);
|
|
1423
|
+
const basename = filenameToBasename(filename);
|
|
1424
|
+
{
|
|
1425
|
+
return basename;
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1429
|
+
const filenameToBasename = (filename) => {
|
|
1430
|
+
const dotLastIndex = filename.lastIndexOf(".");
|
|
1431
|
+
const basename =
|
|
1432
|
+
dotLastIndex === -1 ? filename : filename.slice(0, dotLastIndex);
|
|
1433
|
+
return basename;
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1404
1436
|
const urlToExtension$1 = (url) => {
|
|
1405
1437
|
const pathname = urlToPathname$1(url);
|
|
1406
1438
|
return pathnameToExtension$1(pathname);
|
|
@@ -1554,14 +1586,13 @@ const renderUrlOrRelativeUrlFilename = (urlOrRelativeUrl, renderer) => {
|
|
|
1554
1586
|
};
|
|
1555
1587
|
|
|
1556
1588
|
const setUrlFilename = (url, filename) => {
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
return `${origin}${parentPathname}${filename}${search}${hash}`;
|
|
1589
|
+
const parentPathname = new URL("./", url).pathname;
|
|
1590
|
+
return transformUrlPathname(url, (pathname) => {
|
|
1591
|
+
if (typeof filename === "function") {
|
|
1592
|
+
filename = filename(pathnameToFilename(pathname));
|
|
1593
|
+
}
|
|
1594
|
+
return `${parentPathname}${filename}`;
|
|
1595
|
+
});
|
|
1565
1596
|
};
|
|
1566
1597
|
|
|
1567
1598
|
const transformUrlPathname = (url, transformer) => {
|
|
@@ -1773,27 +1804,6 @@ const urlIsInsideOf = (url, otherUrl) => {
|
|
|
1773
1804
|
return isInside;
|
|
1774
1805
|
};
|
|
1775
1806
|
|
|
1776
|
-
const urlToFilename$1 = (url) => {
|
|
1777
|
-
const pathname = urlToPathname$1(url);
|
|
1778
|
-
const pathnameBeforeLastSlash = pathname.endsWith("/")
|
|
1779
|
-
? pathname.slice(0, -1)
|
|
1780
|
-
: pathname;
|
|
1781
|
-
const slashLastIndex = pathnameBeforeLastSlash.lastIndexOf("/");
|
|
1782
|
-
const filename =
|
|
1783
|
-
slashLastIndex === -1
|
|
1784
|
-
? pathnameBeforeLastSlash
|
|
1785
|
-
: pathnameBeforeLastSlash.slice(slashLastIndex + 1);
|
|
1786
|
-
return filename;
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
|
-
const urlToBasename = (url) => {
|
|
1790
|
-
const filename = urlToFilename$1(url);
|
|
1791
|
-
const dotLastIndex = filename.lastIndexOf(".");
|
|
1792
|
-
const basename =
|
|
1793
|
-
dotLastIndex === -1 ? filename : filename.slice(0, dotLastIndex);
|
|
1794
|
-
return basename;
|
|
1795
|
-
};
|
|
1796
|
-
|
|
1797
1807
|
const urlToFileSystemPath = (url) => {
|
|
1798
1808
|
let urlString = String(url);
|
|
1799
1809
|
if (urlString[urlString.length - 1] === "/") {
|
|
@@ -3283,6 +3293,203 @@ const writeDirectory = async (
|
|
|
3283
3293
|
}
|
|
3284
3294
|
};
|
|
3285
3295
|
|
|
3296
|
+
const mediaTypeInfos = {
|
|
3297
|
+
"application/json": {
|
|
3298
|
+
extensions: ["json", "map"],
|
|
3299
|
+
isTextual: true,
|
|
3300
|
+
},
|
|
3301
|
+
"application/importmap+json": {
|
|
3302
|
+
extensions: ["importmap"],
|
|
3303
|
+
isTextual: true,
|
|
3304
|
+
},
|
|
3305
|
+
"application/manifest+json": {
|
|
3306
|
+
extensions: ["webmanifest"],
|
|
3307
|
+
isTextual: true,
|
|
3308
|
+
},
|
|
3309
|
+
"application/octet-stream": {},
|
|
3310
|
+
"application/pdf": {
|
|
3311
|
+
extensions: ["pdf"],
|
|
3312
|
+
},
|
|
3313
|
+
"application/xml": {
|
|
3314
|
+
extensions: ["xml"],
|
|
3315
|
+
isTextual: true,
|
|
3316
|
+
},
|
|
3317
|
+
"application/x-gzip": {
|
|
3318
|
+
extensions: ["gz"],
|
|
3319
|
+
},
|
|
3320
|
+
"application/wasm": {
|
|
3321
|
+
extensions: ["wasm"],
|
|
3322
|
+
},
|
|
3323
|
+
"application/zip": {
|
|
3324
|
+
extensions: ["zip"],
|
|
3325
|
+
},
|
|
3326
|
+
"audio/basic": {
|
|
3327
|
+
extensions: ["au", "snd"],
|
|
3328
|
+
},
|
|
3329
|
+
"audio/mpeg": {
|
|
3330
|
+
extensions: ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"],
|
|
3331
|
+
},
|
|
3332
|
+
"audio/midi": {
|
|
3333
|
+
extensions: ["midi", "mid", "kar", "rmi"],
|
|
3334
|
+
},
|
|
3335
|
+
"audio/mp4": {
|
|
3336
|
+
extensions: ["m4a", "mp4a"],
|
|
3337
|
+
},
|
|
3338
|
+
"audio/ogg": {
|
|
3339
|
+
extensions: ["oga", "ogg", "spx"],
|
|
3340
|
+
},
|
|
3341
|
+
"audio/webm": {
|
|
3342
|
+
extensions: ["weba"],
|
|
3343
|
+
},
|
|
3344
|
+
"audio/x-wav": {
|
|
3345
|
+
extensions: ["wav"],
|
|
3346
|
+
},
|
|
3347
|
+
"font/ttf": {
|
|
3348
|
+
extensions: ["ttf"],
|
|
3349
|
+
},
|
|
3350
|
+
"font/woff": {
|
|
3351
|
+
extensions: ["woff"],
|
|
3352
|
+
},
|
|
3353
|
+
"font/woff2": {
|
|
3354
|
+
extensions: ["woff2"],
|
|
3355
|
+
},
|
|
3356
|
+
"image/png": {
|
|
3357
|
+
extensions: ["png"],
|
|
3358
|
+
},
|
|
3359
|
+
"image/gif": {
|
|
3360
|
+
extensions: ["gif"],
|
|
3361
|
+
},
|
|
3362
|
+
"image/jpeg": {
|
|
3363
|
+
extensions: ["jpg"],
|
|
3364
|
+
},
|
|
3365
|
+
"image/svg+xml": {
|
|
3366
|
+
extensions: ["svg", "svgz"],
|
|
3367
|
+
isTextual: true,
|
|
3368
|
+
},
|
|
3369
|
+
"text/plain": {
|
|
3370
|
+
extensions: ["txt"],
|
|
3371
|
+
isTextual: true,
|
|
3372
|
+
},
|
|
3373
|
+
"text/html": {
|
|
3374
|
+
extensions: ["html"],
|
|
3375
|
+
isTextual: true,
|
|
3376
|
+
},
|
|
3377
|
+
"text/css": {
|
|
3378
|
+
extensions: ["css"],
|
|
3379
|
+
isTextual: true,
|
|
3380
|
+
},
|
|
3381
|
+
"text/javascript": {
|
|
3382
|
+
extensions: ["js", "cjs", "mjs", "ts", "jsx", "tsx"],
|
|
3383
|
+
isTextual: true,
|
|
3384
|
+
},
|
|
3385
|
+
"text/markdown": {
|
|
3386
|
+
extensions: ["md", "mdx"],
|
|
3387
|
+
isTextual: true,
|
|
3388
|
+
},
|
|
3389
|
+
"text/x-sass": {
|
|
3390
|
+
extensions: ["sass"],
|
|
3391
|
+
isTextual: true,
|
|
3392
|
+
},
|
|
3393
|
+
"text/x-scss": {
|
|
3394
|
+
extensions: ["scss"],
|
|
3395
|
+
isTextual: true,
|
|
3396
|
+
},
|
|
3397
|
+
"text/cache-manifest": {
|
|
3398
|
+
extensions: ["appcache"],
|
|
3399
|
+
},
|
|
3400
|
+
"video/mp4": {
|
|
3401
|
+
extensions: ["mp4", "mp4v", "mpg4"],
|
|
3402
|
+
},
|
|
3403
|
+
"video/mpeg": {
|
|
3404
|
+
extensions: ["mpeg", "mpg", "mpe", "m1v", "m2v"],
|
|
3405
|
+
},
|
|
3406
|
+
"video/ogg": {
|
|
3407
|
+
extensions: ["ogv"],
|
|
3408
|
+
},
|
|
3409
|
+
"video/webm": {
|
|
3410
|
+
extensions: ["webm"],
|
|
3411
|
+
},
|
|
3412
|
+
};
|
|
3413
|
+
|
|
3414
|
+
const CONTENT_TYPE = {
|
|
3415
|
+
parse: (string) => {
|
|
3416
|
+
const [mediaType, charset] = string.split(";");
|
|
3417
|
+
return { mediaType: normalizeMediaType(mediaType), charset };
|
|
3418
|
+
},
|
|
3419
|
+
|
|
3420
|
+
stringify: ({ mediaType, charset }) => {
|
|
3421
|
+
if (charset) {
|
|
3422
|
+
return `${mediaType};${charset}`;
|
|
3423
|
+
}
|
|
3424
|
+
return mediaType;
|
|
3425
|
+
},
|
|
3426
|
+
|
|
3427
|
+
asMediaType: (value) => {
|
|
3428
|
+
if (typeof value === "string") {
|
|
3429
|
+
return CONTENT_TYPE.parse(value).mediaType;
|
|
3430
|
+
}
|
|
3431
|
+
if (typeof value === "object") {
|
|
3432
|
+
return value.mediaType;
|
|
3433
|
+
}
|
|
3434
|
+
return null;
|
|
3435
|
+
},
|
|
3436
|
+
|
|
3437
|
+
isJson: (value) => {
|
|
3438
|
+
const mediaType = CONTENT_TYPE.asMediaType(value);
|
|
3439
|
+
return (
|
|
3440
|
+
mediaType === "application/json" ||
|
|
3441
|
+
/^application\/\w+\+json$/.test(mediaType)
|
|
3442
|
+
);
|
|
3443
|
+
},
|
|
3444
|
+
|
|
3445
|
+
isTextual: (value) => {
|
|
3446
|
+
const mediaType = CONTENT_TYPE.asMediaType(value);
|
|
3447
|
+
if (mediaType.startsWith("text/")) {
|
|
3448
|
+
return true;
|
|
3449
|
+
}
|
|
3450
|
+
const mediaTypeInfo = mediaTypeInfos[mediaType];
|
|
3451
|
+
if (mediaTypeInfo && mediaTypeInfo.isTextual) {
|
|
3452
|
+
return true;
|
|
3453
|
+
}
|
|
3454
|
+
// catch things like application/manifest+json, application/importmap+json
|
|
3455
|
+
if (/^application\/\w+\+json$/.test(mediaType)) {
|
|
3456
|
+
return true;
|
|
3457
|
+
}
|
|
3458
|
+
return false;
|
|
3459
|
+
},
|
|
3460
|
+
|
|
3461
|
+
isBinary: (value) => !CONTENT_TYPE.isTextual(value),
|
|
3462
|
+
|
|
3463
|
+
asFileExtension: (value) => {
|
|
3464
|
+
const mediaType = CONTENT_TYPE.asMediaType(value);
|
|
3465
|
+
const mediaTypeInfo = mediaTypeInfos[mediaType];
|
|
3466
|
+
return mediaTypeInfo ? `.${mediaTypeInfo.extensions[0]}` : "";
|
|
3467
|
+
},
|
|
3468
|
+
|
|
3469
|
+
fromUrlExtension: (url) => {
|
|
3470
|
+
const { pathname } = new URL(url);
|
|
3471
|
+
const extensionWithDot = extname(pathname);
|
|
3472
|
+
if (!extensionWithDot || extensionWithDot === ".") {
|
|
3473
|
+
return "application/octet-stream";
|
|
3474
|
+
}
|
|
3475
|
+
const extension = extensionWithDot.slice(1);
|
|
3476
|
+
const mediaTypeFound = Object.keys(mediaTypeInfos).find((mediaType) => {
|
|
3477
|
+
const mediaTypeInfo = mediaTypeInfos[mediaType];
|
|
3478
|
+
return (
|
|
3479
|
+
mediaTypeInfo.extensions && mediaTypeInfo.extensions.includes(extension)
|
|
3480
|
+
);
|
|
3481
|
+
});
|
|
3482
|
+
return mediaTypeFound || "application/octet-stream";
|
|
3483
|
+
},
|
|
3484
|
+
};
|
|
3485
|
+
|
|
3486
|
+
const normalizeMediaType = (value) => {
|
|
3487
|
+
if (value === "application/javascript") {
|
|
3488
|
+
return "text/javascript";
|
|
3489
|
+
}
|
|
3490
|
+
return value;
|
|
3491
|
+
};
|
|
3492
|
+
|
|
3286
3493
|
const writeFileSync = (destination, content = "") => {
|
|
3287
3494
|
const destinationUrl = assertAndNormalizeFileUrl(destination);
|
|
3288
3495
|
const destinationUrlObject = new URL(destinationUrl);
|
|
@@ -3552,203 +3759,6 @@ process.platform === "win32";
|
|
|
3552
3759
|
|
|
3553
3760
|
process.platform === "win32";
|
|
3554
3761
|
|
|
3555
|
-
const mediaTypeInfos = {
|
|
3556
|
-
"application/json": {
|
|
3557
|
-
extensions: ["json", "map"],
|
|
3558
|
-
isTextual: true,
|
|
3559
|
-
},
|
|
3560
|
-
"application/importmap+json": {
|
|
3561
|
-
extensions: ["importmap"],
|
|
3562
|
-
isTextual: true,
|
|
3563
|
-
},
|
|
3564
|
-
"application/manifest+json": {
|
|
3565
|
-
extensions: ["webmanifest"],
|
|
3566
|
-
isTextual: true,
|
|
3567
|
-
},
|
|
3568
|
-
"application/octet-stream": {},
|
|
3569
|
-
"application/pdf": {
|
|
3570
|
-
extensions: ["pdf"],
|
|
3571
|
-
},
|
|
3572
|
-
"application/xml": {
|
|
3573
|
-
extensions: ["xml"],
|
|
3574
|
-
isTextual: true,
|
|
3575
|
-
},
|
|
3576
|
-
"application/x-gzip": {
|
|
3577
|
-
extensions: ["gz"],
|
|
3578
|
-
},
|
|
3579
|
-
"application/wasm": {
|
|
3580
|
-
extensions: ["wasm"],
|
|
3581
|
-
},
|
|
3582
|
-
"application/zip": {
|
|
3583
|
-
extensions: ["zip"],
|
|
3584
|
-
},
|
|
3585
|
-
"audio/basic": {
|
|
3586
|
-
extensions: ["au", "snd"],
|
|
3587
|
-
},
|
|
3588
|
-
"audio/mpeg": {
|
|
3589
|
-
extensions: ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"],
|
|
3590
|
-
},
|
|
3591
|
-
"audio/midi": {
|
|
3592
|
-
extensions: ["midi", "mid", "kar", "rmi"],
|
|
3593
|
-
},
|
|
3594
|
-
"audio/mp4": {
|
|
3595
|
-
extensions: ["m4a", "mp4a"],
|
|
3596
|
-
},
|
|
3597
|
-
"audio/ogg": {
|
|
3598
|
-
extensions: ["oga", "ogg", "spx"],
|
|
3599
|
-
},
|
|
3600
|
-
"audio/webm": {
|
|
3601
|
-
extensions: ["weba"],
|
|
3602
|
-
},
|
|
3603
|
-
"audio/x-wav": {
|
|
3604
|
-
extensions: ["wav"],
|
|
3605
|
-
},
|
|
3606
|
-
"font/ttf": {
|
|
3607
|
-
extensions: ["ttf"],
|
|
3608
|
-
},
|
|
3609
|
-
"font/woff": {
|
|
3610
|
-
extensions: ["woff"],
|
|
3611
|
-
},
|
|
3612
|
-
"font/woff2": {
|
|
3613
|
-
extensions: ["woff2"],
|
|
3614
|
-
},
|
|
3615
|
-
"image/png": {
|
|
3616
|
-
extensions: ["png"],
|
|
3617
|
-
},
|
|
3618
|
-
"image/gif": {
|
|
3619
|
-
extensions: ["gif"],
|
|
3620
|
-
},
|
|
3621
|
-
"image/jpeg": {
|
|
3622
|
-
extensions: ["jpg"],
|
|
3623
|
-
},
|
|
3624
|
-
"image/svg+xml": {
|
|
3625
|
-
extensions: ["svg", "svgz"],
|
|
3626
|
-
isTextual: true,
|
|
3627
|
-
},
|
|
3628
|
-
"text/plain": {
|
|
3629
|
-
extensions: ["txt"],
|
|
3630
|
-
isTextual: true,
|
|
3631
|
-
},
|
|
3632
|
-
"text/html": {
|
|
3633
|
-
extensions: ["html"],
|
|
3634
|
-
isTextual: true,
|
|
3635
|
-
},
|
|
3636
|
-
"text/css": {
|
|
3637
|
-
extensions: ["css"],
|
|
3638
|
-
isTextual: true,
|
|
3639
|
-
},
|
|
3640
|
-
"text/javascript": {
|
|
3641
|
-
extensions: ["js", "cjs", "mjs", "ts", "jsx", "tsx"],
|
|
3642
|
-
isTextual: true,
|
|
3643
|
-
},
|
|
3644
|
-
"text/markdown": {
|
|
3645
|
-
extensions: ["md", "mdx"],
|
|
3646
|
-
isTextual: true,
|
|
3647
|
-
},
|
|
3648
|
-
"text/x-sass": {
|
|
3649
|
-
extensions: ["sass"],
|
|
3650
|
-
isTextual: true,
|
|
3651
|
-
},
|
|
3652
|
-
"text/x-scss": {
|
|
3653
|
-
extensions: ["scss"],
|
|
3654
|
-
isTextual: true,
|
|
3655
|
-
},
|
|
3656
|
-
"text/cache-manifest": {
|
|
3657
|
-
extensions: ["appcache"],
|
|
3658
|
-
},
|
|
3659
|
-
"video/mp4": {
|
|
3660
|
-
extensions: ["mp4", "mp4v", "mpg4"],
|
|
3661
|
-
},
|
|
3662
|
-
"video/mpeg": {
|
|
3663
|
-
extensions: ["mpeg", "mpg", "mpe", "m1v", "m2v"],
|
|
3664
|
-
},
|
|
3665
|
-
"video/ogg": {
|
|
3666
|
-
extensions: ["ogv"],
|
|
3667
|
-
},
|
|
3668
|
-
"video/webm": {
|
|
3669
|
-
extensions: ["webm"],
|
|
3670
|
-
},
|
|
3671
|
-
};
|
|
3672
|
-
|
|
3673
|
-
const CONTENT_TYPE = {
|
|
3674
|
-
parse: (string) => {
|
|
3675
|
-
const [mediaType, charset] = string.split(";");
|
|
3676
|
-
return { mediaType: normalizeMediaType(mediaType), charset };
|
|
3677
|
-
},
|
|
3678
|
-
|
|
3679
|
-
stringify: ({ mediaType, charset }) => {
|
|
3680
|
-
if (charset) {
|
|
3681
|
-
return `${mediaType};${charset}`;
|
|
3682
|
-
}
|
|
3683
|
-
return mediaType;
|
|
3684
|
-
},
|
|
3685
|
-
|
|
3686
|
-
asMediaType: (value) => {
|
|
3687
|
-
if (typeof value === "string") {
|
|
3688
|
-
return CONTENT_TYPE.parse(value).mediaType;
|
|
3689
|
-
}
|
|
3690
|
-
if (typeof value === "object") {
|
|
3691
|
-
return value.mediaType;
|
|
3692
|
-
}
|
|
3693
|
-
return null;
|
|
3694
|
-
},
|
|
3695
|
-
|
|
3696
|
-
isJson: (value) => {
|
|
3697
|
-
const mediaType = CONTENT_TYPE.asMediaType(value);
|
|
3698
|
-
return (
|
|
3699
|
-
mediaType === "application/json" ||
|
|
3700
|
-
/^application\/\w+\+json$/.test(mediaType)
|
|
3701
|
-
);
|
|
3702
|
-
},
|
|
3703
|
-
|
|
3704
|
-
isTextual: (value) => {
|
|
3705
|
-
const mediaType = CONTENT_TYPE.asMediaType(value);
|
|
3706
|
-
if (mediaType.startsWith("text/")) {
|
|
3707
|
-
return true;
|
|
3708
|
-
}
|
|
3709
|
-
const mediaTypeInfo = mediaTypeInfos[mediaType];
|
|
3710
|
-
if (mediaTypeInfo && mediaTypeInfo.isTextual) {
|
|
3711
|
-
return true;
|
|
3712
|
-
}
|
|
3713
|
-
// catch things like application/manifest+json, application/importmap+json
|
|
3714
|
-
if (/^application\/\w+\+json$/.test(mediaType)) {
|
|
3715
|
-
return true;
|
|
3716
|
-
}
|
|
3717
|
-
return false;
|
|
3718
|
-
},
|
|
3719
|
-
|
|
3720
|
-
isBinary: (value) => !CONTENT_TYPE.isTextual(value),
|
|
3721
|
-
|
|
3722
|
-
asFileExtension: (value) => {
|
|
3723
|
-
const mediaType = CONTENT_TYPE.asMediaType(value);
|
|
3724
|
-
const mediaTypeInfo = mediaTypeInfos[mediaType];
|
|
3725
|
-
return mediaTypeInfo ? `.${mediaTypeInfo.extensions[0]}` : "";
|
|
3726
|
-
},
|
|
3727
|
-
|
|
3728
|
-
fromUrlExtension: (url) => {
|
|
3729
|
-
const { pathname } = new URL(url);
|
|
3730
|
-
const extensionWithDot = extname(pathname);
|
|
3731
|
-
if (!extensionWithDot || extensionWithDot === ".") {
|
|
3732
|
-
return "application/octet-stream";
|
|
3733
|
-
}
|
|
3734
|
-
const extension = extensionWithDot.slice(1);
|
|
3735
|
-
const mediaTypeFound = Object.keys(mediaTypeInfos).find((mediaType) => {
|
|
3736
|
-
const mediaTypeInfo = mediaTypeInfos[mediaType];
|
|
3737
|
-
return (
|
|
3738
|
-
mediaTypeInfo.extensions && mediaTypeInfo.extensions.includes(extension)
|
|
3739
|
-
);
|
|
3740
|
-
});
|
|
3741
|
-
return mediaTypeFound || "application/octet-stream";
|
|
3742
|
-
},
|
|
3743
|
-
};
|
|
3744
|
-
|
|
3745
|
-
const normalizeMediaType = (value) => {
|
|
3746
|
-
if (value === "application/javascript") {
|
|
3747
|
-
return "text/javascript";
|
|
3748
|
-
}
|
|
3749
|
-
return value;
|
|
3750
|
-
};
|
|
3751
|
-
|
|
3752
3762
|
const ensureEmptyDirectory = async (source) => {
|
|
3753
3763
|
const stats = await readEntryStat(source, {
|
|
3754
3764
|
nullIfNotFound: true,
|
|
@@ -21777,8 +21787,10 @@ const defaultRuntimeCompat = {
|
|
|
21777
21787
|
* Use versioning on files written in the build directory
|
|
21778
21788
|
* @param {('search_param'|'filename')} [buildParameters.versioningMethod="search_param"]
|
|
21779
21789
|
* Controls how url are versioned in the build directory
|
|
21780
|
-
* @param {('none'|'inline'|'file'|'programmatic'} [buildParameters.sourcemaps="none"]
|
|
21790
|
+
* @param {('none'|'inline'|'file'|'programmatic')} [buildParameters.sourcemaps="none"]
|
|
21781
21791
|
* Generate sourcemaps in the build directory
|
|
21792
|
+
* @param {('error'|'copy'|'preserve')|function} [buildParameters.directoryReferenceEffect="error"]
|
|
21793
|
+
* What to do when a reference leads to a directory on the filesystem
|
|
21782
21794
|
* @return {Object} buildReturnValue
|
|
21783
21795
|
* @return {Object} buildReturnValue.buildInlineContents
|
|
21784
21796
|
* Contains content that is inline into build files
|
|
@@ -21825,6 +21837,8 @@ const build = async ({
|
|
|
21825
21837
|
outDirectoryUrl,
|
|
21826
21838
|
assetManifest = versioningMethod === "filename",
|
|
21827
21839
|
assetManifestFileRelativeUrl = "asset-manifest.json",
|
|
21840
|
+
returnBuildInlineContents,
|
|
21841
|
+
returnBuildManifest,
|
|
21828
21842
|
...rest
|
|
21829
21843
|
}) => {
|
|
21830
21844
|
// param validation
|
|
@@ -22349,8 +22363,8 @@ build ${entryPointKeys.length} entry points`);
|
|
|
22349
22363
|
}),
|
|
22350
22364
|
);
|
|
22351
22365
|
return {
|
|
22352
|
-
buildInlineContents,
|
|
22353
|
-
buildManifest,
|
|
22366
|
+
...(returnBuildInlineContents ? { buildInlineContents } : {}),
|
|
22367
|
+
...(returnBuildManifest ? { buildManifest } : {}),
|
|
22354
22368
|
};
|
|
22355
22369
|
};
|
|
22356
22370
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "39.2.
|
|
3
|
+
"version": "39.2.14",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"monorepo:publish": "node ./scripts/monorepo/publish_packages.mjs",
|
|
53
53
|
"monorepo:upgrade_versions": "node ./scripts/monorepo/upgrade_external_versions.mjs",
|
|
54
54
|
"monorepo:node_modules_clear": "npx @jsenv/snapshot clear **/node_modules/",
|
|
55
|
-
"
|
|
55
|
+
"md:build": "node ./md/build.js",
|
|
56
56
|
"performances": "node --expose-gc ./scripts/performance/generate_performance_report.mjs --log --once",
|
|
57
57
|
"build:file_size": "node ./scripts/build/build_file_size.mjs --log",
|
|
58
58
|
"prettier": "prettier --write .",
|
|
@@ -66,22 +66,22 @@
|
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
68
68
|
"@jsenv/abort": "4.3.0",
|
|
69
|
-
"@jsenv/ast": "6.2.
|
|
70
|
-
"@jsenv/filesystem": "4.9.
|
|
71
|
-
"@jsenv/humanize": "1.2.
|
|
69
|
+
"@jsenv/ast": "6.2.12",
|
|
70
|
+
"@jsenv/filesystem": "4.9.7",
|
|
71
|
+
"@jsenv/humanize": "1.2.7",
|
|
72
72
|
"@jsenv/importmap": "1.2.1",
|
|
73
73
|
"@jsenv/integrity": "0.0.2",
|
|
74
|
-
"@jsenv/js-module-fallback": "1.3.
|
|
74
|
+
"@jsenv/js-module-fallback": "1.3.33",
|
|
75
75
|
"@jsenv/node-esm-resolution": "1.0.2",
|
|
76
|
-
"@jsenv/plugin-bundling": "2.7.
|
|
76
|
+
"@jsenv/plugin-bundling": "2.7.4",
|
|
77
77
|
"@jsenv/plugin-minification": "1.5.5",
|
|
78
|
-
"@jsenv/plugin-supervisor": "1.5.
|
|
79
|
-
"@jsenv/plugin-transpilation": "1.4.
|
|
78
|
+
"@jsenv/plugin-supervisor": "1.5.13",
|
|
79
|
+
"@jsenv/plugin-transpilation": "1.4.17",
|
|
80
80
|
"@jsenv/runtime-compat": "1.3.1",
|
|
81
|
-
"@jsenv/server": "15.2.
|
|
82
|
-
"@jsenv/sourcemap": "1.2.
|
|
81
|
+
"@jsenv/server": "15.2.17",
|
|
82
|
+
"@jsenv/sourcemap": "1.2.21",
|
|
83
83
|
"@jsenv/url-meta": "8.5.0",
|
|
84
|
-
"@jsenv/urls": "2.
|
|
84
|
+
"@jsenv/urls": "2.5.1",
|
|
85
85
|
"@jsenv/utils": "2.1.2",
|
|
86
86
|
"anchor-markdown-header": "0.7.0"
|
|
87
87
|
},
|
package/src/build/build.js
CHANGED
|
@@ -78,8 +78,10 @@ export const defaultRuntimeCompat = {
|
|
|
78
78
|
* Use versioning on files written in the build directory
|
|
79
79
|
* @param {('search_param'|'filename')} [buildParameters.versioningMethod="search_param"]
|
|
80
80
|
* Controls how url are versioned in the build directory
|
|
81
|
-
* @param {('none'|'inline'|'file'|'programmatic'} [buildParameters.sourcemaps="none"]
|
|
81
|
+
* @param {('none'|'inline'|'file'|'programmatic')} [buildParameters.sourcemaps="none"]
|
|
82
82
|
* Generate sourcemaps in the build directory
|
|
83
|
+
* @param {('error'|'copy'|'preserve')|function} [buildParameters.directoryReferenceEffect="error"]
|
|
84
|
+
* What to do when a reference leads to a directory on the filesystem
|
|
83
85
|
* @return {Object} buildReturnValue
|
|
84
86
|
* @return {Object} buildReturnValue.buildInlineContents
|
|
85
87
|
* Contains content that is inline into build files
|
|
@@ -126,6 +128,8 @@ export const build = async ({
|
|
|
126
128
|
outDirectoryUrl,
|
|
127
129
|
assetManifest = versioningMethod === "filename",
|
|
128
130
|
assetManifestFileRelativeUrl = "asset-manifest.json",
|
|
131
|
+
returnBuildInlineContents,
|
|
132
|
+
returnBuildManifest,
|
|
129
133
|
...rest
|
|
130
134
|
}) => {
|
|
131
135
|
// param validation
|
|
@@ -652,8 +656,8 @@ build ${entryPointKeys.length} entry points`);
|
|
|
652
656
|
}),
|
|
653
657
|
);
|
|
654
658
|
return {
|
|
655
|
-
buildInlineContents,
|
|
656
|
-
buildManifest,
|
|
659
|
+
...(returnBuildInlineContents ? { buildInlineContents } : {}),
|
|
660
|
+
...(returnBuildManifest ? { buildManifest } : {}),
|
|
657
661
|
};
|
|
658
662
|
};
|
|
659
663
|
|