@jsenv/core 39.1.1 → 39.1.3
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
|
@@ -12,20 +12,13 @@ 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
|
-
|
|
15
|
+
Now what do you want to do?
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- [Large browser support during dev](<https://github.com/jsenv/core/wiki/B)-Dev#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.
|
|
23
|
-
- [Large browser support after build](<https://github.com/jsenv/core/wiki/C)-Build#211-maximal-browser-support>). Because some product still needs to support old versions of Firefox, Chrome and Safari.
|
|
24
|
-
- [Single set of files after build](<https://github.com/jsenv/core/wiki/C)-Build#212-same-build-for-all-browsers>). Because a single one is simpler to properly support in every aspects.
|
|
25
|
-
- Versioning during build is robust and <a href="https://bundlers.tooling.report/hashing/avoid-cascade/" target="_blank">avoids cascading hash changes</a><sup>↗</sup>
|
|
26
|
-
- Advanced support of top level await, allowing to use it everywhere
|
|
27
|
-
- Advanced support of web workers including worker type module
|
|
28
|
-
- Unlock [js module features on a classic `<script>`](<https://github.com/jsenv/core/wiki/G)-Plugins#22-asjsclassic>).
|
|
17
|
+
| Scenario | Action |
|
|
18
|
+
| ----------------------------------------------------- | ---------------------------------------------------- |
|
|
19
|
+
| I want to try a demo on my machine | Go to [./demos](#demos) |
|
|
20
|
+
| I want to try jsenv on a project I have on my machine | Go to [./cli](#cli) |
|
|
21
|
+
| I want to learn how to use jsenv | Go to [./docs/users/users.md](./docs/users/users.md) |
|
|
29
22
|
|
|
30
23
|
# Demos
|
|
31
24
|
|
|
@@ -47,7 +40,7 @@ It will prompt to choose one of the available demo:
|
|
|
47
40
|
node-package
|
|
48
41
|
```
|
|
49
42
|
|
|
50
|
-
Selecting "web" will copy [create-jsenv/demo-web](
|
|
43
|
+
Selecting "web" will copy [create-jsenv/demo-web/](./packages/related/create-jsenv/demo-web/) files into a directory:
|
|
51
44
|
|
|
52
45
|
```console
|
|
53
46
|
✔ Select a demo: › web
|
|
@@ -63,10 +56,38 @@ After running the suggested commands the demo is ready.
|
|
|
63
56
|
|
|
64
57
|
The demo contains preconfigured scripts:
|
|
65
58
|
|
|
66
|
-
- `npm run dev`: starts a server for source files; Documented in [B) Dev](
|
|
67
|
-
- `npm run build`: generate build files; Documented in [C) Build](
|
|
68
|
-
- `npm run build:serve`: start a server for build files; Documented in [C) Build#how-to-serve-build-files](
|
|
69
|
-
- `npm run test`: execute test files; Documented in [D) Test](
|
|
59
|
+
- `npm run dev`: starts a server for source files; Documented in [B) Dev](./docs/users/b_dev/b_dev.md).
|
|
60
|
+
- `npm run build`: generate build files; Documented in [C) Build](./docs/users/c_build/c_build.md).
|
|
61
|
+
- `npm run build:serve`: start a server for build files; Documented in [C) Build#how-to-serve-build-files](./docs/users/c_build/c_build.md#3-how-to-serve-build-files).
|
|
62
|
+
- `npm run test`: execute test files; Documented in [D) Test](./docs/users/d_test/d_test.md).
|
|
63
|
+
|
|
64
|
+
# CLI
|
|
65
|
+
|
|
66
|
+
Jsenv commands to test it quickly.
|
|
67
|
+
|
|
68
|
+
| I want to | Command |
|
|
69
|
+
| ------------------------------------- | ------------------------ |
|
|
70
|
+
| Start a local server for source files | `npx @jsenv/cli dev` |
|
|
71
|
+
| Build source files into "./dist/" | `npx @jsenv/cli build` |
|
|
72
|
+
| Start a local server for build files | `npx @jsenv/cli preview` |
|
|
73
|
+
| Run all test files | `npx @jsenv/cli test` |
|
|
74
|
+
|
|
75
|
+
The commands are very basic, for advanced use cases you should use jsenv API.
|
|
76
|
+
|
|
77
|
+
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).
|
|
78
|
+
|
|
79
|
+
# The best parts
|
|
80
|
+
|
|
81
|
+
- Test files are [executed like standard files](./docs/users/d_test/d_test.md#14-executing-a-single-test)
|
|
82
|
+
- [Isolated environment](./docs/users/d_test/d_test.md#33-isolated-environment) for each test file
|
|
83
|
+
- Execute [tests in multiple browsers](./docs/users/d_test/d_test.md#32-execute-on-more-browsers>): Chrome, Safari, Firefox
|
|
84
|
+
- [Large browser support during dev](./docs/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.
|
|
85
|
+
- [Large browser support after build](./docs/users/c_build/c_build.md#211-maximal-browser-support). Because some product still needs to support old versions of Firefox, Chrome and Safari.
|
|
86
|
+
- [Single set of files after build](./docs/users/c_build/c_build.md#212-same-build-for-all-browsers). Because a single one is simpler to properly support in every aspects.
|
|
87
|
+
- Versioning during build is robust and <a href="https://bundlers.tooling.report/hashing/avoid-cascade/" target="_blank">avoids cascading hash changes</a><sup>↗</sup>
|
|
88
|
+
- Advanced support of top level await, allowing to use it everywhere
|
|
89
|
+
- Advanced support of web workers including worker type module
|
|
90
|
+
- Unlock [js module features on a classic `<script>`](./docs/users/g_plugins/g_plugins.md#22-asjsclassic>).
|
|
70
91
|
|
|
71
92
|
<!--
|
|
72
93
|
The following commands can be used to skip the prompt
|
package/dist/jsenv_core.js
CHANGED
|
@@ -13500,7 +13500,11 @@ const createUrlInfoTransformer = ({
|
|
|
13500
13500
|
if (!generatedUrl.startsWith("file:")) {
|
|
13501
13501
|
return;
|
|
13502
13502
|
}
|
|
13503
|
-
if (
|
|
13503
|
+
if (
|
|
13504
|
+
urlInfo.type === "directory" ||
|
|
13505
|
+
// happens when type is "html" to list directory content for example
|
|
13506
|
+
urlInfo.firstReference?.leadsToADirectory
|
|
13507
|
+
) {
|
|
13504
13508
|
// no need to write the directory
|
|
13505
13509
|
return;
|
|
13506
13510
|
}
|
|
@@ -18481,13 +18485,20 @@ const generateDirectoryContent = (
|
|
|
18481
18485
|
directoryUrl,
|
|
18482
18486
|
rootDirectoryUrl,
|
|
18483
18487
|
) => {
|
|
18484
|
-
|
|
18488
|
+
const sortedNames = [];
|
|
18489
|
+
for (const filename of directoryContentArray) {
|
|
18485
18490
|
const fileUrlObject = new URL(filename, directoryUrl);
|
|
18486
|
-
const fileUrl = String(fileUrlObject);
|
|
18487
|
-
let fileUrlRelative = urlToRelativeUrl(fileUrl, rootDirectoryUrl);
|
|
18488
18491
|
if (lstatSync(fileUrlObject).isDirectory()) {
|
|
18489
|
-
|
|
18492
|
+
sortedNames.push(`${filename}/`);
|
|
18493
|
+
} else {
|
|
18494
|
+
sortedNames.push(filename);
|
|
18490
18495
|
}
|
|
18496
|
+
}
|
|
18497
|
+
sortedNames.sort(comparePathnames);
|
|
18498
|
+
return sortedNames.map((filename) => {
|
|
18499
|
+
const fileUrlObject = new URL(filename, directoryUrl);
|
|
18500
|
+
const fileUrl = String(fileUrlObject);
|
|
18501
|
+
let fileUrlRelative = urlToRelativeUrl(fileUrl, rootDirectoryUrl);
|
|
18491
18502
|
return `<li>
|
|
18492
18503
|
<a href="/${fileUrlRelative}">/${fileUrlRelative}</a>
|
|
18493
18504
|
</li>`;
|
|
@@ -23129,6 +23140,7 @@ ${e.trace?.message}`);
|
|
|
23129
23140
|
logger.info(``);
|
|
23130
23141
|
return {
|
|
23131
23142
|
origin: server.origin,
|
|
23143
|
+
sourceDirectoryUrl,
|
|
23132
23144
|
stop: () => {
|
|
23133
23145
|
server.stop();
|
|
23134
23146
|
},
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "39.1.
|
|
3
|
+
"version": "39.1.3",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "dmail",
|
|
8
|
-
"email": "dmaillard06@gmail.com"
|
|
9
|
-
"url": "https://twitter.com/damienmaillard"
|
|
8
|
+
"email": "dmaillard06@gmail.com"
|
|
10
9
|
},
|
|
11
10
|
"repository": {
|
|
12
11
|
"type": "git",
|
|
@@ -66,22 +65,22 @@
|
|
|
66
65
|
"dependencies": {
|
|
67
66
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
68
67
|
"@jsenv/abort": "4.3.0",
|
|
69
|
-
"@jsenv/ast": "6.2.
|
|
70
|
-
"@jsenv/filesystem": "4.
|
|
71
|
-
"@jsenv/humanize": "1.2.
|
|
68
|
+
"@jsenv/ast": "6.2.2",
|
|
69
|
+
"@jsenv/filesystem": "4.8.0",
|
|
70
|
+
"@jsenv/humanize": "1.2.4",
|
|
72
71
|
"@jsenv/importmap": "1.2.1",
|
|
73
72
|
"@jsenv/integrity": "0.0.2",
|
|
74
|
-
"@jsenv/js-module-fallback": "1.3.
|
|
73
|
+
"@jsenv/js-module-fallback": "1.3.23",
|
|
75
74
|
"@jsenv/node-esm-resolution": "1.0.2",
|
|
76
|
-
"@jsenv/plugin-bundling": "2.6.
|
|
77
|
-
"@jsenv/plugin-minification": "1.5.
|
|
78
|
-
"@jsenv/plugin-supervisor": "1.5.
|
|
79
|
-
"@jsenv/plugin-transpilation": "1.4.
|
|
75
|
+
"@jsenv/plugin-bundling": "2.6.16",
|
|
76
|
+
"@jsenv/plugin-minification": "1.5.5",
|
|
77
|
+
"@jsenv/plugin-supervisor": "1.5.2",
|
|
78
|
+
"@jsenv/plugin-transpilation": "1.4.6",
|
|
80
79
|
"@jsenv/runtime-compat": "1.3.0",
|
|
81
|
-
"@jsenv/server": "15.2.
|
|
82
|
-
"@jsenv/sourcemap": "1.2.
|
|
80
|
+
"@jsenv/server": "15.2.13",
|
|
81
|
+
"@jsenv/sourcemap": "1.2.14",
|
|
83
82
|
"@jsenv/url-meta": "8.4.2",
|
|
84
|
-
"@jsenv/urls": "2.2.
|
|
83
|
+
"@jsenv/urls": "2.2.11",
|
|
85
84
|
"@jsenv/utils": "2.1.1"
|
|
86
85
|
},
|
|
87
86
|
"devDependencies": {
|
|
@@ -89,6 +88,7 @@
|
|
|
89
88
|
"@babel/plugin-syntax-import-attributes": "7.24.7",
|
|
90
89
|
"@babel/plugin-syntax-optional-chaining-assign": "7.24.7",
|
|
91
90
|
"@jsenv/assert": "./packages/independent/assert/",
|
|
91
|
+
"@jsenv/cli": "./packages/related/cli/",
|
|
92
92
|
"@jsenv/core": "./",
|
|
93
93
|
"@jsenv/eslint-config": "./packages/independent/eslint-config/",
|
|
94
94
|
"@jsenv/file-size-impact": "14.1.6",
|
|
@@ -98,17 +98,18 @@
|
|
|
98
98
|
"@jsenv/plugin-as-js-classic": "./packages/related/plugin-as-js-classic/",
|
|
99
99
|
"@jsenv/snapshot": "./packages/independent/snapshot/",
|
|
100
100
|
"@jsenv/test": "./packages/related/test/",
|
|
101
|
-
"@playwright/browser-chromium": "1.45.
|
|
102
|
-
"@playwright/browser-firefox": "1.45.
|
|
103
|
-
"@playwright/browser-webkit": "1.45.
|
|
101
|
+
"@playwright/browser-chromium": "1.45.2",
|
|
102
|
+
"@playwright/browser-firefox": "1.45.2",
|
|
103
|
+
"@playwright/browser-webkit": "1.45.2",
|
|
104
104
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
105
105
|
"eslint": "8.56.0",
|
|
106
106
|
"eslint-plugin-html": "8.1.1",
|
|
107
107
|
"eslint-plugin-import": "2.29.1",
|
|
108
|
-
"eslint-plugin-react": "7.34.
|
|
108
|
+
"eslint-plugin-react": "7.34.4",
|
|
109
109
|
"eslint-plugin-regexp": "2.6.0",
|
|
110
|
+
"marked": "13.0.2",
|
|
110
111
|
"open": "10.1.0",
|
|
111
|
-
"playwright": "1.45.
|
|
112
|
-
"prettier": "3.3.
|
|
112
|
+
"playwright": "1.45.2",
|
|
113
|
+
"prettier": "3.3.3"
|
|
113
114
|
}
|
|
114
115
|
}
|
|
@@ -268,7 +268,11 @@ export const createUrlInfoTransformer = ({
|
|
|
268
268
|
if (!generatedUrl.startsWith("file:")) {
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
|
-
if (
|
|
271
|
+
if (
|
|
272
|
+
urlInfo.type === "directory" ||
|
|
273
|
+
// happens when type is "html" to list directory content for example
|
|
274
|
+
urlInfo.firstReference?.leadsToADirectory
|
|
275
|
+
) {
|
|
272
276
|
// no need to write the directory
|
|
273
277
|
return;
|
|
274
278
|
}
|
|
@@ -19,7 +19,10 @@ import {
|
|
|
19
19
|
} from "@jsenv/node-esm-resolution";
|
|
20
20
|
import { pickContentType } from "@jsenv/server";
|
|
21
21
|
import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
assertAndNormalizeDirectoryUrl,
|
|
24
|
+
comparePathnames,
|
|
25
|
+
} from "@jsenv/filesystem";
|
|
23
26
|
|
|
24
27
|
const html404AndParentDirIsEmptyFileUrl = new URL(
|
|
25
28
|
"./html_404_and_parent_dir_is_empty.html",
|
|
@@ -352,13 +355,20 @@ const generateDirectoryContent = (
|
|
|
352
355
|
directoryUrl,
|
|
353
356
|
rootDirectoryUrl,
|
|
354
357
|
) => {
|
|
355
|
-
|
|
358
|
+
const sortedNames = [];
|
|
359
|
+
for (const filename of directoryContentArray) {
|
|
356
360
|
const fileUrlObject = new URL(filename, directoryUrl);
|
|
357
|
-
const fileUrl = String(fileUrlObject);
|
|
358
|
-
let fileUrlRelative = urlToRelativeUrl(fileUrl, rootDirectoryUrl);
|
|
359
361
|
if (lstatSync(fileUrlObject).isDirectory()) {
|
|
360
|
-
|
|
362
|
+
sortedNames.push(`${filename}/`);
|
|
363
|
+
} else {
|
|
364
|
+
sortedNames.push(filename);
|
|
361
365
|
}
|
|
366
|
+
}
|
|
367
|
+
sortedNames.sort(comparePathnames);
|
|
368
|
+
return sortedNames.map((filename) => {
|
|
369
|
+
const fileUrlObject = new URL(filename, directoryUrl);
|
|
370
|
+
const fileUrl = String(fileUrlObject);
|
|
371
|
+
let fileUrlRelative = urlToRelativeUrl(fileUrl, rootDirectoryUrl);
|
|
362
372
|
return `<li>
|
|
363
373
|
<a href="/${fileUrlRelative}">/${fileUrlRelative}</a>
|
|
364
374
|
</li>`;
|