@jsenv/core 19.7.2 → 20.0.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/.DS_Store +0 -0
- package/dist/jsenv_compile_proxy.js +4 -11
- package/dist/jsenv_compile_proxy.js.map +5 -6
- package/dist/jsenv_exploring_redirector.js +4 -11
- package/dist/jsenv_exploring_redirector.js.map +5 -6
- package/dist/jsenv_toolbar.js +4 -11
- package/dist/jsenv_toolbar.js.map +5 -6
- package/{LICENSE → license} +0 -0
- package/main.js +0 -6
- package/package.json +3 -5
- package/src/buildProject.js +50 -49
- package/src/execute.js +4 -2
- package/src/executeTestPlan.js +4 -2
- package/src/internal/CONSTANTS.js +4 -4
- package/src/internal/building/buildUsingRollup.js +44 -36
- package/src/internal/building/createJsenvRollupPlugin.js +9 -9
- package/src/internal/building/css/postcss-urlhash-plugin.js +0 -8
- package/src/internal/building/html/parseHtmlAsset.js +13 -2
- package/src/internal/compiling/compileHtml.js +6 -2
- package/src/internal/compiling/startCompileServer.js +3 -13
- package/src/internal/executing/executePlan.js +3 -2
- package/src/internal/generateGroupMap/generateGroupMap.js +18 -75
- package/src/{jsenvBabelPluginCompatMap.js → internal/generateGroupMap/jsenvBabelPluginCompatMap.js} +2 -1
- package/src/{jsenvPluginCompatMap.js → internal/generateGroupMap/jsenvPluginCompatMap.js} +0 -0
- package/src/internal/generateGroupMap/jsenvRuntimeSupport.js +15 -0
- package/src/internal/generateGroupMap/one_runtime_compat.js +70 -0
- package/src/internal/generateGroupMap/runtime_compat.js +46 -0
- package/src/internal/generateGroupMap/runtime_compat_composition.js +86 -0
- package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +4 -0
- package/src/internal/runtime/resolveGroup.js +3 -3
- package/src/internal/semantic-versioning/index.js +2 -0
- package/src/internal/semantic-versioning/valueToVersion.js +1 -6
- package/src/jsenvRuntimeSupportDuringDev.js +12 -0
- package/src/launchBrowser.js +8 -3
- package/src/playwright_browser_versions.js +5 -0
- package/src/startExploring.js +4 -4
- package/src/convertCommonJsWithBabel.js +0 -72
- package/src/getBabelPluginMapForNode.js +0 -18
- package/src/internal/generateGroupMap/composeGroup.js +0 -54
- package/src/internal/generateGroupMap/composeGroupArray.js +0 -43
- package/src/internal/generateGroupMap/composeRuntimeCompatMap.js +0 -37
- package/src/internal/generateGroupMap/computeBabelPluginMapForRuntime.js +0 -64
- package/src/internal/generateGroupMap/computeJsenvPluginMapForRuntime.js +0 -62
- package/src/internal/generateGroupMap/generateAllRuntimeGroupArray.js +0 -22
- package/src/internal/generateGroupMap/generateRuntimeGroupArray.js +0 -91
- package/src/internal/generateGroupMap/groupHaveSameRequirements.js +0 -8
- package/src/internal/generateGroupMap/runtimeCompatMapToScore.js +0 -39
- package/src/jsenvBrowserScoreMap.js +0 -27
- package/src/jsenvNodeVersionScoreMap.js +0 -12
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
{ ┌──────────┴────────────┐
|
|
8
8
|
"transform-block-scoping": {─┐
|
|
9
9
|
"chrome": "10", │
|
|
10
|
-
"safari": "3.0",
|
|
10
|
+
"safari": "3.0", minRuntimeVersions
|
|
11
11
|
"firefox": "5.1" │
|
|
12
12
|
}────┼─────────┼───────────────┘
|
|
13
13
|
} │ └─────┐
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"babelPluginRequiredNameArray" : [
|
|
21
21
|
"transform-block-scoping",
|
|
22
22
|
],
|
|
23
|
-
"
|
|
23
|
+
"minRuntimeVersions": {
|
|
24
24
|
"chrome": "10",
|
|
25
25
|
"firefox": "6"
|
|
26
26
|
}
|
|
@@ -33,23 +33,16 @@ Take chars below to update legends
|
|
|
33
33
|
*/
|
|
34
34
|
|
|
35
35
|
import { COMPILE_ID_OTHERWISE, COMPILE_ID_BEST } from "../CONSTANTS.js"
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
36
|
+
import { jsenvBabelPluginCompatMap } from "./jsenvBabelPluginCompatMap.js"
|
|
37
|
+
import { createRuntimeCompat } from "./runtime_compat.js"
|
|
38
38
|
|
|
39
39
|
export const generateGroupMap = ({
|
|
40
40
|
babelPluginMap,
|
|
41
|
+
runtimeSupport,
|
|
42
|
+
babelPluginCompatMap = jsenvBabelPluginCompatMap,
|
|
41
43
|
// jsenv plugin are for later, for now, nothing is using them
|
|
42
44
|
jsenvPluginMap = {},
|
|
43
|
-
babelPluginCompatMap,
|
|
44
45
|
jsenvPluginCompatMap,
|
|
45
|
-
runtimeScoreMap,
|
|
46
|
-
groupCount = 1,
|
|
47
|
-
// pass this to true if you don't care if someone tries to run your code
|
|
48
|
-
// on a runtime which is not inside runtimeScoreMap.
|
|
49
|
-
runtimeAlwaysInsideRuntimeScoreMap = false,
|
|
50
|
-
// pass this to true if you think you will always be able to detect
|
|
51
|
-
// the runtime or that if you fail to do so you don't care.
|
|
52
|
-
runtimeWillAlwaysBeKnown = false,
|
|
53
46
|
}) => {
|
|
54
47
|
if (typeof babelPluginMap !== "object") {
|
|
55
48
|
throw new TypeError(
|
|
@@ -61,87 +54,40 @@ export const generateGroupMap = ({
|
|
|
61
54
|
`jsenvPluginMap must be an object, got ${jsenvPluginMap}`,
|
|
62
55
|
)
|
|
63
56
|
}
|
|
64
|
-
if (typeof
|
|
57
|
+
if (typeof runtimeSupport !== "object") {
|
|
65
58
|
throw new TypeError(
|
|
66
|
-
`
|
|
59
|
+
`runtimeSupport must be an object, got ${runtimeSupport}`,
|
|
67
60
|
)
|
|
68
61
|
}
|
|
69
|
-
if (typeof groupCount < 1) {
|
|
70
|
-
throw new TypeError(`groupCount must be above 1, got ${groupCount}`)
|
|
71
|
-
}
|
|
72
62
|
|
|
63
|
+
const runtimeNames = Object.keys(runtimeSupport)
|
|
73
64
|
babelPluginMap = withoutSyntaxPlugins(babelPluginMap)
|
|
74
65
|
|
|
75
66
|
const groupWithoutFeature = {
|
|
76
67
|
babelPluginRequiredNameArray: Object.keys(babelPluginMap),
|
|
77
68
|
jsenvPluginRequiredNameArray: Object.keys(jsenvPluginMap),
|
|
78
|
-
|
|
69
|
+
minRuntimeVersions: {},
|
|
79
70
|
}
|
|
80
|
-
|
|
81
|
-
// when we create one group and we cannot ensure
|
|
82
|
-
// code will be runned on a runtime inside runtimeScoreMap
|
|
83
|
-
// then we return otherwise group to be safe
|
|
84
|
-
if (groupCount === 1 && !runtimeAlwaysInsideRuntimeScoreMap) {
|
|
71
|
+
if (runtimeNames.length === 0) {
|
|
85
72
|
return {
|
|
86
73
|
[COMPILE_ID_OTHERWISE]: groupWithoutFeature,
|
|
87
74
|
}
|
|
88
75
|
}
|
|
89
76
|
|
|
90
|
-
const
|
|
77
|
+
const runtimeCompat = createRuntimeCompat({
|
|
78
|
+
runtimeSupport,
|
|
79
|
+
|
|
91
80
|
babelPluginMap,
|
|
92
81
|
babelPluginCompatMap,
|
|
82
|
+
|
|
93
83
|
jsenvPluginMap,
|
|
94
84
|
jsenvPluginCompatMap,
|
|
95
|
-
runtimeNames: arrayWithoutValue(Object.keys(runtimeScoreMap), "other"),
|
|
96
85
|
})
|
|
97
86
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
87
|
+
return {
|
|
88
|
+
[COMPILE_ID_BEST]: runtimeCompat,
|
|
89
|
+
[COMPILE_ID_OTHERWISE]: groupWithoutFeature,
|
|
102
90
|
}
|
|
103
|
-
|
|
104
|
-
const groupToScore = ({ runtimeCompatMap }) =>
|
|
105
|
-
runtimeCompatMapToScore(runtimeCompatMap, runtimeScoreMap)
|
|
106
|
-
|
|
107
|
-
const allRuntimeGroupArraySortedByScore = allRuntimeGroupArray.sort(
|
|
108
|
-
(a, b) => groupToScore(b) - groupToScore(a),
|
|
109
|
-
)
|
|
110
|
-
|
|
111
|
-
const length = allRuntimeGroupArraySortedByScore.length
|
|
112
|
-
|
|
113
|
-
// if we arrive here and want a single group
|
|
114
|
-
// we take the worst group and consider it's our best group
|
|
115
|
-
// because it's the lowest runtime we want to support
|
|
116
|
-
if (groupCount === 1) {
|
|
117
|
-
return {
|
|
118
|
-
[COMPILE_ID_BEST]: allRuntimeGroupArraySortedByScore[length - 1],
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const addOtherwiseToBeSafe =
|
|
123
|
-
!runtimeAlwaysInsideRuntimeScoreMap || !runtimeWillAlwaysBeKnown
|
|
124
|
-
|
|
125
|
-
const lastGroupIndex = addOtherwiseToBeSafe ? groupCount - 1 : groupCount
|
|
126
|
-
|
|
127
|
-
const groupArray =
|
|
128
|
-
length + 1 > groupCount
|
|
129
|
-
? allRuntimeGroupArraySortedByScore.slice(0, lastGroupIndex)
|
|
130
|
-
: allRuntimeGroupArraySortedByScore
|
|
131
|
-
|
|
132
|
-
const groupMap = {}
|
|
133
|
-
groupArray.forEach((group, index) => {
|
|
134
|
-
if (index === 0) {
|
|
135
|
-
groupMap[COMPILE_ID_BEST] = group
|
|
136
|
-
} else {
|
|
137
|
-
groupMap[`intermediate-${index + 1}`] = group
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
if (addOtherwiseToBeSafe) {
|
|
141
|
-
groupMap[COMPILE_ID_OTHERWISE] = groupWithoutFeature
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return groupMap
|
|
145
91
|
}
|
|
146
92
|
|
|
147
93
|
export const withoutSyntaxPlugins = (babelPluginMap) => {
|
|
@@ -154,6 +100,3 @@ export const withoutSyntaxPlugins = (babelPluginMap) => {
|
|
|
154
100
|
})
|
|
155
101
|
return babelPluginMapWithoutSyntaxPlugins
|
|
156
102
|
}
|
|
157
|
-
|
|
158
|
-
const arrayWithoutValue = (array, value) =>
|
|
159
|
-
array.filter((valueCandidate) => valueCandidate !== value)
|
package/src/{jsenvBabelPluginCompatMap.js → internal/generateGroupMap/jsenvBabelPluginCompatMap.js}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
1
2
|
// copied from
|
|
3
|
+
// https://github.com/babel/babel/blob/e498bee10f0123bb208baa228ce6417542a2c3c4/packages/babel-compat-data/data/plugins.json#L1
|
|
2
4
|
// https://github.com/babel/babel/blob/master/packages/babel-compat-data/data/plugins.json#L1
|
|
3
|
-
// now moved at https://github.com/babel/babel/blob/548cb3ee89552ffc08ee5625b084bd33f8107530/packages/babel-compat-data/data/plugins.json#L1
|
|
4
5
|
// Because this is an hidden implementation detail of @babel/preset-env
|
|
5
6
|
// it could be deprecated or moved anytime.
|
|
6
7
|
// For that reason it makes more sens to have it inlined here
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const jsenvBrowserRuntimeSupport = {
|
|
2
|
+
android: "0.0.0",
|
|
3
|
+
chrome: "0.0.0",
|
|
4
|
+
edge: "0.0.0",
|
|
5
|
+
electron: "0.0.0",
|
|
6
|
+
firefox: "0.0.0",
|
|
7
|
+
ios: "0.0.0",
|
|
8
|
+
opera: "0.0.0",
|
|
9
|
+
rhino: "0.0.0",
|
|
10
|
+
safari: "0.0.0",
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const jsenvNodeRuntimeSupport = {
|
|
14
|
+
node: "0.0.0",
|
|
15
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { findHighestVersion } from "../semantic-versioning/index.js"
|
|
2
|
+
import { jsenvBabelPluginCompatMap } from "./jsenvBabelPluginCompatMap.js"
|
|
3
|
+
import { jsenvPluginCompatMap as jsenvPluginCompatMapFallback } from "./jsenvPluginCompatMap.js"
|
|
4
|
+
|
|
5
|
+
export const createOneRuntimeCompat = ({
|
|
6
|
+
runtimeName,
|
|
7
|
+
runtimeVersion,
|
|
8
|
+
|
|
9
|
+
babelPluginMap,
|
|
10
|
+
babelPluginCompatMap = jsenvBabelPluginCompatMap,
|
|
11
|
+
|
|
12
|
+
jsenvPluginMap,
|
|
13
|
+
jsenvPluginCompatMap = jsenvPluginCompatMapFallback,
|
|
14
|
+
}) => {
|
|
15
|
+
const babelPluginRequiredNameArray = []
|
|
16
|
+
const jsenvPluginRequiredNameArray = []
|
|
17
|
+
// will be the first runtime version compatible with all features not listed in
|
|
18
|
+
// babelPluginRequiredNameArray or jsenvPluginRequiredNameArray
|
|
19
|
+
let minRuntimeVersion
|
|
20
|
+
|
|
21
|
+
Object.keys(babelPluginMap).forEach((babelPluginName) => {
|
|
22
|
+
const babelPluginCompat = babelPluginCompatMap[babelPluginName] || {}
|
|
23
|
+
const runtimeVersionCompatible =
|
|
24
|
+
babelPluginCompat[runtimeName] || "Infinity"
|
|
25
|
+
|
|
26
|
+
const highestVersion = findHighestVersion(
|
|
27
|
+
runtimeVersion,
|
|
28
|
+
runtimeVersionCompatible,
|
|
29
|
+
)
|
|
30
|
+
const compatible = highestVersion === runtimeVersion
|
|
31
|
+
if (!compatible) {
|
|
32
|
+
babelPluginRequiredNameArray.push(babelPluginName)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (compatible && runtimeVersionCompatible !== "Infinity") {
|
|
36
|
+
// there is a version from which runtime becomes compatible with this feature
|
|
37
|
+
minRuntimeVersion = findHighestVersion(
|
|
38
|
+
minRuntimeVersion || "0.0.0",
|
|
39
|
+
runtimeVersionCompatible,
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
Object.keys(jsenvPluginMap).forEach((jsenvPluginName) => {
|
|
45
|
+
const jsenvPluginCompat = jsenvPluginCompatMap[jsenvPluginName] || {}
|
|
46
|
+
const runtimeVersionCompatible =
|
|
47
|
+
jsenvPluginCompat[runtimeName] || "Infinity"
|
|
48
|
+
|
|
49
|
+
const highestVersion = findHighestVersion(
|
|
50
|
+
runtimeVersion,
|
|
51
|
+
runtimeVersionCompatible,
|
|
52
|
+
)
|
|
53
|
+
if (highestVersion === runtimeVersion) {
|
|
54
|
+
// compatible, in that case the min runtime version can be updated
|
|
55
|
+
minRuntimeVersion = findHighestVersion(
|
|
56
|
+
minRuntimeVersion || "0.0.0",
|
|
57
|
+
runtimeVersionCompatible,
|
|
58
|
+
)
|
|
59
|
+
} else {
|
|
60
|
+
// not compatible, no need to increase runtime version
|
|
61
|
+
jsenvPluginRequiredNameArray.push(jsenvPluginName)
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
babelPluginRequiredNameArray,
|
|
67
|
+
jsenvPluginRequiredNameArray,
|
|
68
|
+
minRuntimeVersion: minRuntimeVersion || runtimeVersion,
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createOneRuntimeCompat } from "./one_runtime_compat.js"
|
|
2
|
+
|
|
3
|
+
export const createRuntimeCompat = ({
|
|
4
|
+
runtimeSupport,
|
|
5
|
+
|
|
6
|
+
babelPluginMap,
|
|
7
|
+
babelPluginCompatMap,
|
|
8
|
+
|
|
9
|
+
jsenvPluginMap,
|
|
10
|
+
jsenvPluginCompatMap,
|
|
11
|
+
}) => {
|
|
12
|
+
const minRuntimeVersions = {}
|
|
13
|
+
const babelPluginRequiredNameArray = []
|
|
14
|
+
const jsenvPluginRequiredNameArray = []
|
|
15
|
+
Object.keys(runtimeSupport).forEach((runtimeName) => {
|
|
16
|
+
const runtimeVersion = runtimeSupport[runtimeName]
|
|
17
|
+
const oneRuntimeCompat = createOneRuntimeCompat({
|
|
18
|
+
runtimeName,
|
|
19
|
+
runtimeVersion,
|
|
20
|
+
|
|
21
|
+
babelPluginMap,
|
|
22
|
+
babelPluginCompatMap,
|
|
23
|
+
|
|
24
|
+
jsenvPluginMap,
|
|
25
|
+
jsenvPluginCompatMap,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
minRuntimeVersions[runtimeName] = oneRuntimeCompat.minRuntimeVersion
|
|
29
|
+
oneRuntimeCompat.babelPluginRequiredNameArray.forEach((babelPluginName) => {
|
|
30
|
+
if (!babelPluginRequiredNameArray.includes(babelPluginName)) {
|
|
31
|
+
babelPluginRequiredNameArray.push(babelPluginName)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
oneRuntimeCompat.jsenvPluginRequiredNameArray.forEach((jsenvPluginName) => {
|
|
35
|
+
if (!jsenvPluginRequiredNameArray.includes(jsenvPluginName)) {
|
|
36
|
+
jsenvPluginRequiredNameArray.push(jsenvPluginName)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
babelPluginRequiredNameArray,
|
|
43
|
+
jsenvPluginRequiredNameArray,
|
|
44
|
+
minRuntimeVersions,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { findHighestVersion } from "../semantic-versioning/index.js"
|
|
2
|
+
|
|
3
|
+
export const composeMinRuntimeVersions = (
|
|
4
|
+
firstMinRuntimeVersions,
|
|
5
|
+
secondMinRuntimeVersions,
|
|
6
|
+
) => {
|
|
7
|
+
const composed = {}
|
|
8
|
+
Object.keys(firstMinRuntimeVersions).forEach((runtimeName) => {
|
|
9
|
+
const firstRuntimeVersion = String(firstMinRuntimeVersions[runtimeName])
|
|
10
|
+
composed[runtimeName] = firstRuntimeVersion
|
|
11
|
+
})
|
|
12
|
+
Object.keys(secondMinRuntimeVersions).forEach((runtimeName) => {
|
|
13
|
+
const firstRuntimeVersion = composed[runtimeName]
|
|
14
|
+
const secondRuntimeVersion = String(secondMinRuntimeVersions[runtimeName])
|
|
15
|
+
composed[runtimeName] = firstRuntimeVersion
|
|
16
|
+
? findHighestVersion(firstRuntimeVersion, secondRuntimeVersion)
|
|
17
|
+
: secondRuntimeVersion
|
|
18
|
+
})
|
|
19
|
+
return sortObjectKeys(composed)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const sortObjectKeys = (object) => {
|
|
23
|
+
const sorted = {}
|
|
24
|
+
Object.keys(object)
|
|
25
|
+
.sort()
|
|
26
|
+
.forEach((key) => {
|
|
27
|
+
sorted[key] = object[key]
|
|
28
|
+
})
|
|
29
|
+
return sorted
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// export const composeRuntimeCompat = (...runtimeCompats) => {
|
|
33
|
+
// return runtimeCompats.reduce(runtimeCompatComposer, {
|
|
34
|
+
// babelPluginRequiredNameArray: [],
|
|
35
|
+
// jsenvPluginRequiredNameArray: [],
|
|
36
|
+
// runtimeCompatMap: {},
|
|
37
|
+
// })
|
|
38
|
+
// }
|
|
39
|
+
|
|
40
|
+
// const compositionMappingToStrictReducer = (compositionMapping) => {
|
|
41
|
+
// const propertyComposeStrict = (key, previous, current) => {
|
|
42
|
+
// const propertyExistInCurrent = key in current
|
|
43
|
+
// if (!propertyExistInCurrent) return previous[key]
|
|
44
|
+
|
|
45
|
+
// const propertyExistInPrevious = key in previous
|
|
46
|
+
// if (!propertyExistInPrevious) return current[key]
|
|
47
|
+
|
|
48
|
+
// const composeProperty = compositionMapping[key]
|
|
49
|
+
// return composeProperty(previous[key], current[key])
|
|
50
|
+
// }
|
|
51
|
+
|
|
52
|
+
// return (previous, current) => {
|
|
53
|
+
// if (typeof current !== "object" || current === null) return previous
|
|
54
|
+
|
|
55
|
+
// const composed = {}
|
|
56
|
+
// Object.keys(compositionMapping).forEach((key) => {
|
|
57
|
+
// composed[key] = propertyComposeStrict(key, previous, current)
|
|
58
|
+
// })
|
|
59
|
+
// return composed
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
62
|
+
|
|
63
|
+
// const runtimeCompatComposer = compositionMappingToStrictReducer({
|
|
64
|
+
// babelPluginRequiredNameArray: (
|
|
65
|
+
// babelPluginNamesPrevious,
|
|
66
|
+
// babelPluginNamesCurrent,
|
|
67
|
+
// ) => {
|
|
68
|
+
// return arrayWithoutDuplicate([
|
|
69
|
+
// ...babelPluginNamesPrevious,
|
|
70
|
+
// ...babelPluginNamesCurrent,
|
|
71
|
+
// ]).sort()
|
|
72
|
+
// },
|
|
73
|
+
// jsenvPluginRequiredNameArray: (
|
|
74
|
+
// jsenvPluginNamesPrevious,
|
|
75
|
+
// jsenvPluginNamesCurrent,
|
|
76
|
+
// ) => {
|
|
77
|
+
// return arrayWithoutDuplicate([
|
|
78
|
+
// ...jsenvPluginNamesPrevious,
|
|
79
|
+
// ...jsenvPluginNamesCurrent,
|
|
80
|
+
// ]).sort()
|
|
81
|
+
// },
|
|
82
|
+
// minRuntimeVersions: composeMinRuntimeVersions,
|
|
83
|
+
// })
|
|
84
|
+
|
|
85
|
+
// const arrayWithoutDuplicate = (array) =>
|
|
86
|
+
// array.filter((value, index) => array.indexOf(value) === index)
|
|
@@ -54,6 +54,10 @@ export const createNodeRuntime = async ({
|
|
|
54
54
|
|
|
55
55
|
const importJson = async (url) => {
|
|
56
56
|
const response = await fetchSource(url)
|
|
57
|
+
const status = response.status
|
|
58
|
+
if (status !== 200) {
|
|
59
|
+
throw new Error(`unexpected response status for ${url}, got ${status}`)
|
|
60
|
+
}
|
|
57
61
|
const object = await response.json()
|
|
58
62
|
return object
|
|
59
63
|
}
|
|
@@ -2,11 +2,11 @@ import { findHighestVersion } from "../semantic-versioning/index.js"
|
|
|
2
2
|
|
|
3
3
|
export const resolveGroup = ({ name, version }, groupMap) => {
|
|
4
4
|
return Object.keys(groupMap).find((compileIdCandidate) => {
|
|
5
|
-
const {
|
|
6
|
-
if (name in
|
|
5
|
+
const { minRuntimeVersions } = groupMap[compileIdCandidate]
|
|
6
|
+
if (name in minRuntimeVersions === false) {
|
|
7
7
|
return false
|
|
8
8
|
}
|
|
9
|
-
const versionForGroup =
|
|
9
|
+
const versionForGroup = minRuntimeVersions[name]
|
|
10
10
|
|
|
11
11
|
const highestVersion = findHighestVersion(version, versionForGroup)
|
|
12
12
|
return highestVersion === version
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { findLowestVersion } from "./findLowestVersion.js"
|
|
2
2
|
export { findHighestVersion } from "./findHighestVersion.js"
|
|
3
|
+
export { versionIsAbove } from "./versionIsAbove.js"
|
|
4
|
+
export { versionIsBelow } from "./versionIsBelow.js"
|
|
3
5
|
export { versionCompare } from "./versionCompare.js"
|
|
@@ -7,7 +7,7 @@ export const valueToVersion = (value) => {
|
|
|
7
7
|
return stringToVersion(value)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
throw new TypeError(
|
|
10
|
+
throw new TypeError(`version must be a number or a string, got ${value}`)
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const numberToVersion = (number) => {
|
|
@@ -42,8 +42,3 @@ const stringToVersion = (string) => {
|
|
|
42
42
|
patch: 0,
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
const createValueErrorMessage = ({
|
|
47
|
-
value,
|
|
48
|
-
}) => `value must be a number or a string.
|
|
49
|
-
value: ${value}`
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PLAYWRIGHT_CHROMIUM_VERSION,
|
|
3
|
+
PLAYWRIGHT_FIREFOX_VERSION,
|
|
4
|
+
PLAYWRIGHT_WEBKIT_VERSION,
|
|
5
|
+
} from "./playwright_browser_versions.js"
|
|
6
|
+
|
|
7
|
+
export const jsenvRuntimeSupportDuringDev = {
|
|
8
|
+
chrome: PLAYWRIGHT_CHROMIUM_VERSION,
|
|
9
|
+
firefox: PLAYWRIGHT_FIREFOX_VERSION,
|
|
10
|
+
safari: PLAYWRIGHT_WEBKIT_VERSION,
|
|
11
|
+
node: process.version.slice(1),
|
|
12
|
+
}
|
package/src/launchBrowser.js
CHANGED
|
@@ -13,6 +13,11 @@ import { validateResponseStatusIsOk } from "./internal/validateResponseStatusIsO
|
|
|
13
13
|
import { trackPageToNotify } from "./internal/browser-launcher/trackPageToNotify.js"
|
|
14
14
|
import { createSharing } from "./internal/browser-launcher/createSharing.js"
|
|
15
15
|
import { executeHtmlFile } from "./internal/browser-launcher/executeHtmlFile.js"
|
|
16
|
+
import {
|
|
17
|
+
PLAYWRIGHT_CHROMIUM_VERSION,
|
|
18
|
+
PLAYWRIGHT_FIREFOX_VERSION,
|
|
19
|
+
PLAYWRIGHT_WEBKIT_VERSION,
|
|
20
|
+
} from "./playwright_browser_versions.js"
|
|
16
21
|
|
|
17
22
|
const chromiumSharing = createSharing()
|
|
18
23
|
|
|
@@ -99,7 +104,7 @@ export const launchChromium = async ({
|
|
|
99
104
|
return {
|
|
100
105
|
browser,
|
|
101
106
|
runtimeName: "chromium",
|
|
102
|
-
runtimeVersion:
|
|
107
|
+
runtimeVersion: PLAYWRIGHT_CHROMIUM_VERSION,
|
|
103
108
|
stop: ressourceTracker.cleanup,
|
|
104
109
|
...browserToRuntimeHooks(browser, {
|
|
105
110
|
browserServerLogLevel,
|
|
@@ -175,7 +180,7 @@ export const launchFirefox = async ({
|
|
|
175
180
|
return {
|
|
176
181
|
browser,
|
|
177
182
|
runtimeName: "firefox",
|
|
178
|
-
runtimeVersion:
|
|
183
|
+
runtimeVersion: PLAYWRIGHT_FIREFOX_VERSION,
|
|
179
184
|
stop: ressourceTracker.cleanup,
|
|
180
185
|
...browserToRuntimeHooks(browser, {
|
|
181
186
|
browserServerLogLevel,
|
|
@@ -250,7 +255,7 @@ export const launchWebkit = async ({
|
|
|
250
255
|
return {
|
|
251
256
|
browser,
|
|
252
257
|
runtimeName: "webkit",
|
|
253
|
-
runtimeVersion:
|
|
258
|
+
runtimeVersion: PLAYWRIGHT_WEBKIT_VERSION,
|
|
254
259
|
stop: ressourceTracker.cleanup,
|
|
255
260
|
...browserToRuntimeHooks(browser, {
|
|
256
261
|
browserServerLogLevel,
|
package/src/startExploring.js
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
jsenvExploringIndexJsFileInfo,
|
|
29
29
|
jsenvToolbarJsFileInfo,
|
|
30
30
|
} from "./internal/jsenvInternalFiles.js"
|
|
31
|
+
import { jsenvRuntimeSupportDuringDev } from "./jsenvRuntimeSupportDuringDev.js"
|
|
31
32
|
|
|
32
33
|
export const startExploring = async ({
|
|
33
34
|
cancellationToken = createCancellationToken(),
|
|
@@ -36,12 +37,13 @@ export const startExploring = async ({
|
|
|
36
37
|
explorableConfig = jsenvExplorableConfig,
|
|
37
38
|
projectDirectoryUrl,
|
|
38
39
|
jsenvDirectoryRelativeUrl,
|
|
39
|
-
outDirectoryName,
|
|
40
|
+
outDirectoryName = 'out-dev',
|
|
40
41
|
jsenvToolbar = true,
|
|
41
42
|
livereloading = true,
|
|
42
43
|
inlineImportMapIntoHTML = true,
|
|
43
44
|
keepProcessAlive = true,
|
|
44
45
|
|
|
46
|
+
runtimeSupportDuringDev = jsenvRuntimeSupportDuringDev,
|
|
45
47
|
compileServerLogLevel,
|
|
46
48
|
compileServerCanReadFromFilesystem,
|
|
47
49
|
compileServerCanWriteOnFilesystem,
|
|
@@ -86,15 +88,12 @@ export const startExploring = async ({
|
|
|
86
88
|
cancellationToken,
|
|
87
89
|
projectDirectoryUrl,
|
|
88
90
|
keepProcessAlive,
|
|
89
|
-
cors: true,
|
|
90
91
|
livereloadSSE: livereloading,
|
|
91
92
|
accessControlAllowRequestOrigin: true,
|
|
92
93
|
accessControlAllowRequestMethod: true,
|
|
93
94
|
accessControlAllowRequestHeaders: true,
|
|
94
95
|
accessControlAllowCredentials: true,
|
|
95
96
|
stopOnPackageVersionChange: true,
|
|
96
|
-
watchAndSyncImportMap: true,
|
|
97
|
-
compileGroupCount: 2,
|
|
98
97
|
jsenvToolbarInjection: jsenvToolbar,
|
|
99
98
|
customServices: {
|
|
100
99
|
"service:exploring-redirect": (request) => redirectFiles(request),
|
|
@@ -108,6 +107,7 @@ export const startExploring = async ({
|
|
|
108
107
|
compileServerLogLevel,
|
|
109
108
|
compileServerCanReadFromFilesystem,
|
|
110
109
|
compileServerCanWriteOnFilesystem,
|
|
110
|
+
runtimeSupport: runtimeSupportDuringDev,
|
|
111
111
|
...rest,
|
|
112
112
|
})
|
|
113
113
|
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { require } from "./internal/require.js"
|
|
2
|
-
import { transformJs } from "./internal/compiling/js-compilation-service/transformJs.js"
|
|
3
|
-
import { babelPluginReplaceExpressions } from "./internal/babel-plugin-replace-expressions.js"
|
|
4
|
-
|
|
5
|
-
export const convertCommonJsWithBabel = async ({
|
|
6
|
-
projectDirectoryUrl,
|
|
7
|
-
code,
|
|
8
|
-
url,
|
|
9
|
-
replaceGlobalObject = true,
|
|
10
|
-
replaceGlobalFilename = true,
|
|
11
|
-
replaceGlobalDirname = true,
|
|
12
|
-
replaceProcessEnvNodeEnv = true,
|
|
13
|
-
processEnvNodeEnv = process.env.NODE_ENV,
|
|
14
|
-
replaceMap = {},
|
|
15
|
-
}) => {
|
|
16
|
-
const transformCommonJs = require("babel-plugin-transform-commonjs")
|
|
17
|
-
|
|
18
|
-
// maybe we should use babel core here instead of transformJs
|
|
19
|
-
const result = await transformJs({
|
|
20
|
-
projectDirectoryUrl,
|
|
21
|
-
code,
|
|
22
|
-
url,
|
|
23
|
-
babelPluginMap: {
|
|
24
|
-
"transform-commonjs": [transformCommonJs],
|
|
25
|
-
"transform-replace-expressions": [
|
|
26
|
-
babelPluginReplaceExpressions,
|
|
27
|
-
{
|
|
28
|
-
replaceMap: {
|
|
29
|
-
...(replaceProcessEnvNodeEnv
|
|
30
|
-
? { "process.env.NODE_ENV": `("${processEnvNodeEnv}")` }
|
|
31
|
-
: {}),
|
|
32
|
-
...(replaceGlobalObject ? { global: "globalThis" } : {}),
|
|
33
|
-
...(replaceGlobalFilename
|
|
34
|
-
? { __filename: __filenameReplacement }
|
|
35
|
-
: {}),
|
|
36
|
-
...(replaceGlobalDirname
|
|
37
|
-
? { __dirname: __dirnameReplacement }
|
|
38
|
-
: {}),
|
|
39
|
-
...replaceMap,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
},
|
|
44
|
-
})
|
|
45
|
-
return result
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const __filenameReplacement = `import.meta.url.slice('file:///'.length)`
|
|
49
|
-
|
|
50
|
-
const __dirnameReplacement = `import.meta.url.slice('file:///'.length).replace(/[\\\/\\\\][^\\\/\\\\]*$/, '')`
|
|
51
|
-
|
|
52
|
-
// const createInlineProcessNodeEnvBabelPlugin = ({ value = process.env.NODE_ENV }) => {
|
|
53
|
-
// return ({ types: t }) => {
|
|
54
|
-
// return {
|
|
55
|
-
// name: "inline-process-node-env",
|
|
56
|
-
// visitor: {
|
|
57
|
-
// MemberExpression(path) {
|
|
58
|
-
// if (path.matchesPattern("process.env.NODE_ENV")) {
|
|
59
|
-
// path.replaceWith(t.valueToNode(value))
|
|
60
|
-
|
|
61
|
-
// if (path.parentPath.isBinaryExpression()) {
|
|
62
|
-
// const evaluated = path.parentPath.evaluate()
|
|
63
|
-
// if (evaluated.confident) {
|
|
64
|
-
// path.parentPath.replaceWith(t.valueToNode(evaluated.value))
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
67
|
-
// }
|
|
68
|
-
// },
|
|
69
|
-
// },
|
|
70
|
-
// }
|
|
71
|
-
// }
|
|
72
|
-
// }
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { computeBabelPluginMapForRuntime } from "./internal/generateGroupMap/computeBabelPluginMapForRuntime.js"
|
|
2
|
-
import { jsenvBabelPluginMap } from "./jsenvBabelPluginMap.js"
|
|
3
|
-
|
|
4
|
-
export const getBabelPluginMapForNode = ({
|
|
5
|
-
babelPluginMap = jsenvBabelPluginMap,
|
|
6
|
-
nodeMinimumVersion = decideNodeMinimumVersion(),
|
|
7
|
-
} = {}) => {
|
|
8
|
-
const babelPluginMapForNode = computeBabelPluginMapForRuntime({
|
|
9
|
-
babelPluginMap,
|
|
10
|
-
runtimeName: "node",
|
|
11
|
-
runtimeVersion: nodeMinimumVersion,
|
|
12
|
-
})
|
|
13
|
-
return babelPluginMapForNode
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const decideNodeMinimumVersion = () => {
|
|
17
|
-
return process.version.slice(1)
|
|
18
|
-
}
|