@jsenv/core 40.5.3 → 40.6.0
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/build/build.js +52 -14
- package/dist/build/jsenv_core_packages.js +110 -110
- package/dist/start_dev_server/jsenv_core_packages.js +110 -110
- package/dist/start_dev_server/start_dev_server.js +52 -14
- package/package.json +25 -23
- package/src/plugins/resolution_node_esm/jsenv_plugin_node_esm_resolution.js +9 -4
- package/src/plugins/resolution_node_esm/node_esm_resolver.js +43 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "40.
|
|
3
|
+
"version": "40.6.0",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -38,14 +38,15 @@
|
|
|
38
38
|
},
|
|
39
39
|
"packageManager": "npm@11.2.0",
|
|
40
40
|
"workspaces": [
|
|
41
|
-
"./packages/
|
|
42
|
-
"./packages/
|
|
43
|
-
"./packages/
|
|
44
|
-
"./packages/independent/tooling/*",
|
|
45
|
-
"./packages/independent/shared/*",
|
|
41
|
+
"./packages/back_and_front/*",
|
|
42
|
+
"./packages/backend/*",
|
|
43
|
+
"./packages/frontend/*",
|
|
46
44
|
"./packages/internal/*",
|
|
45
|
+
"./packages/private/*",
|
|
46
|
+
"./packages/private/oto/packages/*",
|
|
47
47
|
"./packages/related/*",
|
|
48
|
-
"./packages/related/cli/*"
|
|
48
|
+
"./packages/related/cli/*",
|
|
49
|
+
"./packages/tooling/*"
|
|
49
50
|
],
|
|
50
51
|
"sideEffects": [
|
|
51
52
|
"./src/kitchen/client/inline_content.js",
|
|
@@ -72,10 +73,11 @@
|
|
|
72
73
|
"test:packages:ci": "CI=1 npm run workspace:test",
|
|
73
74
|
"test:only_dev_server_errors": "node --conditions=dev:jsenv ./tests/dev_server/errors/dev_errors_snapshots.test.mjs",
|
|
74
75
|
"dev": "node --watch --conditions=dev:jsenv ./scripts/dev/dev.mjs",
|
|
75
|
-
"dev:route-inspector": "node --watch --conditions=dev:jsenv ./packages/
|
|
76
|
+
"dev:route-inspector": "node --watch --conditions=dev:jsenv ./packages/backend/server/tests/route_inspector/start_server.js",
|
|
76
77
|
"playwright:install": "npx playwright install-deps && npx playwright install",
|
|
77
78
|
"https:setup": "npx @jsenv/https-local setup",
|
|
78
|
-
"prepublishOnly": "npm run build"
|
|
79
|
+
"prepublishOnly": "npm run build",
|
|
80
|
+
"oto:start": "npm run start -w oto"
|
|
79
81
|
},
|
|
80
82
|
"dependencies": {
|
|
81
83
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
@@ -85,48 +87,48 @@
|
|
|
85
87
|
"@jsenv/plugin-minification": "1.7.0",
|
|
86
88
|
"@jsenv/plugin-supervisor": "1.6.17",
|
|
87
89
|
"@jsenv/plugin-transpilation": "1.5.18",
|
|
88
|
-
"@jsenv/
|
|
89
|
-
"@jsenv/
|
|
90
|
+
"@jsenv/server": "16.1.2",
|
|
91
|
+
"@jsenv/sourcemap": "1.3.7"
|
|
90
92
|
},
|
|
91
93
|
"devDependencies": {
|
|
92
94
|
"@babel/plugin-syntax-decorators": "7.25.9",
|
|
93
95
|
"@babel/plugin-syntax-import-attributes": "7.26.0",
|
|
94
96
|
"@babel/plugin-syntax-optional-chaining-assign": "7.25.9",
|
|
97
|
+
"@jsenv/abort": "workspace:*",
|
|
95
98
|
"@jsenv/assert": "workspace:*",
|
|
96
99
|
"@jsenv/cli": "workspace:*",
|
|
97
100
|
"@jsenv/core": "./",
|
|
98
101
|
"@jsenv/eslint-config-relax": "workspace:*",
|
|
99
102
|
"@jsenv/file-size-impact": "workspace:*",
|
|
103
|
+
"@jsenv/filesystem": "workspace:*",
|
|
100
104
|
"@jsenv/https-local": "workspace:*",
|
|
105
|
+
"@jsenv/humanize": "workspace:*",
|
|
106
|
+
"@jsenv/importmap": "workspace:*",
|
|
107
|
+
"@jsenv/integrity": "workspace:*",
|
|
101
108
|
"@jsenv/md-up": "workspace:*",
|
|
102
109
|
"@jsenv/monorepo": "workspace:*",
|
|
110
|
+
"@jsenv/node-esm-resolution": "workspace:*",
|
|
111
|
+
"@jsenv/os-metrics": "workspace:*",
|
|
103
112
|
"@jsenv/performance-impact": "workspace:*",
|
|
104
113
|
"@jsenv/plugin-as-js-classic": "workspace:*",
|
|
105
114
|
"@jsenv/router": "workspace:*",
|
|
115
|
+
"@jsenv/runtime-compat": "workspace:*",
|
|
106
116
|
"@jsenv/snapshot": "workspace:*",
|
|
107
|
-
"@jsenv/test": "workspace:*",
|
|
108
117
|
"@jsenv/terminal-table": "workspace:*",
|
|
109
|
-
"@jsenv/
|
|
110
|
-
"@jsenv/runtime-compat": "workspace:*",
|
|
118
|
+
"@jsenv/test": "workspace:*",
|
|
111
119
|
"@jsenv/url-meta": "workspace:*",
|
|
112
120
|
"@jsenv/urls": "workspace:*",
|
|
113
121
|
"@jsenv/utils": "workspace:*",
|
|
114
|
-
"@jsenv/abort": "workspace:*",
|
|
115
|
-
"@jsenv/filesystem": "workspace:*",
|
|
116
|
-
"@jsenv/humanize": "workspace:*",
|
|
117
|
-
"@jsenv/importmap": "workspace:*",
|
|
118
|
-
"@jsenv/integrity": "workspace:*",
|
|
119
|
-
"@jsenv/node-esm-resolution": "workspace:*",
|
|
120
122
|
"@playwright/browser-chromium": "1.51.1",
|
|
121
123
|
"@playwright/browser-firefox": "1.51.1",
|
|
122
124
|
"@playwright/browser-webkit": "1.51.1",
|
|
123
125
|
"babel-plugin-transform-async-to-promises": "0.8.18",
|
|
124
126
|
"eslint": "9.24.0",
|
|
125
|
-
"open": "10.1.
|
|
127
|
+
"open": "10.1.1",
|
|
126
128
|
"playwright": "1.51.1",
|
|
129
|
+
"preact": "10.26.5",
|
|
127
130
|
"prettier": "3.5.3",
|
|
128
131
|
"prettier-plugin-organize-imports": "4.1.0",
|
|
129
|
-
"strip-ansi": "7.1.0"
|
|
130
|
-
"preact": "10.26.5"
|
|
132
|
+
"strip-ansi": "7.1.0"
|
|
131
133
|
}
|
|
132
134
|
}
|
|
@@ -46,8 +46,7 @@ export const jsenvPluginNodeEsmResolution = (
|
|
|
46
46
|
if (config === true) {
|
|
47
47
|
resolver = nodeEsmResolverDefault;
|
|
48
48
|
} else if (config === false) {
|
|
49
|
-
|
|
50
|
-
continue;
|
|
49
|
+
resolver = null;
|
|
51
50
|
} else if (typeof config === "object") {
|
|
52
51
|
resolver = resolverFromObject(config, { kitchenContext, urlType });
|
|
53
52
|
} else {
|
|
@@ -62,6 +61,9 @@ export const jsenvPluginNodeEsmResolution = (
|
|
|
62
61
|
resolverMap.set(urlType, resolver);
|
|
63
62
|
}
|
|
64
63
|
}
|
|
64
|
+
if (!anyTypeResolver) {
|
|
65
|
+
anyTypeResolver = nodeEsmResolverDefault;
|
|
66
|
+
}
|
|
65
67
|
|
|
66
68
|
if (!resolverMap.has("js_module")) {
|
|
67
69
|
resolverMap.set("js_module", nodeEsmResolverDefault);
|
|
@@ -87,8 +89,11 @@ export const jsenvPluginNodeEsmResolution = (
|
|
|
87
89
|
}
|
|
88
90
|
const urlType = urlTypeFromReference(reference);
|
|
89
91
|
const resolver = resolverMap.get(urlType);
|
|
90
|
-
if (resolver) {
|
|
91
|
-
|
|
92
|
+
if (resolver !== undefined) {
|
|
93
|
+
if (typeof resolver === "function") {
|
|
94
|
+
return resolver(reference);
|
|
95
|
+
}
|
|
96
|
+
return resolver;
|
|
92
97
|
}
|
|
93
98
|
if (anyTypeResolver) {
|
|
94
99
|
return anyTypeResolver(reference);
|
|
@@ -51,13 +51,32 @@ export const createNodeEsmResolver = ({
|
|
|
51
51
|
return null; // let it to jsenv_web_resolution
|
|
52
52
|
}
|
|
53
53
|
const { specifier } = reference;
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
// specifiers like "#something" have a special meaning for Node.js
|
|
55
|
+
// but can also be used in .css and .html files for example and should not be modified
|
|
56
|
+
// by node esm resolution
|
|
57
|
+
const webResolutionFallback =
|
|
58
|
+
ownerUrlInfo.type !== "js_module" ||
|
|
59
|
+
reference.type === "sourcemap_comment";
|
|
60
|
+
const conditions = buildPackageConditions(specifier, parentUrl, {
|
|
61
|
+
webResolutionFallback,
|
|
62
|
+
});
|
|
63
|
+
let resolution;
|
|
64
|
+
const nodeEsmResolutionParams = {
|
|
56
65
|
conditions,
|
|
57
66
|
parentUrl,
|
|
58
67
|
specifier,
|
|
59
68
|
preservesSymlink,
|
|
60
|
-
}
|
|
69
|
+
};
|
|
70
|
+
if (webResolutionFallback) {
|
|
71
|
+
try {
|
|
72
|
+
resolution = applyNodeEsmResolution(nodeEsmResolutionParams);
|
|
73
|
+
} catch {
|
|
74
|
+
return null; // delegate to web_resolution plugin
|
|
75
|
+
}
|
|
76
|
+
} else {
|
|
77
|
+
resolution = applyNodeEsmResolution(nodeEsmResolutionParams);
|
|
78
|
+
}
|
|
79
|
+
const { url, type, isMain, packageDirectoryUrl } = resolution;
|
|
61
80
|
// try to give a more meaningful filename after build
|
|
62
81
|
if (isMain && packageDirectoryUrl) {
|
|
63
82
|
const basename = urlToBasename(url);
|
|
@@ -126,12 +145,26 @@ const createBuildPackageConditions = (
|
|
|
126
145
|
const nodeRuntimeEnabled = Object.keys(runtimeCompat).includes("node");
|
|
127
146
|
// https://nodejs.org/api/esm.html#resolver-algorithm-specification
|
|
128
147
|
const processArgConditions = readCustomConditionsFromProcessArgs();
|
|
129
|
-
const devResolver = (specifier, importer) => {
|
|
148
|
+
const devResolver = (specifier, importer, { webResolutionFallback }) => {
|
|
130
149
|
if (isBareSpecifier(specifier)) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
150
|
+
let url;
|
|
151
|
+
if (webResolutionFallback) {
|
|
152
|
+
try {
|
|
153
|
+
const resolution = applyNodeEsmResolution({
|
|
154
|
+
specifier,
|
|
155
|
+
parentUrl: importer,
|
|
156
|
+
});
|
|
157
|
+
url = resolution.url;
|
|
158
|
+
} catch {
|
|
159
|
+
url = new URL(specifier, importer).href;
|
|
160
|
+
}
|
|
161
|
+
} else {
|
|
162
|
+
const resolution = applyNodeEsmResolution({
|
|
163
|
+
specifier,
|
|
164
|
+
parentUrl: importer,
|
|
165
|
+
});
|
|
166
|
+
url = resolution.url;
|
|
167
|
+
}
|
|
135
168
|
return !url.includes("/node_modules/");
|
|
136
169
|
}
|
|
137
170
|
return !importer.includes("/node_modules/");
|
|
@@ -235,12 +268,12 @@ const createBuildPackageConditions = (
|
|
|
235
268
|
}
|
|
236
269
|
|
|
237
270
|
const conditionCandidateArray = Object.keys(conditionResolvers);
|
|
238
|
-
return (specifier, importer) => {
|
|
271
|
+
return (specifier, importer, params) => {
|
|
239
272
|
const conditions = [];
|
|
240
273
|
for (const conditionCandidate of conditionCandidateArray) {
|
|
241
274
|
const conditionResolver = conditionResolvers[conditionCandidate];
|
|
242
275
|
if (typeof conditionResolver === "function") {
|
|
243
|
-
if (conditionResolver(specifier, importer)) {
|
|
276
|
+
if (conditionResolver(specifier, importer, params)) {
|
|
244
277
|
conditions.push(conditionCandidate);
|
|
245
278
|
}
|
|
246
279
|
} else if (conditionResolver) {
|