@jsenv/core 27.0.0-alpha.66 → 27.0.0-alpha.69
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 +154 -85
- package/dist/s.js +626 -0
- package/dist/s.js.map +204 -0
- package/package.json +8 -7
- package/src/build/build.js +21 -11
- package/src/build/build_urls_generator.js +1 -1
- package/src/build/resync_ressource_hints.js +1 -1
- package/src/build/start_build_server.js +1 -1
- package/src/dev/plugins/explorer/jsenv_plugin_explorer.js +5 -9
- package/src/dev/start_dev_server.js +1 -1
- package/src/execute/run.js +2 -1
- package/src/execute/runtimes/browsers/from_playwright.js +1 -1
- package/src/execute/runtimes/node/node_process.js +1 -1
- package/src/omega/errors.js +2 -2
- package/src/omega/file_url_converter.js +1 -1
- package/src/omega/kitchen.js +49 -7
- package/src/omega/server/file_service.js +2 -2
- package/src/omega/url_graph/url_info_transformations.js +12 -6
- package/src/omega/url_graph.js +3 -2
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_server.js +1 -1
- package/src/plugins/bundling/js_module/bundle_js_module.js +4 -13
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +33 -26
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +1 -1
- package/src/plugins/importmap/jsenv_plugin_importmap.js +1 -1
- package/src/plugins/inline/jsenv_plugin_data_urls.js +1 -1
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +1 -1
- package/src/plugins/inline/jsenv_plugin_inline_query_param.js +1 -1
- package/src/plugins/inline/jsenv_plugin_js_inline_content.js +3 -3
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +12 -8
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +4 -2
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_workers.js +1 -1
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +10 -6
- package/src/plugins/url_analysis/css/css_urls.js +1 -1
- package/src/plugins/url_analysis/html/html_urls.js +1 -1
- package/src/plugins/url_analysis/js/js_urls.js +1 -1
- package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +5 -14
- package/src/test/execute_plan.js +11 -14
- package/src/test/execute_test_plan.js +10 -16
- package/src/test/execution_steps.js +1 -4
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
serveDirectory,
|
|
4
4
|
composeTwoResponses,
|
|
5
5
|
} from "@jsenv/server"
|
|
6
|
-
import { urlIsInsideOf, moveUrl } from "@jsenv/
|
|
6
|
+
import { urlIsInsideOf, moveUrl } from "@jsenv/urls"
|
|
7
7
|
|
|
8
8
|
import { parseUserAgentHeader } from "./user_agent.js"
|
|
9
9
|
|
|
@@ -143,7 +143,7 @@ export const createFileService = ({
|
|
|
143
143
|
body: urlInfo.content,
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
if (code === "
|
|
146
|
+
if (code === "DIRECTORY_REFERENCE_NOT_ALLOWED") {
|
|
147
147
|
return serveDirectory(reference.url, {
|
|
148
148
|
headers: {
|
|
149
149
|
accept: "text/html",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { bufferToEtag
|
|
1
|
+
import { bufferToEtag } from "@jsenv/filesystem"
|
|
2
|
+
import { urlToRelativeUrl } from "@jsenv/urls"
|
|
2
3
|
|
|
3
4
|
import { composeTwoSourcemaps } from "@jsenv/utils/sourcemap/sourcemap_composition_v3.js"
|
|
4
5
|
import {
|
|
@@ -34,14 +35,14 @@ export const createUrlInfoTransformer = ({
|
|
|
34
35
|
))
|
|
35
36
|
if (sourcemap.sources && sourcemap.sources.length > 1) {
|
|
36
37
|
sourcemap.sources = sourcemap.sources.map(
|
|
37
|
-
(source) => new URL(source, urlInfo.
|
|
38
|
+
(source) => new URL(source, urlInfo.originalUrl).href,
|
|
38
39
|
)
|
|
39
40
|
if (!wantSourcesContent) {
|
|
40
41
|
sourcemap.sourcesContent = undefined
|
|
41
42
|
}
|
|
42
43
|
return sourcemap
|
|
43
44
|
}
|
|
44
|
-
sourcemap.sources = [urlInfo.
|
|
45
|
+
sourcemap.sources = [urlInfo.originalUrl]
|
|
45
46
|
sourcemap.sourcesContent = [urlInfo.originalContent]
|
|
46
47
|
if (!wantSourcesContent) {
|
|
47
48
|
sourcemap.sourcesContent = undefined
|
|
@@ -74,6 +75,7 @@ export const createUrlInfoTransformer = ({
|
|
|
74
75
|
|
|
75
76
|
// already loaded during "load" hook (happens during build)
|
|
76
77
|
if (urlInfo.sourcemap) {
|
|
78
|
+
urlInfo.sourcemap = normalizeSourcemap(urlInfo, urlInfo.sourcemap)
|
|
77
79
|
return
|
|
78
80
|
}
|
|
79
81
|
// check for existing sourcemap for this content
|
|
@@ -92,8 +94,9 @@ export const createUrlInfoTransformer = ({
|
|
|
92
94
|
})
|
|
93
95
|
try {
|
|
94
96
|
await context.cook(sourcemapUrlInfo, { reference: sourcemapReference })
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
+
const sourcemapRaw = JSON.parse(sourcemapUrlInfo.content)
|
|
98
|
+
const sourcemap = normalizeSourcemap(urlInfo, sourcemapRaw)
|
|
99
|
+
urlInfo.sourcemap = sourcemap
|
|
97
100
|
} catch (e) {
|
|
98
101
|
logger.error(`Error while handling existing sourcemap: ${e.message}`)
|
|
99
102
|
return
|
|
@@ -146,7 +149,7 @@ export const createUrlInfoTransformer = ({
|
|
|
146
149
|
if (sourcemapsRelativeSources) {
|
|
147
150
|
sourcemap.sources = sourcemap.sources.map((source) => {
|
|
148
151
|
const sourceRelative = urlToRelativeUrl(source, urlInfo.url)
|
|
149
|
-
return sourceRelative
|
|
152
|
+
return sourceRelative || "."
|
|
150
153
|
})
|
|
151
154
|
}
|
|
152
155
|
sourcemapUrlInfo.content = JSON.stringify(sourcemap, null, " ")
|
|
@@ -163,6 +166,9 @@ export const createUrlInfoTransformer = ({
|
|
|
163
166
|
: sourcemapReference.generatedSpecifier,
|
|
164
167
|
})
|
|
165
168
|
}
|
|
169
|
+
} else if (urlInfo.sourcemapReference) {
|
|
170
|
+
// in the end we don't use the sourcemap placeholder
|
|
171
|
+
urlGraph.deleteUrlInfo(urlInfo.sourcemapReference.url)
|
|
166
172
|
}
|
|
167
173
|
urlInfo.contentEtag = bufferToEtag(Buffer.from(urlInfo.content))
|
|
168
174
|
}
|
package/src/omega/url_graph.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { urlToRelativeUrl } from "@jsenv/
|
|
1
|
+
import { urlToRelativeUrl } from "@jsenv/urls"
|
|
2
2
|
import { urlSpecifierEncoding } from "./url_specifier_encoding.js"
|
|
3
3
|
|
|
4
4
|
export const createUrlGraph = ({
|
|
@@ -184,8 +184,9 @@ const createUrlInfo = (url) => {
|
|
|
184
184
|
subtype: undefined, // "worker", "service_worker", "shared_worker" for js, otherwise undefined
|
|
185
185
|
contentType: "", // "text/html", "text/css", "text/javascript", "application/json", ...
|
|
186
186
|
url,
|
|
187
|
-
|
|
187
|
+
originalUrl: undefined,
|
|
188
188
|
generatedUrl: null,
|
|
189
|
+
filename: "",
|
|
189
190
|
isInline: false,
|
|
190
191
|
inlineUrlSite: null,
|
|
191
192
|
shouldHandle: undefined,
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { pathToFileURL } from "node:url"
|
|
2
|
-
import {
|
|
3
|
-
isFileSystemPath,
|
|
4
|
-
normalizeStructuredMetaMap,
|
|
5
|
-
urlToMeta,
|
|
6
|
-
} from "@jsenv/filesystem"
|
|
2
|
+
import { isFileSystemPath, URL_META } from "@jsenv/urls"
|
|
7
3
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
8
4
|
|
|
9
5
|
import { babelHelperNameFromUrl } from "@jsenv/babel-plugins"
|
|
@@ -145,17 +141,12 @@ const rollupPluginJsenv = ({
|
|
|
145
141
|
}
|
|
146
142
|
let importCanBeBundled = () => true
|
|
147
143
|
if (include) {
|
|
148
|
-
const
|
|
149
|
-
{
|
|
150
|
-
bundle: include,
|
|
151
|
-
},
|
|
144
|
+
const associations = URL_META.resolveAssociations(
|
|
145
|
+
{ bundle: include },
|
|
152
146
|
rootDirectoryUrl,
|
|
153
147
|
)
|
|
154
148
|
importCanBeBundled = (url) => {
|
|
155
|
-
return
|
|
156
|
-
url,
|
|
157
|
-
structuredMetaMap: bundleIncludeConfig,
|
|
158
|
-
}).bundle
|
|
149
|
+
return URL_META.applyAssociations({ url, associations }).bundle
|
|
159
150
|
}
|
|
160
151
|
}
|
|
161
152
|
const urlImporters = {}
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
urlToRelativeUrl,
|
|
6
6
|
urlToExtension,
|
|
7
7
|
urlToFilename,
|
|
8
|
-
|
|
8
|
+
ensurePathnameTrailingSlash,
|
|
9
|
+
} from "@jsenv/urls"
|
|
9
10
|
|
|
10
11
|
import { applyFileSystemMagicResolution } from "@jsenv/node-esm-resolution"
|
|
11
|
-
import { ensurePathnameTrailingSlash } from "@jsenv/utils/urls/url_utils.js"
|
|
12
12
|
import { CONTENT_TYPE } from "@jsenv/utils/content_type/content_type.js"
|
|
13
13
|
|
|
14
14
|
export const jsenvPluginFileUrls = ({
|
|
@@ -54,32 +54,30 @@ export const jsenvPluginFileUrls = ({
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
const { search, hash } = urlObject
|
|
57
|
-
const resolveSymlink = (fileUrl) => {
|
|
58
|
-
const realPath = realpathSync(new URL(fileUrl))
|
|
59
|
-
const realFileUrl = `${pathToFileURL(realPath)}${search}${hash}`
|
|
60
|
-
return realFileUrl
|
|
61
|
-
}
|
|
62
|
-
|
|
63
57
|
let { pathname } = urlObject
|
|
64
58
|
const pathnameUsesTrailingSlash = pathname.endsWith("/")
|
|
65
59
|
urlObject.search = ""
|
|
66
60
|
urlObject.hash = ""
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
: resolveSymlink(urlObject.href)
|
|
77
|
-
}
|
|
78
|
-
// give a chane to magic resolution if enabled
|
|
79
|
-
} else if (pathnameUsesTrailingSlash) {
|
|
80
|
-
// a warning would be great because it's strange to reference a file with a trailing slash
|
|
61
|
+
const foundADirectory = stat && stat.isDirectory()
|
|
62
|
+
const foundSomething = stat && !foundADirectory
|
|
63
|
+
// force trailing slash on directories
|
|
64
|
+
if (foundADirectory && !pathnameUsesTrailingSlash) {
|
|
65
|
+
urlObject.pathname = `${pathname}/`
|
|
66
|
+
}
|
|
67
|
+
// otherwise remove trailing slash if any
|
|
68
|
+
if (foundSomething && pathnameUsesTrailingSlash) {
|
|
69
|
+
// a warning here? (because it's strange to reference a file with a trailing slash)
|
|
81
70
|
urlObject.pathname = pathname.slice(0, -1)
|
|
82
71
|
}
|
|
72
|
+
if (foundADirectory && directoryReferenceAllowed) {
|
|
73
|
+
reference.data.foundADirectory = true
|
|
74
|
+
const directoryFacadeUrl = urlObject.href
|
|
75
|
+
const directoryUrlRaw = preservesSymlink
|
|
76
|
+
? directoryFacadeUrl
|
|
77
|
+
: resolveSymlink(directoryFacadeUrl)
|
|
78
|
+
const directoryUrl = `${directoryUrlRaw}${search}${hash}`
|
|
79
|
+
return directoryUrl
|
|
80
|
+
}
|
|
83
81
|
const url = urlObject.href
|
|
84
82
|
const filesystemResolution = applyFileSystemMagicResolution(url, {
|
|
85
83
|
fileStat: stat,
|
|
@@ -90,11 +88,16 @@ export const jsenvPluginFileUrls = ({
|
|
|
90
88
|
),
|
|
91
89
|
})
|
|
92
90
|
if (!filesystemResolution.found) {
|
|
91
|
+
reference.data.foundADirectory = foundADirectory
|
|
93
92
|
return null
|
|
94
93
|
}
|
|
95
|
-
|
|
94
|
+
reference.data.foundADirectory = filesystemResolution.isDirectory
|
|
95
|
+
const fileFacadeUrl = filesystemResolution.url
|
|
96
|
+
const fileUrlRaw = preservesSymlink
|
|
97
|
+
? fileFacadeUrl
|
|
98
|
+
: resolveSymlink(fileFacadeUrl)
|
|
96
99
|
const fileUrl = `${fileUrlRaw}${search}${hash}`
|
|
97
|
-
return
|
|
100
|
+
return fileUrl
|
|
98
101
|
},
|
|
99
102
|
},
|
|
100
103
|
{
|
|
@@ -150,7 +153,7 @@ export const jsenvPluginFileUrls = ({
|
|
|
150
153
|
return null
|
|
151
154
|
}
|
|
152
155
|
const urlObject = new URL(urlInfo.url)
|
|
153
|
-
if (context.reference.
|
|
156
|
+
if (context.reference.data.foundADirectory) {
|
|
154
157
|
if (directoryReferenceAllowed) {
|
|
155
158
|
const directoryEntries = readdirSync(urlObject)
|
|
156
159
|
let filename
|
|
@@ -170,7 +173,7 @@ export const jsenvPluginFileUrls = ({
|
|
|
170
173
|
}
|
|
171
174
|
}
|
|
172
175
|
const error = new Error("found a directory on filesystem")
|
|
173
|
-
error.code = "
|
|
176
|
+
error.code = "DIRECTORY_REFERENCE_NOT_ALLOWED"
|
|
174
177
|
throw error
|
|
175
178
|
}
|
|
176
179
|
const fileBuffer = readFileSync(urlObject)
|
|
@@ -189,3 +192,7 @@ export const jsenvPluginFileUrls = ({
|
|
|
189
192
|
},
|
|
190
193
|
]
|
|
191
194
|
}
|
|
195
|
+
|
|
196
|
+
const resolveSymlink = (fileUrl) => {
|
|
197
|
+
return pathToFileURL(realpathSync(new URL(fileUrl))).href
|
|
198
|
+
}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
removeHtmlNodeText,
|
|
19
19
|
setHtmlNodeGeneratedText,
|
|
20
20
|
} from "@jsenv/utils/html_ast/html_ast.js"
|
|
21
|
-
import { generateInlineContentUrl } from "@jsenv/
|
|
21
|
+
import { generateInlineContentUrl } from "@jsenv/urls"
|
|
22
22
|
|
|
23
23
|
export const jsenvPluginHtmlSupervisor = ({
|
|
24
24
|
logs = false,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
getHtmlNodeTextNode,
|
|
35
35
|
removeHtmlNode,
|
|
36
36
|
} from "@jsenv/utils/html_ast/html_ast.js"
|
|
37
|
-
import { generateInlineContentUrl } from "@jsenv/
|
|
37
|
+
import { generateInlineContentUrl } from "@jsenv/urls"
|
|
38
38
|
|
|
39
39
|
export const jsenvPluginImportmap = () => {
|
|
40
40
|
let finalImportmap = null
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
setHtmlNodeGeneratedText,
|
|
9
9
|
getHtmlNodeAttributeByName,
|
|
10
10
|
} from "@jsenv/utils/html_ast/html_ast.js"
|
|
11
|
-
import { generateInlineContentUrl } from "@jsenv/
|
|
11
|
+
import { generateInlineContentUrl } from "@jsenv/urls"
|
|
12
12
|
import { CONTENT_TYPE } from "@jsenv/utils/content_type/content_type.js"
|
|
13
13
|
|
|
14
14
|
export const jsenvPluginHtmlInlineContent = ({ analyzeConvertedScripts }) => {
|
|
@@ -2,13 +2,13 @@ import { CONTENT_TYPE } from "@jsenv/utils/content_type/content_type.js"
|
|
|
2
2
|
import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
|
|
3
3
|
import { JS_QUOTES } from "@jsenv/utils/string/js_quotes.js"
|
|
4
4
|
import { applyBabelPlugins } from "@jsenv/utils/js_ast/apply_babel_plugins.js"
|
|
5
|
-
import { generateInlineContentUrl } from "@jsenv/
|
|
5
|
+
import { generateInlineContentUrl } from "@jsenv/urls"
|
|
6
6
|
|
|
7
7
|
export const jsenvPluginJsInlineContent = ({ allowEscapeForVersioning }) => {
|
|
8
8
|
const parseAndTransformInlineContentCalls = async (urlInfo, context) => {
|
|
9
9
|
const inlineContentInfos = await parseJsInlineContentInfos({
|
|
10
10
|
js: urlInfo.content,
|
|
11
|
-
url:
|
|
11
|
+
url: urlInfo.originalUrl,
|
|
12
12
|
isJsModule: urlInfo.type === "js_module",
|
|
13
13
|
})
|
|
14
14
|
if (inlineContentInfos.length === 0) {
|
|
@@ -83,7 +83,7 @@ const parseJsInlineContentInfos = async ({ js, url, isJsModule }) => {
|
|
|
83
83
|
const { metadata } = await applyBabelPlugins({
|
|
84
84
|
babelPlugins: [babelPluginMetadataInlineContents],
|
|
85
85
|
urlInfo: {
|
|
86
|
-
url,
|
|
86
|
+
originalUrl: url,
|
|
87
87
|
type: isJsModule ? "js_module" : "js_classic",
|
|
88
88
|
content: js,
|
|
89
89
|
},
|
|
@@ -12,14 +12,13 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { createRequire } from "node:module"
|
|
15
|
-
import {
|
|
15
|
+
import { urlToFilename, injectQueryParams } from "@jsenv/urls"
|
|
16
|
+
import { readFileSync } from "@jsenv/filesystem"
|
|
16
17
|
|
|
17
18
|
import { requireBabelPlugin } from "@jsenv/babel-plugins"
|
|
18
19
|
import { applyBabelPlugins } from "@jsenv/utils/js_ast/apply_babel_plugins.js"
|
|
19
|
-
import { injectQueryParams } from "@jsenv/utils/urls/url_utils.js"
|
|
20
20
|
import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
|
|
21
21
|
import { composeTwoSourcemaps } from "@jsenv/utils/sourcemap/sourcemap_composition_v3.js"
|
|
22
|
-
import { fetchOriginalUrlInfo } from "@jsenv/utils/graph/fetch_original_url_info.js"
|
|
23
22
|
|
|
24
23
|
import { babelPluginTransformImportMetaUrl } from "./helpers/babel_plugin_transform_import_meta_url.js"
|
|
25
24
|
import { jsenvPluginAsJsClassicHtml } from "./jsenv_plugin_as_js_classic_html.js"
|
|
@@ -92,7 +91,7 @@ const jsenvPluginAsJsClassicConversion = ({
|
|
|
92
91
|
},
|
|
93
92
|
},
|
|
94
93
|
fetchUrlContent: async (urlInfo, context) => {
|
|
95
|
-
const originalUrlInfo = await fetchOriginalUrlInfo({
|
|
94
|
+
const originalUrlInfo = await context.fetchOriginalUrlInfo({
|
|
96
95
|
urlInfo,
|
|
97
96
|
context,
|
|
98
97
|
searchParam: "as_js_classic",
|
|
@@ -126,6 +125,8 @@ const jsenvPluginAsJsClassicConversion = ({
|
|
|
126
125
|
})
|
|
127
126
|
urlInfo.data.jsClassicFormat = jsClassicFormat
|
|
128
127
|
return {
|
|
128
|
+
originalUrl: originalUrlInfo.originalUrl,
|
|
129
|
+
originalContent: originalUrlInfo.originalContent,
|
|
129
130
|
type: "js_classic",
|
|
130
131
|
contentType: "text/javascript",
|
|
131
132
|
content,
|
|
@@ -192,18 +193,21 @@ const convertJsModuleToJsClassic = async ({
|
|
|
192
193
|
],
|
|
193
194
|
urlInfo,
|
|
194
195
|
})
|
|
196
|
+
let sourcemap = urlInfo.sourcemap
|
|
197
|
+
sourcemap = await composeTwoSourcemaps(sourcemap, map)
|
|
195
198
|
if (systemJsInjection && jsClassicFormat === "system" && isJsEntryPoint) {
|
|
196
199
|
const magicSource = createMagicSource(code)
|
|
197
200
|
const systemjsCode = readFileSync(systemJsClientFileUrl, { as: "string" })
|
|
198
201
|
magicSource.prepend(`${systemjsCode}\n\n`)
|
|
199
|
-
const
|
|
202
|
+
const magicResult = magicSource.toContentAndSourcemap()
|
|
203
|
+
sourcemap = await composeTwoSourcemaps(sourcemap, magicResult.sourcemap)
|
|
200
204
|
return {
|
|
201
|
-
content,
|
|
202
|
-
sourcemap
|
|
205
|
+
content: magicResult.content,
|
|
206
|
+
sourcemap,
|
|
203
207
|
}
|
|
204
208
|
}
|
|
205
209
|
return {
|
|
206
210
|
content: code,
|
|
207
|
-
sourcemap
|
|
211
|
+
sourcemap,
|
|
208
212
|
}
|
|
209
213
|
}
|
|
@@ -11,8 +11,10 @@ import {
|
|
|
11
11
|
injectScriptAsEarlyAsPossible,
|
|
12
12
|
createHtmlNode,
|
|
13
13
|
} from "@jsenv/utils/html_ast/html_ast.js"
|
|
14
|
-
import {
|
|
15
|
-
|
|
14
|
+
import {
|
|
15
|
+
generateInlineContentUrl,
|
|
16
|
+
injectQueryParamsIntoSpecifier,
|
|
17
|
+
} from "@jsenv/urls"
|
|
16
18
|
|
|
17
19
|
export const jsenvPluginAsJsClassicHtml = ({
|
|
18
20
|
systemJsInjection,
|
|
@@ -10,11 +10,9 @@
|
|
|
10
10
|
* But for now (as it is simpler) we let the browser throw the error
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { urlToFilename } from "@jsenv/
|
|
13
|
+
import { urlToFilename, injectQueryParams } from "@jsenv/urls"
|
|
14
14
|
|
|
15
|
-
import { injectQueryParams } from "@jsenv/utils/urls/url_utils.js"
|
|
16
15
|
import { JS_QUOTES } from "@jsenv/utils/string/js_quotes.js"
|
|
17
|
-
import { fetchOriginalUrlInfo } from "@jsenv/utils/graph/fetch_original_url_info.js"
|
|
18
16
|
|
|
19
17
|
export const jsenvPluginImportAssertions = () => {
|
|
20
18
|
const updateReference = (reference, searchParam) => {
|
|
@@ -89,7 +87,7 @@ const jsenvPluginAsModules = () => {
|
|
|
89
87
|
name: `jsenv:as_json_module`,
|
|
90
88
|
appliesDuring: "*",
|
|
91
89
|
fetchUrlContent: async (urlInfo, context) => {
|
|
92
|
-
const originalUrlInfo = await fetchOriginalUrlInfo({
|
|
90
|
+
const originalUrlInfo = await context.fetchOriginalUrlInfo({
|
|
93
91
|
urlInfo,
|
|
94
92
|
context,
|
|
95
93
|
searchParam: "as_json_module",
|
|
@@ -100,6 +98,8 @@ const jsenvPluginAsModules = () => {
|
|
|
100
98
|
}
|
|
101
99
|
const jsonText = JSON.stringify(originalUrlInfo.content.trim())
|
|
102
100
|
return {
|
|
101
|
+
originalUrl: originalUrlInfo.originalUrl,
|
|
102
|
+
originalContent: originalUrlInfo.originalContent,
|
|
103
103
|
type: "js_module",
|
|
104
104
|
contentType: "text/javascript",
|
|
105
105
|
// here we could `export default ${jsonText}`:
|
|
@@ -114,7 +114,7 @@ const jsenvPluginAsModules = () => {
|
|
|
114
114
|
name: `jsenv:as_css_module`,
|
|
115
115
|
appliesDuring: "*",
|
|
116
116
|
fetchUrlContent: async (urlInfo, context) => {
|
|
117
|
-
const originalUrlInfo = await fetchOriginalUrlInfo({
|
|
117
|
+
const originalUrlInfo = await context.fetchOriginalUrlInfo({
|
|
118
118
|
urlInfo,
|
|
119
119
|
context,
|
|
120
120
|
searchParam: "as_css_module",
|
|
@@ -130,6 +130,8 @@ const jsenvPluginAsModules = () => {
|
|
|
130
130
|
canUseTemplateString: true,
|
|
131
131
|
})
|
|
132
132
|
return {
|
|
133
|
+
originalUrl: originalUrlInfo.originalUrl,
|
|
134
|
+
originalContent: originalUrlInfo.originalContent,
|
|
133
135
|
type: "js_module",
|
|
134
136
|
contentType: "text/javascript",
|
|
135
137
|
content: `import { InlineContent } from ${JSON.stringify(
|
|
@@ -148,7 +150,7 @@ const jsenvPluginAsModules = () => {
|
|
|
148
150
|
name: `jsenv:as_text_module`,
|
|
149
151
|
appliesDuring: "*",
|
|
150
152
|
fetchUrlContent: async (urlInfo, context) => {
|
|
151
|
-
const originalUrlInfo = await fetchOriginalUrlInfo({
|
|
153
|
+
const originalUrlInfo = await context.fetchOriginalUrlInfo({
|
|
152
154
|
urlInfo,
|
|
153
155
|
context,
|
|
154
156
|
searchParam: "as_text_module",
|
|
@@ -164,6 +166,8 @@ const jsenvPluginAsModules = () => {
|
|
|
164
166
|
canUseTemplateString: true,
|
|
165
167
|
})
|
|
166
168
|
return {
|
|
169
|
+
originalUrl: originalUrlInfo.originalUrl,
|
|
170
|
+
originalContent: originalUrlInfo.originalContent,
|
|
167
171
|
type: "js_module",
|
|
168
172
|
contentType: "text/javascript",
|
|
169
173
|
content: `import { InlineContent } from ${JSON.stringify(
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { htmlAttributeSrcSet } from "@jsenv/utils/html_ast/html_attribute_src_set.js"
|
|
9
9
|
|
|
10
10
|
export const parseAndTransformHtmlUrls = async (urlInfo, context) => {
|
|
11
|
-
const url = urlInfo.
|
|
11
|
+
const url = urlInfo.originalUrl
|
|
12
12
|
const content = urlInfo.content
|
|
13
13
|
const { scenario, referenceUtils } = context
|
|
14
14
|
const htmlAst = parseHtmlString(content, {
|
|
@@ -5,7 +5,7 @@ import { isWebWorkerUrlInfo } from "@jsenv/core/src/omega/web_workers.js"
|
|
|
5
5
|
export const parseAndTransformJsUrls = async (urlInfo, context) => {
|
|
6
6
|
const jsMentions = await parseJsUrls({
|
|
7
7
|
js: urlInfo.content,
|
|
8
|
-
url:
|
|
8
|
+
url: urlInfo.originalUrl,
|
|
9
9
|
isJsModule: urlInfo.type === "js_module",
|
|
10
10
|
isWebWorker: isWebWorkerUrlInfo(urlInfo),
|
|
11
11
|
})
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
normalizeStructuredMetaMap,
|
|
3
|
-
urlToMeta,
|
|
4
|
-
urlToRelativeUrl,
|
|
5
|
-
} from "@jsenv/filesystem"
|
|
1
|
+
import { urlToRelativeUrl, URL_META } from "@jsenv/urls"
|
|
6
2
|
|
|
7
3
|
import { parseAndTransformHtmlUrls } from "./html/html_urls.js"
|
|
8
4
|
import { parseAndTransformCssUrls } from "./css/css_urls.js"
|
|
@@ -12,18 +8,13 @@ import { parseAndTransformWebmanifestUrls } from "./webmanifest/webmanifest_urls
|
|
|
12
8
|
export const jsenvPluginUrlAnalysis = ({ rootDirectoryUrl, include }) => {
|
|
13
9
|
let getIncludeInfo = () => undefined
|
|
14
10
|
if (include) {
|
|
15
|
-
const
|
|
16
|
-
{
|
|
17
|
-
include,
|
|
18
|
-
},
|
|
11
|
+
const associations = URL_META.resolveAssociations(
|
|
12
|
+
{ include },
|
|
19
13
|
rootDirectoryUrl,
|
|
20
14
|
)
|
|
21
15
|
getIncludeInfo = (url) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
structuredMetaMap: includeMetaMap,
|
|
25
|
-
})
|
|
26
|
-
return meta.include
|
|
16
|
+
const { include } = URL_META.applyAssociations({ url, associations })
|
|
17
|
+
return include
|
|
27
18
|
}
|
|
28
19
|
}
|
|
29
20
|
|
package/src/test/execute_plan.js
CHANGED
|
@@ -3,17 +3,15 @@ import { memoryUsage } from "node:process"
|
|
|
3
3
|
import wrapAnsi from "wrap-ansi"
|
|
4
4
|
import stripAnsi from "strip-ansi"
|
|
5
5
|
import cuid from "cuid"
|
|
6
|
+
import { URL_META, urlToFileSystemPath } from "@jsenv/urls"
|
|
7
|
+
import { createDetailedMessage, loggerToLevels } from "@jsenv/logger"
|
|
8
|
+
import { createLog, startSpinner } from "@jsenv/log"
|
|
9
|
+
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
6
10
|
import {
|
|
7
|
-
urlToFileSystemPath,
|
|
8
11
|
writeDirectory,
|
|
9
12
|
ensureEmptyDirectory,
|
|
10
|
-
normalizeStructuredMetaMap,
|
|
11
|
-
urlToMeta,
|
|
12
13
|
writeFileSync,
|
|
13
14
|
} from "@jsenv/filesystem"
|
|
14
|
-
import { createDetailedMessage, loggerToLevels } from "@jsenv/logger"
|
|
15
|
-
import { createLog, startSpinner } from "@jsenv/log"
|
|
16
|
-
import { Abort, raceProcessTeardownEvents } from "@jsenv/abort"
|
|
17
15
|
|
|
18
16
|
import { babelPluginInstrument } from "@jsenv/utils/coverage/babel_plugin_instrument.js"
|
|
19
17
|
import { reportToCoverage } from "@jsenv/utils/coverage/report_to_coverage.js"
|
|
@@ -214,7 +212,7 @@ export const executePlan = async (
|
|
|
214
212
|
// if there is an error during execution npm will mess up the output
|
|
215
213
|
// (happens when npm runs several command in a workspace)
|
|
216
214
|
// so we enable spinner only when !process.exitCode (no error so far)
|
|
217
|
-
|
|
215
|
+
process.exitCode !== 1
|
|
218
216
|
|
|
219
217
|
const startMs = Date.now()
|
|
220
218
|
const report = {}
|
|
@@ -231,17 +229,16 @@ export const executePlan = async (
|
|
|
231
229
|
).href
|
|
232
230
|
|
|
233
231
|
if (coverage) {
|
|
234
|
-
const
|
|
235
|
-
{
|
|
236
|
-
cover: coverageConfig,
|
|
237
|
-
},
|
|
232
|
+
const associations = URL_META.resolveAssociations(
|
|
233
|
+
{ cover: coverageConfig },
|
|
238
234
|
rootDirectoryUrl,
|
|
239
235
|
)
|
|
240
236
|
const urlShouldBeCovered = (url) => {
|
|
241
|
-
|
|
237
|
+
const { cover } = URL_META.applyAssociations({
|
|
242
238
|
url: new URL(url, rootDirectoryUrl).href,
|
|
243
|
-
|
|
244
|
-
})
|
|
239
|
+
associations,
|
|
240
|
+
})
|
|
241
|
+
return cover
|
|
245
242
|
}
|
|
246
243
|
runtimeParams.urlShouldBeCovered = urlShouldBeCovered
|
|
247
244
|
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
+
import { urlToFileSystemPath, resolveDirectoryUrl, URL_META } from "@jsenv/urls"
|
|
1
2
|
import {
|
|
2
|
-
normalizeStructuredMetaMap,
|
|
3
|
-
urlToFileSystemPath,
|
|
4
3
|
ensureEmptyDirectory,
|
|
5
|
-
resolveDirectoryUrl,
|
|
6
|
-
urlToMeta,
|
|
7
4
|
assertAndNormalizeDirectoryUrl,
|
|
8
5
|
} from "@jsenv/filesystem"
|
|
9
6
|
import { createLogger, createDetailedMessage } from "@jsenv/logger"
|
|
@@ -113,25 +110,22 @@ export const executeTestPlan = async ({
|
|
|
113
110
|
)
|
|
114
111
|
}
|
|
115
112
|
if (!coverageAndExecutionAllowed) {
|
|
116
|
-
const
|
|
117
|
-
{
|
|
118
|
-
execute: testPlan,
|
|
119
|
-
},
|
|
113
|
+
const associationsForExecute = URL_META.resolveAssociations(
|
|
114
|
+
{ execute: testPlan },
|
|
120
115
|
"file:///",
|
|
121
116
|
)
|
|
122
|
-
const
|
|
123
|
-
{
|
|
124
|
-
cover: coverageConfig,
|
|
125
|
-
},
|
|
117
|
+
const associationsForCover = URL_META.resolveAssociations(
|
|
118
|
+
{ cover: coverageConfig },
|
|
126
119
|
"file:///",
|
|
127
120
|
)
|
|
128
121
|
const patternsMatchingCoverAndExecute = Object.keys(
|
|
129
|
-
|
|
122
|
+
associationsForExecute.execute,
|
|
130
123
|
).filter((testPlanPattern) => {
|
|
131
|
-
|
|
124
|
+
const { cover } = URL_META.applyAssociations({
|
|
132
125
|
url: testPlanPattern,
|
|
133
|
-
|
|
134
|
-
})
|
|
126
|
+
associations: associationsForCover,
|
|
127
|
+
})
|
|
128
|
+
return cover
|
|
135
129
|
})
|
|
136
130
|
if (patternsMatchingCoverAndExecute.length) {
|
|
137
131
|
// It would be strange, for a given file to be both covered and executed
|
|
@@ -5,13 +5,10 @@ export const generateExecutionSteps = async (
|
|
|
5
5
|
plan,
|
|
6
6
|
{ signal, rootDirectoryUrl },
|
|
7
7
|
) => {
|
|
8
|
-
const structuredMetaMap = {
|
|
9
|
-
filePlan: plan,
|
|
10
|
-
}
|
|
11
8
|
const fileResultArray = await collectFiles({
|
|
12
9
|
signal,
|
|
13
10
|
directoryUrl: rootDirectoryUrl,
|
|
14
|
-
|
|
11
|
+
associations: { filePlan: plan },
|
|
15
12
|
predicate: ({ filePlan }) => filePlan,
|
|
16
13
|
})
|
|
17
14
|
const executionSteps = []
|