@jsenv/core 27.0.0-alpha.32 → 27.0.0-alpha.35
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.35",
|
|
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.4",
|
|
67
68
|
"@jsenv/server": "12.6.1",
|
|
68
69
|
"@jsenv/uneval": "1.6.0",
|
|
69
|
-
"@jsenv/utils": "1.4.
|
|
70
|
+
"@jsenv/utils": "1.4.4",
|
|
70
71
|
"construct-style-sheets-polyfill": "3.1.0",
|
|
71
72
|
"cssnano": "5.1.7",
|
|
72
73
|
"cssnano-preset-default": "5.2.7",
|
|
@@ -109,4 +110,4 @@
|
|
|
109
110
|
"redux": "4.1.2",
|
|
110
111
|
"rollup": "2.70.1"
|
|
111
112
|
}
|
|
112
|
-
}
|
|
113
|
+
}
|
package/src/build/build.js
CHANGED
|
@@ -46,19 +46,44 @@ import { injectGlobalVersionMapping } from "./inject_global_version_mappings.js"
|
|
|
46
46
|
import { injectServiceWorkerUrls } from "./inject_service_worker_urls.js"
|
|
47
47
|
import { resyncRessourceHints } from "./resync_ressource_hints.js"
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Generate an optimized version of source files into a directory
|
|
51
|
+
* @param {Object} buildParameters
|
|
52
|
+
* @param {string|url} buildParameters.rootDirectoryUrl
|
|
53
|
+
* Directory containing source files
|
|
54
|
+
* @param {string|url} buildParameters.buildDirectoryUrl
|
|
55
|
+
* Directory where optimized files will be written
|
|
56
|
+
* @param {object} buildParameters.entryPoints
|
|
57
|
+
* Describe entry point paths and control their names in the build directory
|
|
58
|
+
* @param {object} buildParameters.runtimeCompat
|
|
59
|
+
* Code generated will be compatible with these runtimes
|
|
60
|
+
* @param {string="/"} buildParameters.baseUrl
|
|
61
|
+
* All urls in build file contents are prefixed with this url
|
|
62
|
+
* @param {boolean|object} [buildParameters.minification=true]
|
|
63
|
+
* Minify build file contents
|
|
64
|
+
* @param {boolean} [buildParameters.versioning=true]
|
|
65
|
+
* Controls if url in build file contents are versioned
|
|
66
|
+
* @param {('search_param'|'filename')} [buildParameters.versioningMethod="search_param"]
|
|
67
|
+
* Controls how url are versioned
|
|
68
|
+
* @param {boolean|string} [buildParameters.sourcemaps=false]
|
|
69
|
+
* Generate sourcemaps in the build directory
|
|
70
|
+
* @return {Object} buildReturnValue
|
|
71
|
+
* @return {Object} buildReturnValue.buildFileContents
|
|
72
|
+
* Contains all build file paths relative to the build directory and their content
|
|
73
|
+
* @return {Object} buildReturnValue.buildInlineContents
|
|
74
|
+
* Contains content that is inline into build files
|
|
75
|
+
* @return {Object} buildReturnValue.buildManifest
|
|
76
|
+
* Map build file paths without versioning to versioned file paths
|
|
77
|
+
*/
|
|
49
78
|
export const build = async ({
|
|
50
79
|
signal = new AbortController().signal,
|
|
51
80
|
logLevel = "info",
|
|
52
81
|
rootDirectoryUrl,
|
|
53
82
|
buildDirectoryUrl,
|
|
54
83
|
entryPoints = {},
|
|
55
|
-
// for now it's here but I think preview will become an other script
|
|
56
|
-
// that will just pass different options to build project
|
|
57
|
-
// and this function will be agnostic about "preview" concept
|
|
58
|
-
isPreview = false,
|
|
59
84
|
|
|
60
85
|
plugins = [],
|
|
61
|
-
sourcemaps =
|
|
86
|
+
sourcemaps = false,
|
|
62
87
|
nodeEsmResolution,
|
|
63
88
|
fileSystemMagicResolution,
|
|
64
89
|
injectedGlobals,
|
|
@@ -142,6 +167,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
142
167
|
specifier: key,
|
|
143
168
|
})
|
|
144
169
|
entryUrls.push(entryUrlInfo.url)
|
|
170
|
+
entryUrlInfo.filename = entryPoints[key]
|
|
145
171
|
})
|
|
146
172
|
},
|
|
147
173
|
})
|
|
@@ -4,6 +4,17 @@ import { memoizeByUrl } from "@jsenv/utils/memoize/memoize_by_url.js"
|
|
|
4
4
|
|
|
5
5
|
export const createBuilUrlsGenerator = ({ buildDirectoryUrl }) => {
|
|
6
6
|
const cache = {}
|
|
7
|
+
|
|
8
|
+
const getUrlName = (url, urlInfo) => {
|
|
9
|
+
if (!urlInfo) {
|
|
10
|
+
return urlToFilename(url)
|
|
11
|
+
}
|
|
12
|
+
if (urlInfo.filename) {
|
|
13
|
+
return urlInfo.filename
|
|
14
|
+
}
|
|
15
|
+
return urlToFilename(url)
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
const generate = memoizeByUrl((url, { urlInfo, parentUrlInfo }) => {
|
|
8
19
|
const directoryPath = determineDirectoryPath({
|
|
9
20
|
urlInfo,
|
|
@@ -16,9 +27,7 @@ export const createBuilUrlsGenerator = ({ buildDirectoryUrl }) => {
|
|
|
16
27
|
}
|
|
17
28
|
const urlObject = new URL(url)
|
|
18
29
|
let { search, hash } = urlObject
|
|
19
|
-
let name = urlInfo
|
|
20
|
-
? urlInfo.filename || urlToFilename(url)
|
|
21
|
-
: urlToFilename(url)
|
|
30
|
+
let name = getUrlName(url, urlInfo)
|
|
22
31
|
const [basename, extension] = splitFileExtension(name)
|
|
23
32
|
let nameCandidate = name
|
|
24
33
|
let integer = 1
|
|
@@ -45,7 +45,7 @@ export const startBuildServer = async ({
|
|
|
45
45
|
rootDirectoryUrl,
|
|
46
46
|
buildDirectoryUrl,
|
|
47
47
|
buildCommand,
|
|
48
|
-
|
|
48
|
+
mainBuildFileUrl = "/index.html",
|
|
49
49
|
watchedFilePatterns,
|
|
50
50
|
cooldownBetweenFileEvents,
|
|
51
51
|
autorestart,
|
|
@@ -145,10 +145,10 @@ export const startBuildServer = async ({
|
|
|
145
145
|
request.ressource,
|
|
146
146
|
request.origin,
|
|
147
147
|
).searchParams.has("v")
|
|
148
|
-
if (
|
|
148
|
+
if (mainBuildFileUrl && request.ressource === "/") {
|
|
149
149
|
request = {
|
|
150
150
|
...request,
|
|
151
|
-
ressource:
|
|
151
|
+
ressource: mainBuildFileUrl,
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
return fetchFileSystem(
|