@jsenv/core 27.0.0 → 27.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/dist/main.js +34 -16
- package/package.json +11 -11
- package/src/build/start_build_server.js +3 -1
- package/src/execute/runtimes/browsers/from_playwright.js +6 -3
- package/src/omega/url_graph/url_info_transformations.js +27 -14
- package/src/omega/url_graph.js +1 -0
- package/src/plugins/bundling/js_module/bundle_js_module.js +5 -1
- package/src/test/execute_plan.js +1 -0
package/dist/main.js
CHANGED
|
@@ -19850,7 +19850,7 @@ const rollupPluginJsenv = ({
|
|
|
19850
19850
|
outputOptions: outputOptions => {
|
|
19851
19851
|
// const sourcemapFile = buildDirectoryUrl
|
|
19852
19852
|
Object.assign(outputOptions, {
|
|
19853
|
-
format: "esm",
|
|
19853
|
+
format: jsModuleUrlInfos.some(jsModuleUrlInfo => jsModuleUrlInfo.filename.endsWith(".cjs")) ? "cjs" : "esm",
|
|
19854
19854
|
dir: fileUrlConverter.asFilePath(buildDirectoryUrl),
|
|
19855
19855
|
sourcemap: sourcemaps === "file" || sourcemaps === "inline",
|
|
19856
19856
|
// sourcemapFile,
|
|
@@ -21446,6 +21446,7 @@ const createUrlInfo = url => {
|
|
|
21446
21446
|
content: undefined,
|
|
21447
21447
|
sourcemap: null,
|
|
21448
21448
|
sourcemapReference: null,
|
|
21449
|
+
sourcemapIsWrong: false,
|
|
21449
21450
|
timing: {},
|
|
21450
21451
|
headers: {}
|
|
21451
21452
|
};
|
|
@@ -21891,7 +21892,8 @@ const createUrlInfoTransformer = ({
|
|
|
21891
21892
|
type,
|
|
21892
21893
|
contentType,
|
|
21893
21894
|
content,
|
|
21894
|
-
sourcemap
|
|
21895
|
+
sourcemap,
|
|
21896
|
+
sourcemapIsWrong
|
|
21895
21897
|
} = transformations;
|
|
21896
21898
|
|
|
21897
21899
|
if (type) {
|
|
@@ -21910,7 +21912,17 @@ const createUrlInfoTransformer = ({
|
|
|
21910
21912
|
const sourcemapNormalized = normalizeSourcemap(urlInfo, sourcemap);
|
|
21911
21913
|
const finalSourcemap = await composeTwoSourcemaps(urlInfo.sourcemap, sourcemapNormalized);
|
|
21912
21914
|
const finalSourcemapNormalized = normalizeSourcemap(urlInfo, finalSourcemap);
|
|
21913
|
-
urlInfo.sourcemap = finalSourcemapNormalized;
|
|
21915
|
+
urlInfo.sourcemap = finalSourcemapNormalized; // A plugin is allowed to modify url content
|
|
21916
|
+
// without returning a sourcemap
|
|
21917
|
+
// This is the case for preact and react plugins.
|
|
21918
|
+
// They are currently generating wrong source mappings
|
|
21919
|
+
// when used.
|
|
21920
|
+
// Generating the correct sourcemap in this situation
|
|
21921
|
+
// is a nightmare no-one could solve in years so
|
|
21922
|
+
// jsenv won't emit a warning and use the following strategy:
|
|
21923
|
+
// "no sourcemap is better than wrong sourcemap"
|
|
21924
|
+
|
|
21925
|
+
urlInfo.sourcemapIsWrong = sourcemapIsWrong;
|
|
21914
21926
|
}
|
|
21915
21927
|
};
|
|
21916
21928
|
|
|
@@ -21939,16 +21951,18 @@ const createUrlInfoTransformer = ({
|
|
|
21939
21951
|
|
|
21940
21952
|
sourcemapUrlInfo.content = JSON.stringify(sourcemap, null, " ");
|
|
21941
21953
|
|
|
21942
|
-
if (
|
|
21943
|
-
|
|
21944
|
-
|
|
21954
|
+
if (!urlInfo.sourcemapIsWrong) {
|
|
21955
|
+
if (sourcemaps === "inline") {
|
|
21956
|
+
sourcemapReference.generatedSpecifier = generateSourcemapDataUrl(sourcemap);
|
|
21957
|
+
}
|
|
21945
21958
|
|
|
21946
|
-
|
|
21947
|
-
|
|
21948
|
-
|
|
21949
|
-
|
|
21950
|
-
|
|
21951
|
-
|
|
21959
|
+
if (sourcemaps === "file" || sourcemaps === "inline") {
|
|
21960
|
+
urlInfo.content = SOURCEMAP.writeComment({
|
|
21961
|
+
contentType: urlInfo.contentType,
|
|
21962
|
+
content: urlInfo.content,
|
|
21963
|
+
specifier: sourcemaps === "file" && sourcemapsRelativeSources ? urlToRelativeUrl(sourcemapReference.url, urlInfo.url) : sourcemapReference.generatedSpecifier
|
|
21964
|
+
});
|
|
21965
|
+
}
|
|
21952
21966
|
}
|
|
21953
21967
|
} else if (urlInfo.sourcemapReference) {
|
|
21954
21968
|
// in the end we don't use the sourcemap placeholder
|
|
@@ -25478,6 +25492,7 @@ const executePlan = async (plan, {
|
|
|
25478
25492
|
});
|
|
25479
25493
|
|
|
25480
25494
|
if (!keepRunning) {
|
|
25495
|
+
logger.debug("stopAfterAllSignal.notify()");
|
|
25481
25496
|
await stopAfterAllSignal.notify();
|
|
25482
25497
|
}
|
|
25483
25498
|
|
|
@@ -25888,7 +25903,7 @@ const createRuntimeFromPlaywright = ({
|
|
|
25888
25903
|
|
|
25889
25904
|
runtime.run = async ({
|
|
25890
25905
|
signal = new AbortController().signal,
|
|
25891
|
-
|
|
25906
|
+
logger,
|
|
25892
25907
|
rootDirectoryUrl,
|
|
25893
25908
|
fileRelativeUrl,
|
|
25894
25909
|
server,
|
|
@@ -25947,10 +25962,10 @@ const createRuntimeFromPlaywright = ({
|
|
|
25947
25962
|
};
|
|
25948
25963
|
|
|
25949
25964
|
browser.on("disconnected", disconnectedCallback);
|
|
25950
|
-
}) : Promise.resolve(); // for some reason without this
|
|
25965
|
+
}) : Promise.resolve(); // for some reason without this 150ms timeout
|
|
25951
25966
|
// browser.close() never resolves (playwright does not like something)
|
|
25952
25967
|
|
|
25953
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
25968
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
25954
25969
|
|
|
25955
25970
|
try {
|
|
25956
25971
|
await browser.close();
|
|
@@ -26148,6 +26163,7 @@ const createRuntimeFromPlaywright = ({
|
|
|
26148
26163
|
stopAfterAllSignal.notify = async () => {
|
|
26149
26164
|
await notifyPrevious();
|
|
26150
26165
|
browser.removeListener("disconnected", disconnectedCallback);
|
|
26166
|
+
logger.debug(`stopAfterAllSignal notified -> closing ${browserName}`);
|
|
26151
26167
|
await closeBrowser();
|
|
26152
26168
|
};
|
|
26153
26169
|
}
|
|
@@ -29162,7 +29178,9 @@ const startBuildServer = async ({
|
|
|
29162
29178
|
throw new TypeError(`buildIndexPath must be a string, got ${buildIndexPath}`);
|
|
29163
29179
|
}
|
|
29164
29180
|
|
|
29165
|
-
if (buildIndexPath[0]
|
|
29181
|
+
if (buildIndexPath[0] === "/") {
|
|
29182
|
+
buildIndexPath = buildIndexPath.slice(1);
|
|
29183
|
+
} else {
|
|
29166
29184
|
const buildIndexUrl = new URL(buildIndexPath, buildDirectoryUrl).href;
|
|
29167
29185
|
|
|
29168
29186
|
if (!buildIndexUrl.startsWith(buildDirectoryUrl)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "27.0.
|
|
3
|
+
"version": "27.0.3",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -43,26 +43,26 @@
|
|
|
43
43
|
"eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
|
|
44
44
|
"dev": "node --conditions=development ./scripts/dev/dev.mjs",
|
|
45
45
|
"test": "node --conditions=development ./scripts/test/test.mjs",
|
|
46
|
-
"test
|
|
46
|
+
"test:coverage": "npm run test -- --coverage",
|
|
47
47
|
"build": "node --conditions=development ./scripts/build/build.mjs",
|
|
48
|
-
"
|
|
49
|
-
"workspace
|
|
50
|
-
"workspace
|
|
48
|
+
"workspace:test": "npm run test --workspaces --if-present -- --workspace",
|
|
49
|
+
"workspace:versions": "node ./scripts/publish/workspace_versions.mjs",
|
|
50
|
+
"workspace:publish": "node ./scripts/publish/workspace_publish.mjs",
|
|
51
51
|
"performances": "node --expose-gc ./scripts/performance/generate_performance_report.mjs --log --once",
|
|
52
52
|
"file-size": "node ./scripts/file_size/file_size.mjs --log",
|
|
53
|
+
"start_file_server": "node ./scripts/dev/start_file_server.mjs",
|
|
53
54
|
"prettier": "prettier --write .",
|
|
54
55
|
"playwright-install": "npx playwright install-deps && npx playwright install",
|
|
55
56
|
"certificate-install": "node ./scripts/dev/install_certificate_authority.mjs",
|
|
56
|
-
"test-with-coverage": "npm run test -- --coverage",
|
|
57
57
|
"prepublishOnly": "npm run build"
|
|
58
58
|
},
|
|
59
59
|
"optionalDependencies": {
|
|
60
60
|
"playwright": "1.x"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@babel/plugin-proposal-dynamic-import": "7.
|
|
63
|
+
"@babel/plugin-proposal-dynamic-import": "7.18.6",
|
|
64
64
|
"@babel/plugin-transform-modules-systemjs": "7.18.6",
|
|
65
|
-
"@babel/plugin-transform-modules-umd": "7.18.
|
|
65
|
+
"@babel/plugin-transform-modules-umd": "7.18.6",
|
|
66
66
|
"@c88/v8-coverage": "0.1.1",
|
|
67
67
|
"@financial-times/polyfill-useragent-normaliser": "2.0.1",
|
|
68
68
|
"@jsenv/ast": "1.1.1",
|
|
@@ -96,12 +96,12 @@
|
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@babel/eslint-parser": "7.18.2",
|
|
99
|
-
"@babel/plugin-syntax-import-assertions": "7.
|
|
99
|
+
"@babel/plugin-syntax-import-assertions": "7.18.6",
|
|
100
100
|
"@jsenv/assert": "2.6.0",
|
|
101
|
-
"@jsenv/eslint-config": "16.0
|
|
101
|
+
"@jsenv/eslint-config": "16.1.0",
|
|
102
102
|
"@jsenv/file-size-impact": "13.0.1",
|
|
103
103
|
"@jsenv/https-local": "2.1.0",
|
|
104
|
-
"@jsenv/package-workspace": "0.4.
|
|
104
|
+
"@jsenv/package-workspace": "0.4.1",
|
|
105
105
|
"@jsenv/performance-impact": "3.0.1",
|
|
106
106
|
"eslint": "8.19.0",
|
|
107
107
|
"eslint-plugin-html": "6.2.0",
|
|
@@ -69,7 +69,9 @@ export const startBuildServer = async ({
|
|
|
69
69
|
`buildIndexPath must be a string, got ${buildIndexPath}`,
|
|
70
70
|
)
|
|
71
71
|
}
|
|
72
|
-
if (buildIndexPath[0]
|
|
72
|
+
if (buildIndexPath[0] === "/") {
|
|
73
|
+
buildIndexPath = buildIndexPath.slice(1)
|
|
74
|
+
} else {
|
|
73
75
|
const buildIndexUrl = new URL(buildIndexPath, buildDirectoryUrl).href
|
|
74
76
|
if (!buildIndexUrl.startsWith(buildDirectoryUrl)) {
|
|
75
77
|
throw new Error(
|
|
@@ -30,7 +30,7 @@ export const createRuntimeFromPlaywright = ({
|
|
|
30
30
|
let browserAndContextPromise
|
|
31
31
|
runtime.run = async ({
|
|
32
32
|
signal = new AbortController().signal,
|
|
33
|
-
|
|
33
|
+
logger,
|
|
34
34
|
rootDirectoryUrl,
|
|
35
35
|
fileRelativeUrl,
|
|
36
36
|
server,
|
|
@@ -82,9 +82,9 @@ export const createRuntimeFromPlaywright = ({
|
|
|
82
82
|
browser.on("disconnected", disconnectedCallback)
|
|
83
83
|
})
|
|
84
84
|
: Promise.resolve()
|
|
85
|
-
// for some reason without this
|
|
85
|
+
// for some reason without this 150ms timeout
|
|
86
86
|
// browser.close() never resolves (playwright does not like something)
|
|
87
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
87
|
+
await new Promise((resolve) => setTimeout(resolve, 150))
|
|
88
88
|
try {
|
|
89
89
|
await browser.close()
|
|
90
90
|
} catch (e) {
|
|
@@ -275,6 +275,9 @@ export const createRuntimeFromPlaywright = ({
|
|
|
275
275
|
stopAfterAllSignal.notify = async () => {
|
|
276
276
|
await notifyPrevious()
|
|
277
277
|
browser.removeListener("disconnected", disconnectedCallback)
|
|
278
|
+
logger.debug(
|
|
279
|
+
`stopAfterAllSignal notified -> closing ${browserName}`,
|
|
280
|
+
)
|
|
278
281
|
await closeBrowser()
|
|
279
282
|
}
|
|
280
283
|
}
|
|
@@ -117,7 +117,8 @@ export const createUrlInfoTransformer = ({
|
|
|
117
117
|
if (!transformations) {
|
|
118
118
|
return
|
|
119
119
|
}
|
|
120
|
-
const { type, contentType, content, sourcemap } =
|
|
120
|
+
const { type, contentType, content, sourcemap, sourcemapIsWrong } =
|
|
121
|
+
transformations
|
|
121
122
|
if (type) {
|
|
122
123
|
urlInfo.type = type
|
|
123
124
|
}
|
|
@@ -138,6 +139,16 @@ export const createUrlInfoTransformer = ({
|
|
|
138
139
|
finalSourcemap,
|
|
139
140
|
)
|
|
140
141
|
urlInfo.sourcemap = finalSourcemapNormalized
|
|
142
|
+
// A plugin is allowed to modify url content
|
|
143
|
+
// without returning a sourcemap
|
|
144
|
+
// This is the case for preact and react plugins.
|
|
145
|
+
// They are currently generating wrong source mappings
|
|
146
|
+
// when used.
|
|
147
|
+
// Generating the correct sourcemap in this situation
|
|
148
|
+
// is a nightmare no-one could solve in years so
|
|
149
|
+
// jsenv won't emit a warning and use the following strategy:
|
|
150
|
+
// "no sourcemap is better than wrong sourcemap"
|
|
151
|
+
urlInfo.sourcemapIsWrong = sourcemapIsWrong
|
|
141
152
|
}
|
|
142
153
|
}
|
|
143
154
|
|
|
@@ -162,19 +173,21 @@ export const createUrlInfoTransformer = ({
|
|
|
162
173
|
})
|
|
163
174
|
}
|
|
164
175
|
sourcemapUrlInfo.content = JSON.stringify(sourcemap, null, " ")
|
|
165
|
-
if (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
if (!urlInfo.sourcemapIsWrong) {
|
|
177
|
+
if (sourcemaps === "inline") {
|
|
178
|
+
sourcemapReference.generatedSpecifier =
|
|
179
|
+
generateSourcemapDataUrl(sourcemap)
|
|
180
|
+
}
|
|
181
|
+
if (sourcemaps === "file" || sourcemaps === "inline") {
|
|
182
|
+
urlInfo.content = SOURCEMAP.writeComment({
|
|
183
|
+
contentType: urlInfo.contentType,
|
|
184
|
+
content: urlInfo.content,
|
|
185
|
+
specifier:
|
|
186
|
+
sourcemaps === "file" && sourcemapsRelativeSources
|
|
187
|
+
? urlToRelativeUrl(sourcemapReference.url, urlInfo.url)
|
|
188
|
+
: sourcemapReference.generatedSpecifier,
|
|
189
|
+
})
|
|
190
|
+
}
|
|
178
191
|
}
|
|
179
192
|
} else if (urlInfo.sourcemapReference) {
|
|
180
193
|
// in the end we don't use the sourcemap placeholder
|
package/src/omega/url_graph.js
CHANGED
|
@@ -147,7 +147,11 @@ const rollupPluginJsenv = ({
|
|
|
147
147
|
outputOptions: (outputOptions) => {
|
|
148
148
|
// const sourcemapFile = buildDirectoryUrl
|
|
149
149
|
Object.assign(outputOptions, {
|
|
150
|
-
format:
|
|
150
|
+
format: jsModuleUrlInfos.some((jsModuleUrlInfo) =>
|
|
151
|
+
jsModuleUrlInfo.filename.endsWith(".cjs"),
|
|
152
|
+
)
|
|
153
|
+
? "cjs"
|
|
154
|
+
: "esm",
|
|
151
155
|
dir: fileUrlConverter.asFilePath(buildDirectoryUrl),
|
|
152
156
|
sourcemap: sourcemaps === "file" || sourcemaps === "inline",
|
|
153
157
|
// sourcemapFile,
|