@jsenv/core 27.0.0-alpha.37 → 27.0.0-alpha.38
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": "27.0.0-alpha.
|
|
3
|
+
"version": "27.0.0-alpha.38",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@jsenv/integrity": "0.0.1",
|
|
66
66
|
"@jsenv/log": "1.5.2",
|
|
67
67
|
"@jsenv/logger": "4.0.1",
|
|
68
|
-
"@jsenv/node-esm-resolution": "0.0.
|
|
68
|
+
"@jsenv/node-esm-resolution": "0.0.6",
|
|
69
69
|
"@jsenv/server": "12.6.1",
|
|
70
70
|
"@jsenv/uneval": "1.6.0",
|
|
71
71
|
"@jsenv/utils": "1.5.0",
|
package/src/build/build.js
CHANGED
|
@@ -7,25 +7,91 @@
|
|
|
7
7
|
* it should likely be an other plugin happening after the others
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
+
import { registerFileLifecycle } from "@jsenv/filesystem"
|
|
11
|
+
|
|
10
12
|
import {
|
|
11
13
|
applyNodeEsmResolution,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
defaultLookupPackageScope,
|
|
15
|
+
defaultReadPackageJson,
|
|
14
16
|
} from "@jsenv/node-esm-resolution"
|
|
15
17
|
|
|
16
18
|
export const jsenvPluginNodeEsmResolution = ({
|
|
19
|
+
rootDirectoryUrl,
|
|
17
20
|
// https://nodejs.org/api/esm.html#resolver-algorithm-specification
|
|
18
21
|
packageConditions = ["browser", "import"],
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
filesInvalidatingCache = ["package.json", "package-lock.json"],
|
|
23
|
+
}) => {
|
|
24
|
+
const packageScopesCache = new Map()
|
|
25
|
+
const lookupPackageScope = (url) => {
|
|
26
|
+
const fromCache = packageScopesCache.get(url)
|
|
27
|
+
if (fromCache) {
|
|
28
|
+
return fromCache
|
|
29
|
+
}
|
|
30
|
+
const packageScope = defaultLookupPackageScope(url)
|
|
31
|
+
packageScopesCache.set(url, packageScope)
|
|
32
|
+
return packageScope
|
|
33
|
+
}
|
|
34
|
+
const packageJsonsCache = new Map()
|
|
35
|
+
const readPackageJson = (url) => {
|
|
36
|
+
const fromCache = packageJsonsCache.get(url)
|
|
37
|
+
if (fromCache) {
|
|
38
|
+
return fromCache
|
|
39
|
+
}
|
|
40
|
+
const packageJson = defaultReadPackageJson(url)
|
|
41
|
+
packageJsonsCache.set(url, packageJson)
|
|
42
|
+
return packageJson
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const unregisters = []
|
|
46
|
+
filesInvalidatingCache.forEach((file) => {
|
|
47
|
+
const unregister = registerFileLifecycle(new URL(file, rootDirectoryUrl), {
|
|
48
|
+
added: () => {
|
|
49
|
+
packageScopesCache.clear()
|
|
50
|
+
packageJsonsCache.clear()
|
|
51
|
+
},
|
|
52
|
+
updated: () => {
|
|
53
|
+
packageScopesCache.clear()
|
|
54
|
+
packageJsonsCache.clear()
|
|
55
|
+
},
|
|
56
|
+
removed: () => {
|
|
57
|
+
packageScopesCache.clear()
|
|
58
|
+
packageJsonsCache.clear()
|
|
59
|
+
},
|
|
60
|
+
keepProcessAlive: false,
|
|
61
|
+
})
|
|
62
|
+
unregisters.push(unregister)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return [
|
|
66
|
+
jsenvPluginNodeEsmResolver({
|
|
67
|
+
packageConditions,
|
|
68
|
+
lookupPackageScope,
|
|
69
|
+
readPackageJson,
|
|
70
|
+
}),
|
|
71
|
+
jsenvPluginNodeModulesVersionInUrls({
|
|
72
|
+
lookupPackageScope,
|
|
73
|
+
readPackageJson,
|
|
74
|
+
}),
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const jsenvPluginNodeEsmResolver = ({
|
|
79
|
+
packageConditions,
|
|
80
|
+
lookupPackageScope,
|
|
81
|
+
readPackageJson,
|
|
82
|
+
}) => {
|
|
83
|
+
return {
|
|
21
84
|
name: "jsenv:node_esm_resolve",
|
|
22
85
|
appliesDuring: "*",
|
|
23
86
|
resolveUrl: {
|
|
24
87
|
js_import_export: (reference) => {
|
|
88
|
+
const { parentUrl, specifier } = reference
|
|
25
89
|
const { url } = applyNodeEsmResolution({
|
|
26
90
|
conditions: packageConditions,
|
|
27
|
-
parentUrl
|
|
28
|
-
specifier
|
|
91
|
+
parentUrl,
|
|
92
|
+
specifier,
|
|
93
|
+
lookupPackageScope,
|
|
94
|
+
readPackageJson,
|
|
29
95
|
})
|
|
30
96
|
return url
|
|
31
97
|
},
|
|
@@ -39,9 +105,14 @@ export const jsenvPluginNodeEsmResolution = ({
|
|
|
39
105
|
return null
|
|
40
106
|
},
|
|
41
107
|
}
|
|
108
|
+
}
|
|
42
109
|
|
|
43
|
-
|
|
44
|
-
|
|
110
|
+
const jsenvPluginNodeModulesVersionInUrls = ({
|
|
111
|
+
lookupPackageScope,
|
|
112
|
+
readPackageJson,
|
|
113
|
+
}) => {
|
|
114
|
+
return {
|
|
115
|
+
name: "jsenv:node_modules_version_in_urls",
|
|
45
116
|
appliesDuring: {
|
|
46
117
|
dev: true,
|
|
47
118
|
test: true,
|
|
@@ -72,6 +143,4 @@ export const jsenvPluginNodeEsmResolution = ({
|
|
|
72
143
|
}
|
|
73
144
|
},
|
|
74
145
|
}
|
|
75
|
-
|
|
76
|
-
return [nodeEsmResolution, packageVersionInUrl]
|
|
77
146
|
}
|
package/src/plugins/plugins.js
CHANGED
|
@@ -39,6 +39,9 @@ export const getCorePlugins = ({
|
|
|
39
39
|
if (autoreload === true) {
|
|
40
40
|
autoreload = {}
|
|
41
41
|
}
|
|
42
|
+
if (nodeEsmResolution === true) {
|
|
43
|
+
nodeEsmResolution = {}
|
|
44
|
+
}
|
|
42
45
|
return [
|
|
43
46
|
jsenvPluginUrlReferences(),
|
|
44
47
|
jsenvPluginTranspilation(transpilation),
|
|
@@ -48,7 +51,11 @@ export const getCorePlugins = ({
|
|
|
48
51
|
jsenvPluginFileUrls(),
|
|
49
52
|
jsenvPluginHttpUrls(),
|
|
50
53
|
jsenvPluginLeadingSlash(),
|
|
51
|
-
|
|
54
|
+
// before url resolution to handle "js_import_export" resolution
|
|
55
|
+
jsenvPluginNodeEsmResolution({
|
|
56
|
+
rootDirectoryUrl,
|
|
57
|
+
...nodeEsmResolution,
|
|
58
|
+
}),
|
|
52
59
|
jsenvPluginUrlResolution(),
|
|
53
60
|
jsenvPluginFileSystemMagic(fileSystemMagicResolution),
|
|
54
61
|
jsenvPluginUrlVersion(),
|
package/src/test/execute_plan.js
CHANGED