@jsenv/core 27.6.0 → 27.8.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/js/autoreload.js +3 -6
- package/dist/js/html_supervisor_installer.js +42 -30
- package/dist/js/html_supervisor_setup.js +10 -2
- package/dist/js/server_events_client.js +249 -216
- package/dist/js/wrapper.mjs +4233 -0
- package/dist/main.js +21282 -21623
- package/package.json +4 -4
- package/src/build/build.js +19 -18
- package/src/dev/start_dev_server.js +7 -11
- package/src/execute/execute.js +2 -2
- package/src/execute/runtimes/browsers/chromium.js +1 -1
- package/src/execute/runtimes/browsers/firefox.js +1 -1
- package/src/execute/runtimes/browsers/webkit.js +1 -1
- package/src/omega/kitchen.js +9 -14
- package/src/omega/omega_server.js +13 -2
- package/src/omega/server/file_service.js +13 -29
- package/src/plugins/autoreload/client/autoreload.js +3 -4
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +0 -4
- package/src/plugins/autoreload/jsenv_plugin_autoreload_client.js +1 -1
- package/src/plugins/autoreload/jsenv_plugin_autoreload_server.js +1 -1
- package/src/plugins/autoreload/jsenv_plugin_hmr.js +1 -1
- package/src/plugins/bundling/jsenv_plugin_bundling.js +1 -3
- package/src/plugins/cache_control/jsenv_plugin_cache_control.js +2 -5
- package/src/plugins/commonjs_globals/jsenv_plugin_commonjs_globals.js +2 -2
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +4 -8
- package/src/plugins/html_supervisor/client/error_formatter.js +48 -35
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +1 -4
- package/src/plugins/html_supervisor/client/html_supervisor_setup.js +10 -2
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +28 -11
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +2 -2
- package/src/plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +18 -24
- package/src/plugins/importmap/jsenv_plugin_importmap.js +1 -1
- package/src/plugins/minification/jsenv_plugin_minification.js +1 -3
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +9 -7
- package/src/plugins/plugin_controller.js +17 -6
- package/src/plugins/plugins.js +0 -2
- package/src/plugins/server_events/client/connection_manager.js +165 -0
- package/src/plugins/server_events/client/event_source_connection.js +50 -256
- package/src/plugins/server_events/client/events_manager.js +75 -0
- package/src/plugins/server_events/client/server_events_client.js +12 -11
- package/src/plugins/server_events/client/web_socket_connection.js +81 -0
- package/src/plugins/server_events/server_events_dispatcher.js +70 -54
- package/src/plugins/toolbar/jsenv_plugin_toolbar.js +1 -3
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +1 -1
- package/src/plugins/url_analysis/html/html_urls.js +2 -2
- package/src/test/execute_plan.js +2 -2
- package/src/test/execute_test_plan.js +1 -1
- package/src/plugins/html_supervisor/client/error_site_remap.js +0 -85
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "27.
|
|
3
|
+
"version": "27.8.0",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"@jsenv/integrity": "0.0.1",
|
|
74
74
|
"@jsenv/log": "3.1.0",
|
|
75
75
|
"@jsenv/node-esm-resolution": "0.1.0",
|
|
76
|
-
"@jsenv/server": "13.
|
|
77
|
-
"@jsenv/sourcemap": "1.0.
|
|
76
|
+
"@jsenv/server": "13.1.0",
|
|
77
|
+
"@jsenv/sourcemap": "1.0.4",
|
|
78
78
|
"@jsenv/uneval": "1.6.0",
|
|
79
79
|
"@jsenv/url-meta": "7.0.0",
|
|
80
80
|
"@jsenv/urls": "1.2.7",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"eslint-plugin-html": "7.0.0",
|
|
110
110
|
"eslint-plugin-import": "2.26.0",
|
|
111
111
|
"eslint-plugin-react": "7.30.1",
|
|
112
|
-
"playwright": "1.
|
|
112
|
+
"playwright": "1.24.1",
|
|
113
113
|
"prettier": "2.7.1"
|
|
114
114
|
}
|
|
115
115
|
}
|
package/src/build/build.js
CHANGED
|
@@ -47,6 +47,20 @@ import { createVersionGenerator } from "./version_generator.js"
|
|
|
47
47
|
import { injectServiceWorkerUrls } from "./inject_service_worker_urls.js"
|
|
48
48
|
import { resyncRessourceHints } from "./resync_ressource_hints.js"
|
|
49
49
|
|
|
50
|
+
// default runtimeCompat corresponds to
|
|
51
|
+
// "we can keep <script type="module"> intact":
|
|
52
|
+
// so script_type_module + dynamic_import + import_meta
|
|
53
|
+
export const defaultRuntimeCompat = {
|
|
54
|
+
// android: "8",
|
|
55
|
+
chrome: "64",
|
|
56
|
+
edge: "79",
|
|
57
|
+
firefox: "67",
|
|
58
|
+
ios: "12",
|
|
59
|
+
opera: "51",
|
|
60
|
+
safari: "11.3",
|
|
61
|
+
samsung: "9.2",
|
|
62
|
+
}
|
|
63
|
+
|
|
50
64
|
/**
|
|
51
65
|
* Generate an optimized version of source files into a directory
|
|
52
66
|
* @param {Object} buildParameters
|
|
@@ -85,19 +99,7 @@ export const build = async ({
|
|
|
85
99
|
entryPoints = {},
|
|
86
100
|
baseUrl = "/",
|
|
87
101
|
|
|
88
|
-
|
|
89
|
-
// "we can keep <script type="module"> intact":
|
|
90
|
-
// so script_type_module + dynamic_import + import_meta
|
|
91
|
-
runtimeCompat = {
|
|
92
|
-
// android: "8",
|
|
93
|
-
chrome: "64",
|
|
94
|
-
edge: "79",
|
|
95
|
-
firefox: "67",
|
|
96
|
-
ios: "12",
|
|
97
|
-
opera: "51",
|
|
98
|
-
safari: "11.3",
|
|
99
|
-
samsung: "9.2",
|
|
100
|
-
},
|
|
102
|
+
runtimeCompat = defaultRuntimeCompat,
|
|
101
103
|
plugins = [],
|
|
102
104
|
sourcemaps = false,
|
|
103
105
|
sourcemapsSourcesContent,
|
|
@@ -173,7 +175,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
173
175
|
logger,
|
|
174
176
|
rootDirectoryUrl,
|
|
175
177
|
urlGraph: rawGraph,
|
|
176
|
-
|
|
178
|
+
scenarios: { build: true },
|
|
177
179
|
sourcemaps,
|
|
178
180
|
sourcemapsSourcesContent,
|
|
179
181
|
runtimeCompat,
|
|
@@ -200,7 +202,6 @@ build ${entryPointKeys.length} entry points`)
|
|
|
200
202
|
...getCorePlugins({
|
|
201
203
|
rootDirectoryUrl,
|
|
202
204
|
urlGraph: rawGraph,
|
|
203
|
-
scenario: "build",
|
|
204
205
|
runtimeCompat,
|
|
205
206
|
|
|
206
207
|
urlAnalysis,
|
|
@@ -421,7 +422,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
421
422
|
logger,
|
|
422
423
|
rootDirectoryUrl,
|
|
423
424
|
urlGraph: finalGraph,
|
|
424
|
-
|
|
425
|
+
scenarios: { build: true },
|
|
425
426
|
sourcemaps,
|
|
426
427
|
sourcemapsSourcesContent,
|
|
427
428
|
sourcemapsRelativeSources: !versioning,
|
|
@@ -1061,7 +1062,7 @@ const applyUrlVersioning = async ({
|
|
|
1061
1062
|
logger,
|
|
1062
1063
|
rootDirectoryUrl: buildDirectoryUrl,
|
|
1063
1064
|
urlGraph: finalGraph,
|
|
1064
|
-
|
|
1065
|
+
scenarios: { build: true },
|
|
1065
1066
|
sourcemaps,
|
|
1066
1067
|
sourcemapsSourcesContent,
|
|
1067
1068
|
sourcemapsRelativeSources: true,
|
|
@@ -1076,7 +1077,7 @@ const applyUrlVersioning = async ({
|
|
|
1076
1077
|
}),
|
|
1077
1078
|
{
|
|
1078
1079
|
name: "jsenv:versioning",
|
|
1079
|
-
appliesDuring:
|
|
1080
|
+
appliesDuring: "build",
|
|
1080
1081
|
resolveUrl: (reference) => {
|
|
1081
1082
|
const buildUrl = buildUrls[reference.specifier]
|
|
1082
1083
|
if (buildUrl) {
|
|
@@ -7,6 +7,7 @@ import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
|
7
7
|
import { createLogger, loggerToLevels, createTaskLog } from "@jsenv/log"
|
|
8
8
|
import { getCallerPosition } from "@jsenv/urls"
|
|
9
9
|
|
|
10
|
+
import { defaultRuntimeCompat } from "@jsenv/core/src/build/build.js"
|
|
10
11
|
import { createReloadableWorker } from "@jsenv/core/src/helpers/worker_reload.js"
|
|
11
12
|
import { startOmegaServer } from "@jsenv/core/src/omega/omega_server.js"
|
|
12
13
|
|
|
@@ -41,16 +42,10 @@ export const startDevServer = async ({
|
|
|
41
42
|
devServerMainFile = getCallerPosition().url,
|
|
42
43
|
cooldownBetweenFileEvents,
|
|
43
44
|
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
// and "jsenv_plugin_node_runtime.js" applies only during build made for node.js
|
|
49
|
-
runtimeCompat = {
|
|
50
|
-
chrome: "100",
|
|
51
|
-
firefox: "100",
|
|
52
|
-
safari: "15.5",
|
|
53
|
-
},
|
|
45
|
+
// runtimeCompat is the runtimeCompat for the build
|
|
46
|
+
// when specified, dev server use it to warn in case
|
|
47
|
+
// code would be supported during dev but not after build
|
|
48
|
+
runtimeCompat = defaultRuntimeCompat,
|
|
54
49
|
plugins = [],
|
|
55
50
|
urlAnalysis = {},
|
|
56
51
|
htmlSupervisor = true,
|
|
@@ -160,8 +155,9 @@ export const startDevServer = async ({
|
|
|
160
155
|
services,
|
|
161
156
|
|
|
162
157
|
rootDirectoryUrl,
|
|
163
|
-
|
|
158
|
+
scenarios: { dev: true },
|
|
164
159
|
runtimeCompat,
|
|
160
|
+
|
|
165
161
|
plugins,
|
|
166
162
|
urlAnalysis,
|
|
167
163
|
htmlSupervisor,
|
package/src/execute/execute.js
CHANGED
|
@@ -24,7 +24,7 @@ export const execute = async ({
|
|
|
24
24
|
runtime,
|
|
25
25
|
runtimeParams,
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
scenarios = { dev: true },
|
|
28
28
|
plugins = [],
|
|
29
29
|
nodeEsmResolution,
|
|
30
30
|
fileSystemMagicResolution,
|
|
@@ -75,7 +75,7 @@ export const execute = async ({
|
|
|
75
75
|
privateKey,
|
|
76
76
|
|
|
77
77
|
rootDirectoryUrl,
|
|
78
|
-
|
|
78
|
+
scenarios,
|
|
79
79
|
runtimeCompat: { [runtime.name]: runtime.version },
|
|
80
80
|
|
|
81
81
|
plugins,
|
|
@@ -2,7 +2,7 @@ import { createRuntimeFromPlaywright } from "./from_playwright.js"
|
|
|
2
2
|
|
|
3
3
|
export const chromium = createRuntimeFromPlaywright({
|
|
4
4
|
browserName: "chromium",
|
|
5
|
-
browserVersion: "104.0.5112.
|
|
5
|
+
browserVersion: "104.0.5112.48", // to update, check https://github.com/microsoft/playwright/releases
|
|
6
6
|
coveragePlaywrightAPIAvailable: true,
|
|
7
7
|
})
|
|
8
8
|
export const chromiumIsolatedTab = chromium.isolatedTab
|
|
@@ -2,6 +2,6 @@ import { createRuntimeFromPlaywright } from "./from_playwright.js"
|
|
|
2
2
|
|
|
3
3
|
export const firefox = createRuntimeFromPlaywright({
|
|
4
4
|
browserName: "firefox",
|
|
5
|
-
browserVersion: "
|
|
5
|
+
browserVersion: "102.0", // to update, check https://github.com/microsoft/playwright/releases
|
|
6
6
|
})
|
|
7
7
|
export const firefoxIsolatedTab = firefox.isolatedTab
|
|
@@ -2,7 +2,7 @@ import { createRuntimeFromPlaywright } from "./from_playwright.js"
|
|
|
2
2
|
|
|
3
3
|
export const webkit = createRuntimeFromPlaywright({
|
|
4
4
|
browserName: "webkit",
|
|
5
|
-
browserVersion: "
|
|
5
|
+
browserVersion: "16.0", // to update, check https://github.com/microsoft/playwright/releases
|
|
6
6
|
ignoreErrorHook: (error) => {
|
|
7
7
|
// we catch error during execution but safari throw unhandled rejection
|
|
8
8
|
// in a non-deterministic way.
|
package/src/omega/kitchen.js
CHANGED
|
@@ -28,18 +28,14 @@ export const createKitchen = ({
|
|
|
28
28
|
logLevel,
|
|
29
29
|
|
|
30
30
|
rootDirectoryUrl,
|
|
31
|
-
|
|
31
|
+
scenarios,
|
|
32
32
|
runtimeCompat,
|
|
33
33
|
// during dev/test clientRuntimeCompat is a single runtime
|
|
34
34
|
// during build clientRuntimeCompat is runtimeCompat
|
|
35
35
|
clientRuntimeCompat = runtimeCompat,
|
|
36
36
|
urlGraph,
|
|
37
37
|
plugins,
|
|
38
|
-
sourcemaps =
|
|
39
|
-
dev: "inline", // "programmatic" and "file" also allowed
|
|
40
|
-
test: "inline",
|
|
41
|
-
build: "none",
|
|
42
|
-
}[scenario],
|
|
38
|
+
sourcemaps = scenarios.dev ? "inline" : "none", // "programmatic" and "file" also allowed
|
|
43
39
|
sourcemapsSourcesProtocol,
|
|
44
40
|
sourcemapsSourcesContent,
|
|
45
41
|
sourcemapsRelativeSources,
|
|
@@ -48,7 +44,7 @@ export const createKitchen = ({
|
|
|
48
44
|
const logger = createLogger({ logLevel })
|
|
49
45
|
const pluginController = createPluginController({
|
|
50
46
|
plugins,
|
|
51
|
-
|
|
47
|
+
scenarios,
|
|
52
48
|
})
|
|
53
49
|
const jsenvDirectoryUrl = new URL(".jsenv/", rootDirectoryUrl).href
|
|
54
50
|
const kitchenContext = {
|
|
@@ -56,7 +52,7 @@ export const createKitchen = ({
|
|
|
56
52
|
logger,
|
|
57
53
|
rootDirectoryUrl,
|
|
58
54
|
urlGraph,
|
|
59
|
-
|
|
55
|
+
scenarios,
|
|
60
56
|
runtimeCompat,
|
|
61
57
|
clientRuntimeCompat,
|
|
62
58
|
isSupportedOnCurrentClients: (feature) => {
|
|
@@ -769,12 +765,11 @@ const applyReferenceEffectsOnUrlInfo = (reference, urlInfo, context) => {
|
|
|
769
765
|
column: reference.specifierColumn,
|
|
770
766
|
}
|
|
771
767
|
urlInfo.contentType = reference.contentType
|
|
772
|
-
urlInfo.originalContent =
|
|
773
|
-
|
|
774
|
-
?
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
: reference.content
|
|
768
|
+
urlInfo.originalContent = context.scenarios.build
|
|
769
|
+
? urlInfo.originalContent === undefined
|
|
770
|
+
? reference.content
|
|
771
|
+
: urlInfo.originalContent
|
|
772
|
+
: reference.content
|
|
778
773
|
urlInfo.content = reference.content
|
|
779
774
|
}
|
|
780
775
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
jsenvServiceErrorHandler,
|
|
6
6
|
} from "@jsenv/server"
|
|
7
7
|
import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/internal/convertFileSystemErrorToResponseProperties.js"
|
|
8
|
+
import { createServerEventsDispatcher } from "@jsenv/core/src/plugins/server_events/server_events_dispatcher.js"
|
|
8
9
|
|
|
9
10
|
import { createFileService } from "./server/file_service.js"
|
|
10
11
|
|
|
@@ -24,7 +25,7 @@ export const startOmegaServer = async ({
|
|
|
24
25
|
services = [],
|
|
25
26
|
|
|
26
27
|
rootDirectoryUrl,
|
|
27
|
-
|
|
28
|
+
scenarios,
|
|
28
29
|
runtimeCompat,
|
|
29
30
|
|
|
30
31
|
plugins,
|
|
@@ -43,6 +44,10 @@ export const startOmegaServer = async ({
|
|
|
43
44
|
writeGeneratedFiles,
|
|
44
45
|
}) => {
|
|
45
46
|
const serverStopCallbacks = []
|
|
47
|
+
const serverEventsDispatcher = createServerEventsDispatcher()
|
|
48
|
+
serverStopCallbacks.push(() => {
|
|
49
|
+
serverEventsDispatcher.destroy()
|
|
50
|
+
})
|
|
46
51
|
const server = await startServer({
|
|
47
52
|
signal,
|
|
48
53
|
stopOnExit: false,
|
|
@@ -79,9 +84,10 @@ export const startOmegaServer = async ({
|
|
|
79
84
|
signal,
|
|
80
85
|
logLevel,
|
|
81
86
|
serverStopCallbacks,
|
|
87
|
+
serverEventsDispatcher,
|
|
82
88
|
|
|
83
89
|
rootDirectoryUrl,
|
|
84
|
-
|
|
90
|
+
scenarios,
|
|
85
91
|
runtimeCompat,
|
|
86
92
|
|
|
87
93
|
plugins,
|
|
@@ -99,6 +105,11 @@ export const startOmegaServer = async ({
|
|
|
99
105
|
sourcemapsSourcesContent,
|
|
100
106
|
writeGeneratedFiles,
|
|
101
107
|
}),
|
|
108
|
+
handleWebsocket: (websocket, { request }) => {
|
|
109
|
+
if (request.headers["sec-websocket-protocol"] === "jsenv") {
|
|
110
|
+
serverEventsDispatcher.addWebsocket(websocket, request)
|
|
111
|
+
}
|
|
112
|
+
},
|
|
102
113
|
},
|
|
103
114
|
{
|
|
104
115
|
name: "jsenv:omega_error_handler",
|
|
@@ -10,7 +10,6 @@ import { URL_META } from "@jsenv/url-meta"
|
|
|
10
10
|
import { getCorePlugins } from "@jsenv/core/src/plugins/plugins.js"
|
|
11
11
|
import { createUrlGraph } from "@jsenv/core/src/omega/url_graph.js"
|
|
12
12
|
import { createKitchen } from "@jsenv/core/src/omega/kitchen.js"
|
|
13
|
-
import { createServerEventsDispatcher } from "@jsenv/core/src/plugins/server_events/server_events_dispatcher.js"
|
|
14
13
|
import { jsenvPluginServerEventsClientInjection } from "@jsenv/core/src/plugins/server_events/jsenv_plugin_server_events_client_injection.js"
|
|
15
14
|
import { parseUserAgentHeader } from "./user_agent.js"
|
|
16
15
|
|
|
@@ -18,9 +17,10 @@ export const createFileService = ({
|
|
|
18
17
|
signal,
|
|
19
18
|
logLevel,
|
|
20
19
|
serverStopCallbacks,
|
|
20
|
+
serverEventsDispatcher,
|
|
21
21
|
|
|
22
22
|
rootDirectoryUrl,
|
|
23
|
-
|
|
23
|
+
scenarios,
|
|
24
24
|
runtimeCompat,
|
|
25
25
|
|
|
26
26
|
plugins,
|
|
@@ -53,7 +53,7 @@ export const createFileService = ({
|
|
|
53
53
|
".jsenv/": false,
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
if (
|
|
56
|
+
if (scenarios.dev) {
|
|
57
57
|
const stopWatchingClientFiles = registerDirectoryLifecycle(
|
|
58
58
|
rootDirectoryUrl,
|
|
59
59
|
{
|
|
@@ -99,13 +99,13 @@ export const createFileService = ({
|
|
|
99
99
|
})
|
|
100
100
|
urlInfo.isValid = () => watch
|
|
101
101
|
},
|
|
102
|
-
includeOriginalUrls:
|
|
102
|
+
includeOriginalUrls: scenarios.dev,
|
|
103
103
|
})
|
|
104
104
|
const kitchen = createKitchen({
|
|
105
105
|
signal,
|
|
106
106
|
logLevel,
|
|
107
107
|
rootDirectoryUrl,
|
|
108
|
-
|
|
108
|
+
scenarios,
|
|
109
109
|
runtimeCompat,
|
|
110
110
|
clientRuntimeCompat: {
|
|
111
111
|
[runtimeName]: runtimeVersion,
|
|
@@ -115,7 +115,6 @@ export const createFileService = ({
|
|
|
115
115
|
...plugins,
|
|
116
116
|
...getCorePlugins({
|
|
117
117
|
rootDirectoryUrl,
|
|
118
|
-
scenario,
|
|
119
118
|
runtimeCompat,
|
|
120
119
|
|
|
121
120
|
urlAnalysis,
|
|
@@ -152,15 +151,11 @@ export const createFileService = ({
|
|
|
152
151
|
})
|
|
153
152
|
const serverEventNames = Object.keys(allServerEvents)
|
|
154
153
|
if (serverEventNames.length > 0) {
|
|
155
|
-
const serverEventsDispatcher = createServerEventsDispatcher()
|
|
156
|
-
serverStopCallbacks.push(() => {
|
|
157
|
-
serverEventsDispatcher.destroy()
|
|
158
|
-
})
|
|
159
154
|
Object.keys(allServerEvents).forEach((serverEventName) => {
|
|
160
155
|
allServerEvents[serverEventName]({
|
|
161
156
|
rootDirectoryUrl,
|
|
162
157
|
urlGraph,
|
|
163
|
-
|
|
158
|
+
scenarios,
|
|
164
159
|
sendServerEvent: (data) => {
|
|
165
160
|
serverEventsDispatcher.dispatch({
|
|
166
161
|
type: serverEventName,
|
|
@@ -169,19 +164,7 @@ export const createFileService = ({
|
|
|
169
164
|
},
|
|
170
165
|
})
|
|
171
166
|
})
|
|
172
|
-
// "
|
|
173
|
-
kitchen.pluginController.unshiftPlugin({
|
|
174
|
-
name: "jsenv:provide_server_events",
|
|
175
|
-
serve: (request) => {
|
|
176
|
-
const { accept } = request.headers
|
|
177
|
-
if (accept && accept.includes("text/event-stream")) {
|
|
178
|
-
const room = serverEventsDispatcher.addRoom(request)
|
|
179
|
-
return room.join(request)
|
|
180
|
-
}
|
|
181
|
-
return null
|
|
182
|
-
},
|
|
183
|
-
})
|
|
184
|
-
// "push" so that event source client connection can be put as early as possible in html
|
|
167
|
+
// "pushPlugin" so that event source client connection can be put as early as possible in html
|
|
185
168
|
kitchen.pluginController.pushPlugin(
|
|
186
169
|
jsenvPluginServerEventsClientInjection(),
|
|
187
170
|
)
|
|
@@ -190,7 +173,7 @@ export const createFileService = ({
|
|
|
190
173
|
|
|
191
174
|
const context = {
|
|
192
175
|
rootDirectoryUrl,
|
|
193
|
-
|
|
176
|
+
scenarios,
|
|
194
177
|
runtimeName,
|
|
195
178
|
runtimeVersion,
|
|
196
179
|
urlGraph,
|
|
@@ -276,10 +259,11 @@ export const createFileService = ({
|
|
|
276
259
|
await kitchen.cook(urlInfo, {
|
|
277
260
|
request,
|
|
278
261
|
reference,
|
|
279
|
-
outDirectoryUrl:
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
262
|
+
outDirectoryUrl: scenarios.dev
|
|
263
|
+
? `${rootDirectoryUrl}.jsenv/${runtimeName}@${runtimeVersion}/`
|
|
264
|
+
: `${rootDirectoryUrl}.jsenv/${
|
|
265
|
+
scenarios.test ? "test" : "build"
|
|
266
|
+
}/${runtimeName}@${runtimeVersion}/`,
|
|
283
267
|
})
|
|
284
268
|
let { response } = urlInfo
|
|
285
269
|
if (response) {
|
|
@@ -192,10 +192,9 @@ const applyHotReload = async ({ hotInstructions }) => {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
window.__reloader__ = reloader
|
|
195
|
-
window.__server_events__.
|
|
196
|
-
reload: (
|
|
197
|
-
|
|
198
|
-
reloader.addMessage(reloadMessage)
|
|
195
|
+
window.__server_events__.listenEvents({
|
|
196
|
+
reload: (reloadServerEvent) => {
|
|
197
|
+
reloader.addMessage(reloadServerEvent.data)
|
|
199
198
|
},
|
|
200
199
|
})
|
|
201
200
|
|
|
@@ -3,13 +3,9 @@ import { jsenvPluginAutoreloadClient } from "./jsenv_plugin_autoreload_client.js
|
|
|
3
3
|
import { jsenvPluginAutoreloadServer } from "./jsenv_plugin_autoreload_server.js"
|
|
4
4
|
|
|
5
5
|
export const jsenvPluginAutoreload = ({
|
|
6
|
-
scenario,
|
|
7
6
|
clientFileChangeCallbackList,
|
|
8
7
|
clientFilesPruneCallbackList,
|
|
9
8
|
}) => {
|
|
10
|
-
if (scenario === "build") {
|
|
11
|
-
return []
|
|
12
|
-
}
|
|
13
9
|
return [
|
|
14
10
|
jsenvPluginHmr(),
|
|
15
11
|
jsenvPluginAutoreloadClient(),
|
|
@@ -13,7 +13,7 @@ export const jsenvPluginAutoreloadClient = () => {
|
|
|
13
13
|
|
|
14
14
|
return {
|
|
15
15
|
name: "jsenv:autoreload_client",
|
|
16
|
-
appliesDuring: { dev: true },
|
|
16
|
+
appliesDuring: { dev: true, test: false },
|
|
17
17
|
transformUrlContent: {
|
|
18
18
|
html: (htmlUrlInfo, context) => {
|
|
19
19
|
const htmlAst = parseHtmlString(htmlUrlInfo.content)
|
|
@@ -6,7 +6,7 @@ export const jsenvPluginAutoreloadServer = ({
|
|
|
6
6
|
}) => {
|
|
7
7
|
return {
|
|
8
8
|
name: "jsenv:autoreload_server",
|
|
9
|
-
appliesDuring: { dev: true },
|
|
9
|
+
appliesDuring: { dev: true, test: false },
|
|
10
10
|
serverEvents: {
|
|
11
11
|
reload: ({ sendServerEvent, rootDirectoryUrl, urlGraph }) => {
|
|
12
12
|
const formatUrlForClient = (url) => {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
export const jsenvPluginCacheControl = () => {
|
|
2
2
|
return {
|
|
3
3
|
name: "jsenv:cache_control",
|
|
4
|
-
appliesDuring:
|
|
5
|
-
dev: true,
|
|
6
|
-
test: true,
|
|
7
|
-
},
|
|
4
|
+
appliesDuring: "dev",
|
|
8
5
|
augmentResponse: ({ reference }, context) => {
|
|
9
|
-
if (context.
|
|
6
|
+
if (context.scenarios.test) {
|
|
10
7
|
// During dev, all files are put into browser cache for 1 hour because:
|
|
11
8
|
// 1: Browser cache is a temporary directory created by playwright
|
|
12
9
|
// 2: We assume source files won't be modified while tests are running
|
|
@@ -11,7 +11,7 @@ import { createMagicSource } from "@jsenv/sourcemap"
|
|
|
11
11
|
import { applyBabelPlugins } from "@jsenv/ast"
|
|
12
12
|
|
|
13
13
|
export const jsenvPluginCommonJsGlobals = () => {
|
|
14
|
-
const transformCommonJsGlobals = async (urlInfo,
|
|
14
|
+
const transformCommonJsGlobals = async (urlInfo, context) => {
|
|
15
15
|
if (
|
|
16
16
|
!urlInfo.content.includes("process.env.NODE_ENV") &&
|
|
17
17
|
!urlInfo.content.includes("__filename") &&
|
|
@@ -22,7 +22,7 @@ export const jsenvPluginCommonJsGlobals = () => {
|
|
|
22
22
|
const isJsModule = urlInfo.type === "js_module"
|
|
23
23
|
const replaceMap = {
|
|
24
24
|
"process.env.NODE_ENV": `("${
|
|
25
|
-
|
|
25
|
+
context.scenarios.dev ? "development" : "production"
|
|
26
26
|
}")`,
|
|
27
27
|
"global": "globalThis",
|
|
28
28
|
"__filename": isJsModule
|
|
@@ -113,14 +113,10 @@ export const jsenvPluginFileUrls = ({
|
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
115
|
name: "jsenv:@fs_resolution",
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
test: true,
|
|
121
|
-
// during build it's fine to use file:// urls
|
|
122
|
-
build: false,
|
|
123
|
-
},
|
|
116
|
+
// during dev and test it's a browser running the code
|
|
117
|
+
// so absolute file urls needs to be relativized
|
|
118
|
+
// during build it's fine to use file:// urls
|
|
119
|
+
appliesDuring: "dev",
|
|
124
120
|
resolveUrl: (reference) => {
|
|
125
121
|
if (reference.specifier.startsWith("/@fs/")) {
|
|
126
122
|
const fsRootRelativeUrl = reference.specifier.slice("/@fs/".length)
|
|
@@ -10,6 +10,9 @@ export const formatError = (
|
|
|
10
10
|
const errorMeta = extractErrorMeta(error, { url, line, column })
|
|
11
11
|
|
|
12
12
|
const resolveUrlSite = ({ url, line, column }) => {
|
|
13
|
+
if (typeof line === "string") line = parseInt(line)
|
|
14
|
+
if (typeof column === "string") column = parseInt(column)
|
|
15
|
+
|
|
13
16
|
const inlineUrlMatch = url.match(
|
|
14
17
|
/@L([0-9]+)C([0-9]+)\-L([0-9]+)C([0-9]+)(\.[\w]+)$/,
|
|
15
18
|
)
|
|
@@ -21,7 +24,7 @@ export const formatError = (
|
|
|
21
24
|
const tagColumnEnd = parseInt(inlineUrlMatch[4])
|
|
22
25
|
const extension = inlineUrlMatch[5]
|
|
23
26
|
url = htmlUrl
|
|
24
|
-
line = tagLineStart + (line ===
|
|
27
|
+
line = tagLineStart + (typeof line === "number" ? line : 0)
|
|
25
28
|
// stackTrace formatted by V8 (chrome)
|
|
26
29
|
if (Error.captureStackTrace) {
|
|
27
30
|
line--
|
|
@@ -35,7 +38,7 @@ export const formatError = (
|
|
|
35
38
|
line -= 2
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
|
-
column = tagColumnStart + (column ===
|
|
41
|
+
column = tagColumnStart + (typeof column === "number" ? column : 0)
|
|
39
42
|
const fileUrl = resolveFileUrl(url)
|
|
40
43
|
return {
|
|
41
44
|
isInline: true,
|
|
@@ -120,42 +123,52 @@ export const formatError = (
|
|
|
120
123
|
const onErrorLocated = (urlSite) => {
|
|
121
124
|
errorUrlSite = urlSite
|
|
122
125
|
errorDetailsPromiseReference.current = (async () => {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return null
|
|
131
|
-
}
|
|
132
|
-
const causeInfo = await response.json()
|
|
133
|
-
if (!causeInfo) {
|
|
134
|
-
return null
|
|
135
|
-
}
|
|
126
|
+
try {
|
|
127
|
+
if (errorMeta.type === "dynamic_import_fetch_error") {
|
|
128
|
+
const response = await window.fetch(
|
|
129
|
+
`/__get_error_cause__/${
|
|
130
|
+
urlSite.isInline ? urlSite.originalUrl : urlSite.url
|
|
131
|
+
}`,
|
|
132
|
+
)
|
|
136
133
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
134
|
+
if (response.status !== 200) {
|
|
135
|
+
return null
|
|
136
|
+
}
|
|
137
|
+
const causeInfo = await response.json()
|
|
138
|
+
if (!causeInfo) {
|
|
139
|
+
return null
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const causeText =
|
|
143
|
+
causeInfo.code === "NOT_FOUND"
|
|
144
|
+
? formatErrorText({
|
|
145
|
+
message: causeInfo.reason,
|
|
146
|
+
stack: causeInfo.codeFrame,
|
|
147
|
+
})
|
|
148
|
+
: formatErrorText({
|
|
149
|
+
message: causeInfo.stack,
|
|
150
|
+
stack: causeInfo.codeFrame,
|
|
151
|
+
})
|
|
152
|
+
return {
|
|
153
|
+
cause: causeText,
|
|
154
|
+
}
|
|
149
155
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
156
|
+
if (urlSite.line !== undefined) {
|
|
157
|
+
let ressourceToFetch = `/__get_code_frame__/${formatUrlWithLineAndColumn(
|
|
158
|
+
urlSite,
|
|
159
|
+
)}`
|
|
160
|
+
if (!Error.captureStackTrace) {
|
|
161
|
+
ressourceToFetch += `?remap`
|
|
162
|
+
}
|
|
163
|
+
const response = await window.fetch(ressourceToFetch)
|
|
164
|
+
const codeFrame = await response.text()
|
|
165
|
+
return {
|
|
166
|
+
codeFrame: formatErrorText({ message: codeFrame }),
|
|
167
|
+
}
|
|
158
168
|
}
|
|
169
|
+
} catch (e) {
|
|
170
|
+
// happens if server is closed for instance
|
|
171
|
+
return null
|
|
159
172
|
}
|
|
160
173
|
return null
|
|
161
174
|
})()
|