@jsenv/core 27.0.0-alpha.14 → 27.0.0-alpha.17
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 +5 -4
- package/src/build/start_build_server.js +32 -49
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.17",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"node": ">=16.13.0"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
14
|
+
"access": "public",
|
|
15
|
+
"registry": "https://registry.npmjs.org"
|
|
15
16
|
},
|
|
16
17
|
"type": "module",
|
|
17
18
|
"imports": {},
|
|
@@ -66,7 +67,7 @@
|
|
|
66
67
|
"@jsenv/node-esm-resolution": "0.0.2",
|
|
67
68
|
"@jsenv/server": "12.6.1",
|
|
68
69
|
"@jsenv/uneval": "1.6.0",
|
|
69
|
-
"@jsenv/utils": "1.1
|
|
70
|
+
"@jsenv/utils": "1.2.1",
|
|
70
71
|
"construct-style-sheets-polyfill": "3.1.0",
|
|
71
72
|
"cssnano": "5.1.7",
|
|
72
73
|
"cssnano-preset-default": "5.2.7",
|
|
@@ -110,4 +111,4 @@
|
|
|
110
111
|
"redux": "4.1.2",
|
|
111
112
|
"rollup": "2.70.1"
|
|
112
113
|
}
|
|
113
|
-
}
|
|
114
|
+
}
|
|
@@ -26,12 +26,13 @@ import { createLogger } from "@jsenv/logger"
|
|
|
26
26
|
|
|
27
27
|
import { createTaskLog } from "@jsenv/utils/logs/task_log.js"
|
|
28
28
|
import { watchFiles } from "@jsenv/utils/file_watcher/file_watcher.js"
|
|
29
|
-
import {
|
|
29
|
+
import { executeCommand } from "@jsenv/utils/command/command.js"
|
|
30
30
|
|
|
31
31
|
export const startBuildServer = async ({
|
|
32
32
|
signal = new AbortController().signal,
|
|
33
33
|
handleSIGINT = true,
|
|
34
34
|
logLevel,
|
|
35
|
+
buildCommandLogLevel = "warn",
|
|
35
36
|
protocol,
|
|
36
37
|
http2,
|
|
37
38
|
certificate,
|
|
@@ -42,24 +43,9 @@ export const startBuildServer = async ({
|
|
|
42
43
|
|
|
43
44
|
rootDirectoryUrl,
|
|
44
45
|
buildDirectoryUrl,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
plugins,
|
|
48
|
-
sourcemaps,
|
|
49
|
-
nodeEsmResolution,
|
|
50
|
-
fileSystemMagicResolution,
|
|
51
|
-
injectedGlobals,
|
|
52
|
-
runtimeCompat,
|
|
53
|
-
transpilation,
|
|
54
|
-
bundling,
|
|
55
|
-
minification,
|
|
56
|
-
versioning,
|
|
57
|
-
versioningMethod = "search_param", // "filename", "search_param"
|
|
58
|
-
lineBreakNormalization,
|
|
46
|
+
buildCommand,
|
|
59
47
|
watchedFilePatterns,
|
|
60
48
|
cooldownBetweenFileEvents,
|
|
61
|
-
|
|
62
|
-
baseUrl,
|
|
63
49
|
}) => {
|
|
64
50
|
const operation = Abort.startOperation()
|
|
65
51
|
operation.addAbortSignal(signal)
|
|
@@ -73,42 +59,34 @@ export const startBuildServer = async ({
|
|
|
73
59
|
)
|
|
74
60
|
})
|
|
75
61
|
}
|
|
62
|
+
const logger = createLogger({ logLevel })
|
|
76
63
|
|
|
77
64
|
let buildPromise
|
|
78
65
|
let abortController
|
|
79
|
-
const runBuild = () => {
|
|
66
|
+
const runBuild = async () => {
|
|
67
|
+
const buildTask = createTaskLog(logger, `execute build command`)
|
|
80
68
|
abortController = new AbortController()
|
|
81
69
|
operation.addAbortCallback(() => {
|
|
82
70
|
abortController.abort()
|
|
83
71
|
})
|
|
84
|
-
buildPromise =
|
|
72
|
+
buildPromise = executeCommand(buildCommand, {
|
|
73
|
+
cwd: rootDirectoryUrl,
|
|
74
|
+
logLevel: buildCommandLogLevel,
|
|
85
75
|
signal: abortController.signal,
|
|
86
|
-
logLevel: "warn",
|
|
87
|
-
rootDirectoryUrl,
|
|
88
|
-
buildDirectoryUrl,
|
|
89
|
-
entryPoints,
|
|
90
|
-
|
|
91
|
-
plugins,
|
|
92
|
-
sourcemaps,
|
|
93
|
-
nodeEsmResolution,
|
|
94
|
-
fileSystemMagicResolution,
|
|
95
|
-
injectedGlobals,
|
|
96
|
-
runtimeCompat,
|
|
97
|
-
transpilation,
|
|
98
|
-
bundling,
|
|
99
|
-
minification,
|
|
100
|
-
versioning,
|
|
101
|
-
versioningMethod,
|
|
102
|
-
lineBreakNormalization,
|
|
103
|
-
|
|
104
|
-
writeOnFileSystem: true,
|
|
105
|
-
buildDirectoryClean: true,
|
|
106
|
-
baseUrl,
|
|
107
|
-
assetManifest: false,
|
|
108
76
|
})
|
|
77
|
+
try {
|
|
78
|
+
await buildPromise
|
|
79
|
+
buildTask.done()
|
|
80
|
+
} catch (e) {
|
|
81
|
+
if (e.code === "ABORT_ERR") {
|
|
82
|
+
buildTask.fail(`execute build command aborted`)
|
|
83
|
+
} else {
|
|
84
|
+
buildTask.fail()
|
|
85
|
+
throw e
|
|
86
|
+
}
|
|
87
|
+
}
|
|
109
88
|
}
|
|
110
89
|
|
|
111
|
-
const logger = createLogger({ logLevel })
|
|
112
90
|
const startServerTask = createTaskLog(logger, "start build server")
|
|
113
91
|
const server = await startServer({
|
|
114
92
|
signal,
|
|
@@ -145,11 +123,10 @@ export const startBuildServer = async ({
|
|
|
145
123
|
sendErrorDetails: true,
|
|
146
124
|
requestToResponse: async (request) => {
|
|
147
125
|
await buildPromise
|
|
148
|
-
const urlIsVersioned =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
false
|
|
126
|
+
const urlIsVersioned = new URL(
|
|
127
|
+
request.ressource,
|
|
128
|
+
request.origin,
|
|
129
|
+
).searchParams.has("v")
|
|
153
130
|
|
|
154
131
|
return fetchFileSystem(
|
|
155
132
|
new URL(request.ressource.slice(1), buildDirectoryUrl),
|
|
@@ -177,9 +154,15 @@ export const startBuildServer = async ({
|
|
|
177
154
|
rootDirectoryUrl,
|
|
178
155
|
watchedFilePatterns,
|
|
179
156
|
cooldownBetweenFileEvents,
|
|
180
|
-
fileChangeCallback: () => {
|
|
157
|
+
fileChangeCallback: ({ relativeUrl, event }) => {
|
|
181
158
|
abortController.abort()
|
|
182
|
-
|
|
159
|
+
// setTimeout is to ensure the abortController.abort() above
|
|
160
|
+
// is properly taken into account so that logs about abort comes first
|
|
161
|
+
// then logs about re-running the build happens
|
|
162
|
+
setTimeout(() => {
|
|
163
|
+
logger.info(`${relativeUrl} ${event} -> rebuild`)
|
|
164
|
+
runBuild()
|
|
165
|
+
})
|
|
183
166
|
},
|
|
184
167
|
})
|
|
185
168
|
operation.addAbortCallback(() => {
|