@jsenv/core 22.0.1 → 22.0.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.3",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"@babel/helpers": "7.15.4",
|
|
58
58
|
"@babel/parser": "7.15.7",
|
|
59
59
|
"@babel/plugin-proposal-dynamic-import": "7.14.5",
|
|
60
|
-
"@babel/plugin-transform-modules-systemjs": "7.15.4",
|
|
61
60
|
"@babel/plugin-syntax-dynamic-import": "7.8.3",
|
|
62
61
|
"@babel/plugin-syntax-import-meta": "7.10.4",
|
|
63
62
|
"@babel/plugin-syntax-numeric-separator": "7.10.4",
|
|
63
|
+
"@babel/plugin-transform-modules-systemjs": "7.15.4",
|
|
64
64
|
"@c88/v8-coverage": "0.1.1",
|
|
65
65
|
"@jsenv/cancellation": "3.0.0",
|
|
66
66
|
"@jsenv/filesystem": "2.2.0",
|
|
@@ -69,11 +69,11 @@
|
|
|
69
69
|
"@jsenv/node-signals": "2.0.1",
|
|
70
70
|
"@jsenv/server": "7.2.0",
|
|
71
71
|
"@jsenv/uneval": "1.6.0",
|
|
72
|
-
"@rollup/plugin-commonjs": "
|
|
72
|
+
"@rollup/plugin-commonjs": "21.0.0",
|
|
73
73
|
"@rollup/plugin-json": "4.1.0",
|
|
74
74
|
"@rollup/plugin-node-resolve": "13.0.5",
|
|
75
75
|
"@rollup/plugin-replace": "3.0.0",
|
|
76
|
-
"ansi-to-html": "0.7.
|
|
76
|
+
"ansi-to-html": "0.7.2",
|
|
77
77
|
"babel-plugin-transform-async-to-promises": "0.8.15",
|
|
78
78
|
"bytes": "3.1.0",
|
|
79
79
|
"cjs-module-lexer": "1.2.2",
|
|
@@ -92,13 +92,14 @@
|
|
|
92
92
|
"magic-string": "0.25.7",
|
|
93
93
|
"parse5": "6.0.1",
|
|
94
94
|
"playwright": "1.15.1",
|
|
95
|
-
"postcss": "8.3.
|
|
95
|
+
"postcss": "8.3.9",
|
|
96
96
|
"postcss-value-parser": "4.1.0",
|
|
97
97
|
"regenerator-runtime": "0.13.9",
|
|
98
98
|
"resolve": "1.20.0",
|
|
99
|
-
"rollup": "2.
|
|
99
|
+
"rollup": "2.58.0",
|
|
100
100
|
"rollup-plugin-node-builtins-brofs": "2.1.3",
|
|
101
101
|
"rollup-plugin-node-globals": "1.4.0",
|
|
102
|
+
"rollup-plugin-polyfill-node": "0.7.0",
|
|
102
103
|
"source-map": "0.7.3",
|
|
103
104
|
"string-width": "5.0.1",
|
|
104
105
|
"supports-color": "9.0.2",
|
|
@@ -134,22 +135,22 @@
|
|
|
134
135
|
"@babel/plugin-transform-new-target": "7.14.5",
|
|
135
136
|
"@babel/plugin-transform-object-super": "7.14.5",
|
|
136
137
|
"@babel/plugin-transform-parameters": "7.15.4",
|
|
138
|
+
"@babel/plugin-transform-react-jsx": "7.14.9",
|
|
137
139
|
"@babel/plugin-transform-regenerator": "7.14.5",
|
|
138
140
|
"@babel/plugin-transform-shorthand-properties": "7.14.5",
|
|
139
141
|
"@babel/plugin-transform-spread": "7.14.6",
|
|
140
142
|
"@babel/plugin-transform-sticky-regex": "7.14.5",
|
|
141
143
|
"@babel/plugin-transform-template-literals": "7.14.5",
|
|
142
144
|
"@babel/plugin-transform-typeof-symbol": "7.14.5",
|
|
143
|
-
"@babel/plugin-transform-unicode-regex": "7.14.5",
|
|
144
|
-
"@babel/plugin-transform-react-jsx": "7.14.9",
|
|
145
145
|
"@babel/plugin-transform-typescript": "7.15.4",
|
|
146
|
+
"@babel/plugin-transform-unicode-regex": "7.14.5",
|
|
146
147
|
"@babel/preset-env": "7.15.6",
|
|
147
148
|
"@jsenv/assert": "2.3.1",
|
|
148
149
|
"@jsenv/codecov-upload": "3.5.0",
|
|
149
|
-
"@jsenv/eslint-config": "16.0.
|
|
150
|
+
"@jsenv/eslint-config": "16.0.6",
|
|
150
151
|
"@jsenv/github-release-package": "1.2.3",
|
|
151
152
|
"@jsenv/importmap-eslint-resolver": "5.1.2",
|
|
152
|
-
"@jsenv/importmap-node-module": "2.
|
|
153
|
+
"@jsenv/importmap-node-module": "2.3.1",
|
|
153
154
|
"@jsenv/package-publish": "1.6.2",
|
|
154
155
|
"@jsenv/performance-impact": "1.7.0",
|
|
155
156
|
"@jsenv/prettier-check-project": "5.6.1",
|
package/readme.md
CHANGED
|
@@ -330,23 +330,66 @@ npm install --save-dev @jsenv/core
|
|
|
330
330
|
|
|
331
331
|
Jsenv can execute standard JavaScript and be configured to run non-standard JavaScript.
|
|
332
332
|
|
|
333
|
-
|
|
333
|
+
_non-standard JavaScript examples:_
|
|
334
334
|
|
|
335
|
-
|
|
335
|
+
- [CommonJS modules](https://code-trotter.com/web/understand-the-different-javascript-modules-formats/#commonjs-cjs)
|
|
336
|
+
- [JSX](https://reactjs.org/docs/introducing-jsx.html)
|
|
336
337
|
|
|
337
338
|
> Keep in mind one of your dependency may use non-standard JavaScript. For instance react uses CommonJS modules.
|
|
338
339
|
|
|
339
340
|
## jsenv.config.mjs
|
|
340
341
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
To get a better idea see [jsenv.config.js](./jsenv.config.js). The file can be imported and passed using the spread operator. This technic helps to see jsenv custom configuration quickly and share it between files.
|
|
342
|
+
Jsenv codebase regroups configuration in a top level [jsenv.config.mjs](./jsenv.config.js) file.
|
|
343
|
+
The file is meant to be imported and passed using the spread operator.
|
|
344
344
|
|
|
345
345
|

|
|
346
346
|
|
|
347
347
|
— See [script/test/test.js](https://github.com/jsenv/jsenv-core/blob/e44e362241e8e2142010322cb4552983b3bc9744/script/test/test.js#L2)
|
|
348
348
|
|
|
349
|
-
|
|
349
|
+
This technic helps to see jsenv custom configuration quickly and share it between files. That being said you are free to organize your configuration as you want.
|
|
350
|
+
|
|
351
|
+
## babel.config.cjs
|
|
352
|
+
|
|
353
|
+
When code needs to be transformed, the project must contain a [babel config file](https://babeljs.io/docs/en/config-files).
|
|
354
|
+
|
|
355
|
+
There is 2 scenarios where it happens:
|
|
356
|
+
|
|
357
|
+
- Code needs to be compatible with old browsers
|
|
358
|
+
- Code is not standard (jsx for instance)
|
|
359
|
+
|
|
360
|
+
In that case, it's recommended to use the following babel plugins declared in `babel.config.cjs`
|
|
361
|
+
|
|
362
|
+
```js
|
|
363
|
+
/*
|
|
364
|
+
* This file is used to configure a list of babel plugins as documented in
|
|
365
|
+
* https://babeljs.io/docs/en/config-files
|
|
366
|
+
*
|
|
367
|
+
* During dev: babel plugins natively supported by browsers and Node.js are not used.
|
|
368
|
+
* During build:
|
|
369
|
+
* - When "runtimeSupport" is configured, babel plugins already supported by these runtime won't be used
|
|
370
|
+
* See https://github.com/jsenv/jsenv-template-pwa/blob/main/jsenv.config.mjs#L12
|
|
371
|
+
* - Otherwise all babel plugins are use
|
|
372
|
+
*
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
// "@babel/preset-env" transforms async function to generators
|
|
376
|
+
// but it's verbose and slow compared to using promises, so we:
|
|
377
|
+
// 1. Exclude "transform-async-to-generator", "transform-regenerator"
|
|
378
|
+
// 2. Enable "babel-plugin-transform-async-to-promises"
|
|
379
|
+
// See https://github.com/babel/babel/issues/8121
|
|
380
|
+
module.exports = {
|
|
381
|
+
presets: [
|
|
382
|
+
[
|
|
383
|
+
"@babel/preset-env",
|
|
384
|
+
{
|
|
385
|
+
modules: false,
|
|
386
|
+
exclude: ["transform-async-to-generator", "transform-regenerator"],
|
|
387
|
+
},
|
|
388
|
+
],
|
|
389
|
+
],
|
|
390
|
+
plugins: ["babel-plugin-transform-async-to-promises"],
|
|
391
|
+
}
|
|
392
|
+
```
|
|
350
393
|
|
|
351
394
|
## CommonJS
|
|
352
395
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
/* eslint-disable import/max-dependencies */
|
|
2
1
|
import { urlToFileSystemPath, resolveUrl } from "@jsenv/filesystem"
|
|
3
2
|
|
|
4
|
-
import { require } from "@jsenv/core/src/internal/require.js"
|
|
5
3
|
import { transformResultToCompilationResult } from "@jsenv/core/src/internal/compiling/transformResultToCompilationResult.js"
|
|
6
4
|
import { rollupPluginCommonJsNamedExports } from "@jsenv/core/src/internal/compiling/rollup_plugin_commonjs_named_exports.js"
|
|
7
5
|
|
|
@@ -44,6 +42,7 @@ export const commonJsToJavaScriptModule = async ({
|
|
|
44
42
|
"main",
|
|
45
43
|
],
|
|
46
44
|
extensions: [".mjs", ".cjs", ".js", ".json"],
|
|
45
|
+
preferBuiltins: false,
|
|
47
46
|
exportConditions: [],
|
|
48
47
|
})
|
|
49
48
|
|
|
@@ -97,8 +96,9 @@ export const commonJsToJavaScriptModule = async ({
|
|
|
97
96
|
logger,
|
|
98
97
|
})
|
|
99
98
|
|
|
100
|
-
const
|
|
101
|
-
|
|
99
|
+
const { default: rollupPluginNodePolyfills } = await import(
|
|
100
|
+
"rollup-plugin-polyfill-node"
|
|
101
|
+
)
|
|
102
102
|
|
|
103
103
|
const { rollup } = await import("rollup")
|
|
104
104
|
const rollupBuild = await rollup({
|
|
@@ -112,8 +112,33 @@ export const commonJsToJavaScriptModule = async ({
|
|
|
112
112
|
commonJsRollupPlugin,
|
|
113
113
|
commonJsNamedExportsRollupPlugin,
|
|
114
114
|
nodeGlobalRollupPlugin,
|
|
115
|
-
...(convertBuiltinsToBrowser
|
|
115
|
+
...(convertBuiltinsToBrowser
|
|
116
|
+
? [
|
|
117
|
+
rollupPluginNodePolyfills({
|
|
118
|
+
include: null,
|
|
119
|
+
}),
|
|
120
|
+
]
|
|
121
|
+
: []),
|
|
116
122
|
],
|
|
123
|
+
onwarn: (warning) => {
|
|
124
|
+
const { loc, message } = warning
|
|
125
|
+
const logMessage = loc
|
|
126
|
+
? `${loc.file}:${loc.line}:${loc.column} ${message}`
|
|
127
|
+
: message
|
|
128
|
+
|
|
129
|
+
// These warnings are usually harmless in packages, so don't show them by default
|
|
130
|
+
if (
|
|
131
|
+
warning.code === "CIRCULAR_DEPENDENCY" ||
|
|
132
|
+
warning.code === "NAMESPACE_CONFLICT" ||
|
|
133
|
+
warning.code === "THIS_IS_UNDEFINED" ||
|
|
134
|
+
warning.code === "EMPTY_BUNDLE" ||
|
|
135
|
+
warning.code === "UNUSED_EXTERNAL_IMPORT"
|
|
136
|
+
) {
|
|
137
|
+
logger.debug(logMessage)
|
|
138
|
+
} else {
|
|
139
|
+
logger.warn(logMessage)
|
|
140
|
+
}
|
|
141
|
+
},
|
|
117
142
|
})
|
|
118
143
|
|
|
119
144
|
const generateOptions = {
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { require } from "@jsenv/core/src/internal/require.js"
|
|
2
2
|
|
|
3
|
+
export const babelPluginNamesToRemoveFromBest = [
|
|
4
|
+
"proposal-private-property-in-object",
|
|
5
|
+
"proposal-logical-assignment-operators",
|
|
6
|
+
"proposal-export-namespace-from",
|
|
7
|
+
"proposal-class-properties",
|
|
8
|
+
"proposal-private-methods",
|
|
9
|
+
"transform-named-capturing-groups-regex",
|
|
10
|
+
]
|
|
11
|
+
|
|
3
12
|
export const getMinimalBabelPluginMap = () => {
|
|
4
13
|
const syntaxDynamicImport = require("@babel/plugin-syntax-dynamic-import")
|
|
5
14
|
const syntaxImportMeta = require("@babel/plugin-syntax-import-meta")
|
|
@@ -29,7 +29,10 @@ import {
|
|
|
29
29
|
} from "@jsenv/filesystem"
|
|
30
30
|
|
|
31
31
|
import { loadBabelPluginMapFromFile } from "./load_babel_plugin_map_from_file.js"
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
extractSyntaxBabelPluginMap,
|
|
34
|
+
babelPluginNamesToRemoveFromBest,
|
|
35
|
+
} from "./babel_plugins.js"
|
|
33
36
|
import { generateGroupMap } from "../generateGroupMap/generateGroupMap.js"
|
|
34
37
|
import { createCallbackList } from "../createCallbackList.js"
|
|
35
38
|
import {
|
|
@@ -165,6 +168,22 @@ export const startCompileServer = async ({
|
|
|
165
168
|
runtimeSupport,
|
|
166
169
|
})
|
|
167
170
|
|
|
171
|
+
const { best } = compileServerGroupMap
|
|
172
|
+
if (best) {
|
|
173
|
+
// here it's just that @babel/preset-env is a bit aggressive in the list of babel plugins
|
|
174
|
+
// that it enables
|
|
175
|
+
// we don't want to end up transforming code that could run without any compile step
|
|
176
|
+
// ideally we should maintain our own babel preset list
|
|
177
|
+
// (would just be the jsenvBabelPluginMap)
|
|
178
|
+
// so that we have the correct list of babel plugins
|
|
179
|
+
// and we are not forced to remove some of them
|
|
180
|
+
// we should also fix the node system not working anymore
|
|
181
|
+
best.babelPluginRequiredNameArray =
|
|
182
|
+
best.babelPluginRequiredNameArray.filter((babelPluginName) => {
|
|
183
|
+
return !babelPluginNamesToRemoveFromBest.includes(babelPluginName)
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
168
187
|
babelPluginMap = {
|
|
169
188
|
"transform-replace-expressions": [
|
|
170
189
|
babelPluginReplaceExpressions,
|