@jsenv/core 24.1.0-alpha.0 → 24.3.1
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/{license → LICENSE} +0 -0
- package/dist/browser_runtime/browser_runtime-fbd309a1.js +5137 -0
- package/dist/browser_runtime/browser_runtime-fbd309a1.js.map +1064 -0
- package/dist/{jsenv_browser_system.js → browser_system/browser_system-29eda202.js} +12 -12
- package/dist/{jsenv_browser_system.js.map → browser_system/browser_system-29eda202.js.map} +64 -64
- package/dist/build_manifest.js +12 -0
- package/dist/compile_proxy/assets/s.js-749702e8.map +242 -0
- package/dist/compile_proxy/compile_proxy-405777e6.html +2074 -0
- package/dist/compile_proxy/compile_proxy.html__inline__20-39c0801c.js.map +385 -0
- package/dist/event_source_client/event_source_client-9f14c8b9.js +356 -0
- package/dist/event_source_client/event_source_client-9f14c8b9.js.map +127 -0
- package/dist/redirector/assets/s.js-749702e8.map +242 -0
- package/dist/redirector/redirector-237cd168.html +2118 -0
- package/dist/redirector/redirector.html__inline__15-33acb0b9.js.map +390 -0
- package/dist/toolbar/assets/compilation.css-209d68b4.map +12 -0
- package/dist/toolbar/assets/eventsource.css-38cd0a36.map +12 -0
- package/dist/toolbar/assets/execution.css-0ebe522f.map +12 -0
- package/dist/toolbar/assets/focus.css-3f9c156d.map +12 -0
- package/dist/toolbar/assets/light-theme.css-78b19a80.map +12 -0
- package/dist/toolbar/assets/overflow-menu.css-d9688a1c.map +12 -0
- package/dist/toolbar/assets/s.js-749702e8.map +242 -0
- package/dist/toolbar/assets/settings.css-2b81b245.map +12 -0
- package/dist/toolbar/assets/toolbar.main.css-846920e9.map +28 -0
- package/dist/toolbar/assets/tooltip.css-03395ee6.map +12 -0
- package/dist/toolbar/toolbar-d3d98c2e.html +4778 -0
- package/dist/toolbar/toolbar.main-cab36c15.js.map +795 -0
- package/dist/toolbar_injector/assets/jsenv-logo-188b9ca6.svg +95 -0
- package/dist/{jsenv_toolbar_injector.js → toolbar_injector/toolbar_injector-01f71ce3.js} +62 -137
- package/dist/toolbar_injector/toolbar_injector-01f71ce3.js.map +294 -0
- package/main.js +0 -1
- package/package.json +4 -2
- package/readme.md +10 -7
- package/src/buildProject.js +8 -2
- package/src/dev_server.js +45 -102
- package/src/importUsingChildProcess.js +1 -1
- package/src/internal/{runtime/detectBrowser/detectBrowser.js → browser_detection/browser_detection.js} +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectAndroid.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectChrome.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectEdge.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectElectron.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectFirefox.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectIOS.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectInternetExplorer.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectOpera.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/detectSafari.js +0 -0
- package/src/internal/{runtime/detectBrowser → browser_detection}/util.js +0 -0
- package/src/internal/{runtime/createBrowserRuntime/scanBrowserRuntimeFeatures.js → browser_feature_detection/browser_feature_detection.js} +116 -81
- package/src/internal/browser_feature_detection/compile_proxy.html +27 -0
- package/src/internal/{browser-launcher → browser_launcher}/createSharing.js +0 -0
- package/src/internal/{browser-launcher → browser_launcher}/executeHtmlFile.js +7 -4
- package/src/internal/{browser-launcher → browser_launcher}/trackPageToNotify.js +0 -0
- package/src/internal/{browser-launcher/jsenv-browser-system.js → browser_runtime/browser_runtime.js} +4 -4
- package/src/internal/{runtime/createBrowserRuntime/createBrowserSystem.js → browser_runtime/browser_system.js} +3 -2
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/createBrowserRuntime.js +7 -5
- package/src/internal/{browser-launcher → browser_runtime}/displayErrorInDocument.js +0 -0
- package/src/internal/{browser-launcher → browser_runtime}/displayErrorNotification.js +2 -4
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/evalSource.js +2 -0
- package/src/internal/{runtime/createBrowserRuntime → browser_runtime}/makeNamespaceTransferable.js +0 -0
- package/src/internal/{browser-utils → browser_utils}/fetch-browser.js +2 -0
- package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingFetch.js +3 -0
- package/src/internal/{browser-utils → browser_utils}/fetchAndEvalUsingScript.js +2 -0
- package/src/internal/{browser-utils → browser_utils}/fetchJson.js +0 -0
- package/src/internal/{browser-utils → browser_utils}/fetchUsingXHR.js +4 -4
- package/src/internal/building/buildUsingRollup.js +4 -0
- package/src/internal/building/createJsenvRollupPlugin.js +19 -9
- package/src/internal/building/css/applyPostCss.js +19 -8
- package/src/internal/building/css/moveCssUrls.js +44 -0
- package/src/internal/building/css/parseCssRessource.js +67 -17
- package/src/internal/building/css/parseCssUrls.js +29 -23
- package/src/internal/building/css/postcss_plugin_url_visitor.js +11 -20
- package/src/internal/building/css/replaceCssUrls.js +38 -19
- package/src/internal/building/css_module.js +6 -10
- package/src/internal/building/html/parseHtmlRessource.js +37 -11
- package/src/internal/building/parseRessource.js +3 -0
- package/src/internal/building/ressource_builder.js +12 -3
- package/src/internal/compiling/babel_plugin_import_assertions.js +1 -2
- package/src/internal/compiling/compile-directory/validateCache.js +0 -5
- package/src/internal/compiling/compileFile.js +17 -54
- package/src/internal/compiling/createCompiledFileService.js +2 -0
- package/src/internal/compiling/html_source_file_service.js +49 -13
- package/src/internal/compiling/jsenvCompilerForHtml.js +29 -12
- package/src/internal/compiling/startCompileServer.js +39 -33
- package/src/internal/dev_server/event_source_client/event_source_client.js +63 -0
- package/src/internal/{toolbar/eventsource/connectEventSource.js → dev_server/event_source_client/event_source_connection.js} +66 -88
- package/src/internal/dev_server/event_source_client/file_changes.js +82 -0
- package/src/internal/dev_server/event_source_client/livereload_preference.js +13 -0
- package/src/internal/{exploring → dev_server/exploring}/exploring.css +0 -0
- package/src/internal/{exploring → dev_server/exploring}/exploring.html +8 -3
- package/src/internal/{exploring → dev_server/exploring}/exploring.js +0 -0
- package/src/internal/{exploring → dev_server/exploring}/fetchExploringJson.js +4 -9
- package/src/internal/dev_server/redirector/redirector.html +48 -0
- package/src/internal/{toolbar → dev_server/toolbar}/animation/toolbar.animation.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/compilation/compilation.css +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/compilation/toolbar.compilation.js +4 -7
- package/src/internal/{toolbar → dev_server/toolbar}/eventsource/eventsource.css +0 -0
- package/src/internal/dev_server/toolbar/eventsource/toolbar.eventsource.js +83 -0
- package/src/internal/{toolbar → dev_server/toolbar}/execution/execution.css +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/execution/toolbar.execution.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/focus/focus.css +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/focus/toolbar.focus.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/jsenv-logo.svg +0 -0
- package/src/internal/dev_server/toolbar/notification/toolbar.notification.js +152 -0
- package/src/internal/{toolbar → dev_server/toolbar}/responsive/overflow-menu.css +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/responsive/toolbar.responsive.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/settings/settings.css +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/settings/toolbar.settings.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/theme/jsenv-theme.css +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/theme/light-theme.css +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/theme/toolbar.theme.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/toolbar.html +35 -42
- package/src/internal/{toolbar → dev_server/toolbar}/toolbar.injector.js +53 -125
- package/src/internal/{toolbar → dev_server/toolbar}/toolbar.main.css +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/toolbar.main.js +44 -31
- package/src/internal/{toolbar → dev_server/toolbar}/tooltip/tooltip.css +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/tooltip/tooltip.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/util/animation.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/util/dom.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/util/fetching.js +2 -2
- package/src/internal/{toolbar → dev_server/toolbar}/util/jsenvLogger.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/util/preferences.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/util/responsive.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/util/util.js +0 -0
- package/src/internal/{toolbar → dev_server/toolbar}/variant/variant.js +0 -0
- package/src/internal/generateGroupMap/one_runtime_compat.js +1 -1
- package/src/internal/generateGroupMap/runtime_compat_composition.js +1 -1
- package/src/internal/generateGroupMap/runtime_support.js +1 -1
- package/src/internal/jsenvInternalFiles.js +0 -84
- package/src/internal/jsenv_builds.js +19 -0
- package/src/internal/{runtime/node-feature-detect/feature-detect-dynamic-import.mjs → node_feature_detection/feature_detect_dynamic_import.mjs} +0 -0
- package/src/internal/{runtime/node-feature-detect/feature-detect-top-level-await.mjs → node_feature_detection/feature_detect_top_level_await.mjs} +0 -0
- package/src/internal/{runtime/node-feature-detect → node_feature_detection}/nodeSupportsDynamicImport.js +0 -0
- package/src/internal/node_feature_detection/nodeSupportsTopLevelAwait.js +16 -0
- package/src/internal/{runtime/createNodeRuntime/scanNodeRuntimeFeatures.js → node_feature_detection/node_feature_detection.js} +12 -13
- package/src/internal/{node-launcher → node_launcher}/createChildProcessOptions.js +0 -0
- package/src/internal/{node-launcher → node_launcher}/createControllableNodeProcess.js +9 -14
- package/src/internal/{node-launcher → node_launcher}/kill_process_tree.js +0 -0
- package/src/internal/{node-launcher → node_launcher}/processOptions.js +0 -0
- package/src/internal/{runtime/detectNode → node_runtime}/detectNode.js +0 -0
- package/src/internal/{runtime/createNodeRuntime → node_runtime}/evalSource.js +1 -1
- package/src/internal/{runtime/createNodeRuntime → node_runtime}/fetchSource.js +1 -1
- package/src/internal/{node-launcher → node_runtime}/nodeControllableFile.mjs +14 -11
- package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithDynamicImport.js → node_runtime/node_execution_dynamic_import.js} +34 -6
- package/src/internal/node_runtime/node_execution_performance.js +67 -0
- package/src/internal/{runtime/createNodeRuntime/createNodeExecutionWithSystemJs.js → node_runtime/node_execution_systemjs.js} +38 -24
- package/src/internal/{runtime/createNodeRuntime/createNodeSystem.js → node_runtime/node_system.js} +4 -4
- package/src/internal/runtime/computeCompileIdFromGroupId.js +1 -0
- package/src/internal/runtime/resolveGroup.js +1 -1
- package/src/internal/runtime/resolveRuntimeGroup.js +2 -2
- package/src/internal/{semantic-versioning → semantic_versioning}/findHighestVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/findLowestVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/index.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/valueToVersion.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionCompare.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsAbove.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsBelow.js +0 -0
- package/src/internal/{semantic-versioning → semantic_versioning}/versionIsEqual.js +0 -0
- package/src/launchBrowser.js +3 -3
- package/src/launchNode.js +33 -7
- package/src/requireUsingChildProcess.js +1 -1
- package/dist/jsenv_compile_proxy.js +0 -1339
- package/dist/jsenv_compile_proxy.js.map +0 -378
- package/dist/jsenv_exploring_index.js +0 -1092
- package/dist/jsenv_exploring_index.js.map +0 -353
- package/dist/jsenv_exploring_redirector.js +0 -1386
- package/dist/jsenv_exploring_redirector.js.map +0 -384
- package/dist/jsenv_toolbar.js +0 -3347
- package/dist/jsenv_toolbar.js.map +0 -846
- package/dist/jsenv_toolbar_injector.js.map +0 -320
- package/src/internal/browser-launcher/jsenv_compile_proxy.html +0 -13
- package/src/internal/browser-launcher/jsenv_compile_proxy.js +0 -5
- package/src/internal/exploring/exploring.redirector.html +0 -13
- package/src/internal/exploring/exploring.redirector.js +0 -28
- package/src/internal/node-launcher/node-js-file.js +0 -110
- package/src/internal/runtime/createNodeRuntime/createNodeRuntime.js +0 -32
- package/src/internal/runtime/node-feature-detect/nodeSupportsTopLevelAwait.js +0 -18
- package/src/internal/toolbar/backtolist/toolbar.backtolist.js +0 -33
- package/src/internal/toolbar/eventsource/connectCompileServerEventSource.js +0 -74
- package/src/internal/toolbar/eventsource/toolbar.eventsource.js +0 -239
- package/src/internal/toolbar/notification/toolbar.notification.js +0 -121
- package/src/nodeRuntime.js +0 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveUrl, urlToRelativeUrl } from "@jsenv/filesystem"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { moveCssUrls } from "@jsenv/core/src/internal/building/css/moveCssUrls.js"
|
|
4
4
|
import { escapeTemplateStringSpecialCharacters } from "@jsenv/core/src/internal/escapeTemplateStringSpecialCharacters.js"
|
|
5
5
|
import {
|
|
6
6
|
getCssSourceMappingUrl,
|
|
@@ -16,18 +16,14 @@ export const convertCssTextToJavascriptModule = async ({
|
|
|
16
16
|
const directoryUrl = resolveUrl("./", cssUrl)
|
|
17
17
|
const jsDirectoryUrl = resolveUrl("./", jsUrl)
|
|
18
18
|
if (directoryUrl !== jsDirectoryUrl) {
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const moveUrlResult = await moveCssUrls({
|
|
20
|
+
from: cssUrl,
|
|
21
|
+
to: jsUrl,
|
|
21
22
|
code,
|
|
22
23
|
map,
|
|
23
|
-
getUrlReplacementValue: ({ specifier }) => {
|
|
24
|
-
const urlForCss = resolveUrl(specifier, cssUrl)
|
|
25
|
-
const urlForJs = urlToRelativeUrl(urlForCss, jsUrl)
|
|
26
|
-
return urlForJs
|
|
27
|
-
},
|
|
28
24
|
})
|
|
29
|
-
code =
|
|
30
|
-
map =
|
|
25
|
+
code = moveUrlResult.code
|
|
26
|
+
map = moveUrlResult.map
|
|
31
27
|
const sourcemapUrlSpecifier = getCssSourceMappingUrl(code)
|
|
32
28
|
const sourcemapUrlForCss = resolveUrl(sourcemapUrlSpecifier, cssUrl)
|
|
33
29
|
const sourcemapUrlForJs = urlToRelativeUrl(sourcemapUrlForCss, jsUrl)
|
|
@@ -51,6 +51,7 @@ import {
|
|
|
51
51
|
import { collectNodesMutations } from "../parsing.utils.js"
|
|
52
52
|
|
|
53
53
|
import { collectSvgMutations } from "../svg/parseSvgRessource.js"
|
|
54
|
+
import { moveCssUrls } from "../css/moveCssUrls.js"
|
|
54
55
|
|
|
55
56
|
export const parseHtmlRessource = async (
|
|
56
57
|
htmlRessource,
|
|
@@ -144,11 +145,12 @@ export const parseHtmlRessource = async (
|
|
|
144
145
|
]
|
|
145
146
|
|
|
146
147
|
return async (params) => {
|
|
147
|
-
htmlMutations.
|
|
148
|
-
|
|
148
|
+
await htmlMutations.reduce(async (previous, mutationCallback) => {
|
|
149
|
+
await previous
|
|
150
|
+
await mutationCallback({
|
|
149
151
|
...params,
|
|
150
152
|
})
|
|
151
|
-
})
|
|
153
|
+
}, Promise.resolve())
|
|
152
154
|
|
|
153
155
|
const htmlAfterTransformation = htmlAstToHtmlString(htmlAst)
|
|
154
156
|
const html = minify
|
|
@@ -507,7 +509,11 @@ const linkStylesheetHrefVisitor = (
|
|
|
507
509
|
ressourceSpecifier: hrefAttribute.value,
|
|
508
510
|
...referenceLocationFromHtmlNode(link, "href"),
|
|
509
511
|
})
|
|
510
|
-
return ({
|
|
512
|
+
return async ({
|
|
513
|
+
getUrlRelativeToImporter,
|
|
514
|
+
precomputeBuildRelativeUrl,
|
|
515
|
+
buildDirectoryUrl,
|
|
516
|
+
}) => {
|
|
511
517
|
const { ressource } = cssReference
|
|
512
518
|
|
|
513
519
|
if (ressource.isExternal) {
|
|
@@ -516,18 +522,38 @@ const linkStylesheetHrefVisitor = (
|
|
|
516
522
|
|
|
517
523
|
if (shouldInline({ ressource, htmlNode: link })) {
|
|
518
524
|
const { bufferAfterBuild } = ressource
|
|
519
|
-
let
|
|
520
|
-
const
|
|
525
|
+
let code = String(bufferAfterBuild)
|
|
526
|
+
const { buildRelativeUrl } = ressource
|
|
527
|
+
const cssBuildUrl = resolveUrl(buildRelativeUrl, buildDirectoryUrl)
|
|
528
|
+
const htmlUrl = resolveUrl(
|
|
529
|
+
precomputeBuildRelativeUrl(htmlRessource),
|
|
530
|
+
buildDirectoryUrl,
|
|
531
|
+
)
|
|
532
|
+
|
|
533
|
+
const moveResult = await moveCssUrls({
|
|
534
|
+
code,
|
|
535
|
+
from: cssBuildUrl,
|
|
536
|
+
to: htmlUrl,
|
|
537
|
+
// moveCssUrls will change the css source code
|
|
538
|
+
// Ideally we should update the sourcemap referenced by css
|
|
539
|
+
// to target the one after css urls are moved.
|
|
540
|
+
// It means we should force sourcemap ressource to the new one
|
|
541
|
+
// until it's supported we prevent postcss from updating the
|
|
542
|
+
// sourcemap comment, othwise css would reference a sourcemap
|
|
543
|
+
// that won't by in the build directory
|
|
544
|
+
sourcemapMethod: null,
|
|
545
|
+
})
|
|
546
|
+
code = moveResult.code
|
|
547
|
+
|
|
548
|
+
const sourcemapRelativeUrl = getCssSourceMappingUrl(code)
|
|
521
549
|
if (sourcemapRelativeUrl) {
|
|
522
|
-
const
|
|
523
|
-
const cssBuildUrl = resolveUrl(buildRelativeUrl, "file:///")
|
|
550
|
+
const cssBuildUrl = resolveUrl(buildRelativeUrl, buildDirectoryUrl)
|
|
524
551
|
const sourcemapBuildUrl = resolveUrl(sourcemapRelativeUrl, cssBuildUrl)
|
|
525
|
-
const htmlUrl = resolveUrl(htmlRessource.fileNamePattern, "file:///")
|
|
526
552
|
const sourcemapInlineUrl = urlToRelativeUrl(sourcemapBuildUrl, htmlUrl)
|
|
527
|
-
|
|
553
|
+
code = setCssSourceMappingUrl(code, sourcemapInlineUrl)
|
|
528
554
|
}
|
|
529
555
|
|
|
530
|
-
replaceHtmlNode(link, `<style>${
|
|
556
|
+
replaceHtmlNode(link, `<style>${code}</style>`, {
|
|
531
557
|
attributesToIgnore: ["href", "rel", "as", "crossorigin", "type"],
|
|
532
558
|
})
|
|
533
559
|
cssReference.inlinedCallback()
|
|
@@ -39,6 +39,7 @@ export const parseRessource = (
|
|
|
39
39
|
minifyJs,
|
|
40
40
|
minifyHtml,
|
|
41
41
|
minifyCssOptions,
|
|
42
|
+
cssConcatenation,
|
|
42
43
|
},
|
|
43
44
|
) => {
|
|
44
45
|
const { contentType } = ressource
|
|
@@ -124,10 +125,12 @@ export const parseRessource = (
|
|
|
124
125
|
|
|
125
126
|
if (contentType === "text/css") {
|
|
126
127
|
return parseCssRessource(ressource, notifiers, {
|
|
128
|
+
asProjectUrl,
|
|
127
129
|
asOriginalUrl,
|
|
128
130
|
asOriginalServerUrl,
|
|
129
131
|
minify,
|
|
130
132
|
minifyCssOptions,
|
|
133
|
+
cssConcatenation,
|
|
131
134
|
})
|
|
132
135
|
}
|
|
133
136
|
|
|
@@ -49,6 +49,7 @@ export const createRessourceBuilder = (
|
|
|
49
49
|
entryUrl,
|
|
50
50
|
entryBuffer,
|
|
51
51
|
entryBuildRelativeUrl,
|
|
52
|
+
urlVersionningForEntryPoints,
|
|
52
53
|
}) => {
|
|
53
54
|
// The entry point is conceptually referenced by code passing "entryPointMap"
|
|
54
55
|
// to buildProject. So we analyse stack trace to put this function caller
|
|
@@ -68,8 +69,12 @@ export const createRessourceBuilder = (
|
|
|
68
69
|
isEntryPoint: true,
|
|
69
70
|
|
|
70
71
|
// don't hash asset entry points
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
...(urlVersionningForEntryPoints
|
|
73
|
+
? {}
|
|
74
|
+
: {
|
|
75
|
+
urlVersioningDisabled: true,
|
|
76
|
+
fileNamePattern: entryBuildRelativeUrl,
|
|
77
|
+
}),
|
|
73
78
|
})
|
|
74
79
|
entryReference.isProgrammatic = true
|
|
75
80
|
|
|
@@ -567,6 +572,10 @@ export const createRessourceBuilder = (
|
|
|
567
572
|
)
|
|
568
573
|
await transform({
|
|
569
574
|
buildDirectoryUrl,
|
|
575
|
+
precomputeBuildRelativeUrl: (ressource) =>
|
|
576
|
+
precomputeBuildRelativeUrlForRessource(ressource, {
|
|
577
|
+
lineBreakNormalization,
|
|
578
|
+
}),
|
|
570
579
|
getUrlRelativeToImporter: (referencedRessource) => {
|
|
571
580
|
const ressourceImporter = ressource
|
|
572
581
|
|
|
@@ -1021,7 +1030,7 @@ const isEmitChunkNeeded = ({ ressource, reference }) => {
|
|
|
1021
1030
|
*
|
|
1022
1031
|
* see also:
|
|
1023
1032
|
* - https://rollupjs.org/guide/en/#thisemitfileemittedfile-emittedchunk--emittedasset--string
|
|
1024
|
-
* -https://github.com/rollup/rollup/issues/2872
|
|
1033
|
+
* - https://github.com/rollup/rollup/issues/2872
|
|
1025
1034
|
*/
|
|
1026
1035
|
const referenceShouldBeIgnoredWarning = ({
|
|
1027
1036
|
isJsModule,
|
|
@@ -10,8 +10,7 @@ export const babelPluginImportAssertions = (
|
|
|
10
10
|
return {
|
|
11
11
|
...babelPluginImportVisitor(
|
|
12
12
|
babel,
|
|
13
|
-
// During
|
|
14
|
-
// sepcifier or type is dynamic.
|
|
13
|
+
// During build we throw on import call expression where "specifier" or "type" is dynamic
|
|
15
14
|
// Here there is no strong need to throw because keeping the source code intact
|
|
16
15
|
// will throw an error when browser will execute the code
|
|
17
16
|
({ importPath, specifierPath }) => {
|
|
@@ -20,11 +20,6 @@ export const validateCache = async ({
|
|
|
20
20
|
}) => {
|
|
21
21
|
const validity = { isValid: true }
|
|
22
22
|
|
|
23
|
-
// disable cahce for html files so that we always parse the importmap file
|
|
24
|
-
if (compiledFileUrl.endsWith(".html")) {
|
|
25
|
-
return { isValid: false }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
23
|
const metaJsonFileUrl = `${compiledFileUrl}__asset__meta.json`
|
|
29
24
|
const metaValidity = await validateMetaFile(metaJsonFileUrl)
|
|
30
25
|
mergeValidity(validity, "meta", metaValidity)
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
bufferToEtag,
|
|
6
6
|
urlIsInsideOf,
|
|
7
7
|
} from "@jsenv/filesystem"
|
|
8
|
-
import { normalizeImportMap, resolveImport } from "@jsenv/importmap"
|
|
9
8
|
import { convertFileSystemErrorToResponseProperties } from "@jsenv/server/src/internal/convertFileSystemErrorToResponseProperties.js"
|
|
10
9
|
|
|
11
10
|
import { getOrGenerateCompiledFile } from "./compile-directory/getOrGenerateCompiledFile.js"
|
|
@@ -109,15 +108,10 @@ export const compileFile = async ({
|
|
|
109
108
|
})
|
|
110
109
|
|
|
111
110
|
if (request.http2) {
|
|
112
|
-
// js resolution is special, we cannot just do resolveUrl of the import specifier
|
|
113
|
-
// because there can be importmap (bare specifier, import without extension, custom remapping, ...)
|
|
114
|
-
// And we would push 404 to the browser
|
|
115
|
-
// Until we implement import map resolution pushing ressource for js imports is disabled
|
|
116
111
|
const dependencyResolver = getDependencyResolver({
|
|
117
112
|
compileResult,
|
|
118
113
|
importmapInfos,
|
|
119
114
|
request,
|
|
120
|
-
projectDirectoryUrl,
|
|
121
115
|
})
|
|
122
116
|
if (dependencyResolver) {
|
|
123
117
|
compileResult.dependencies.forEach((dependency) => {
|
|
@@ -236,61 +230,30 @@ export const compileFile = async ({
|
|
|
236
230
|
}
|
|
237
231
|
}
|
|
238
232
|
|
|
239
|
-
const getDependencyResolver = ({
|
|
240
|
-
compileResult,
|
|
241
|
-
importmapInfos,
|
|
242
|
-
request,
|
|
243
|
-
projectDirectoryUrl,
|
|
244
|
-
}) => {
|
|
233
|
+
const getDependencyResolver = ({ compileResult, importmapInfos, request }) => {
|
|
245
234
|
const importmapKeys = Object.keys(importmapInfos)
|
|
246
235
|
const requestUrl = resolveUrl(request.ressource, request.origin)
|
|
247
236
|
|
|
248
237
|
if (
|
|
249
|
-
compileResult.contentType
|
|
250
|
-
importmapKeys
|
|
238
|
+
compileResult.contentType === "application/javascript" &&
|
|
239
|
+
// we cannot trust importmapKeys because when html is restored from cache
|
|
240
|
+
// it would be empty
|
|
241
|
+
importmapKeys.length > 0
|
|
251
242
|
) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const firstImportmapInfo = importmapInfos[importmapKeys[0]]
|
|
262
|
-
if (!firstImportmapInfo.text) {
|
|
243
|
+
// js resolution is special, we cannot just do resolveUrl of the import specifier
|
|
244
|
+
// because there can be importmap (bare specifier, import without extension, custom remapping, ...)
|
|
245
|
+
// And we would push 404 to the browser
|
|
246
|
+
// BUT I tried to push everything to the browser and it was a big fail:
|
|
247
|
+
// server is trying to push streams but browser rejects most push streams
|
|
248
|
+
// either because main file is already fetched or an other file request the same ressource
|
|
263
249
|
return null
|
|
264
250
|
}
|
|
265
251
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
const importMapBaseUrl = resolveUrl(
|
|
273
|
-
urlToRelativeUrl(firstImportmapInfo.url, projectDirectoryUrl),
|
|
274
|
-
`${request.origin}/`,
|
|
275
|
-
)
|
|
276
|
-
const importMap = normalizeImportMap(
|
|
277
|
-
JSON.parse(firstImportmapInfo.text),
|
|
278
|
-
importMapBaseUrl,
|
|
279
|
-
)
|
|
280
|
-
return {
|
|
281
|
-
type: "importmap_resolution",
|
|
282
|
-
resolve: (dependency) => {
|
|
283
|
-
const dependencyUrl = resolveImport({
|
|
284
|
-
specifier: dependency,
|
|
285
|
-
importer: requestUrl,
|
|
286
|
-
importMap,
|
|
287
|
-
})
|
|
288
|
-
return dependencyUrl
|
|
289
|
-
},
|
|
290
|
-
}
|
|
252
|
+
return {
|
|
253
|
+
type: "url_resolution",
|
|
254
|
+
resolve: (dependency) => {
|
|
255
|
+
const dependencyUrl = resolveUrl(dependency, requestUrl)
|
|
256
|
+
return dependencyUrl
|
|
257
|
+
},
|
|
291
258
|
}
|
|
292
|
-
|
|
293
|
-
// there is more than 2 importmaps, we cannot know which one to pick
|
|
294
|
-
// (not supposed ot happen because during dev you usually use a single importmap)
|
|
295
|
-
return null
|
|
296
259
|
}
|
|
@@ -48,6 +48,7 @@ export const createCompiledFileService = ({
|
|
|
48
48
|
groupMap,
|
|
49
49
|
customCompilers,
|
|
50
50
|
|
|
51
|
+
jsenvEventSourceClientInjection,
|
|
51
52
|
jsenvToolbarInjection,
|
|
52
53
|
|
|
53
54
|
projectFileRequestedCallback,
|
|
@@ -197,6 +198,7 @@ export const createCompiledFileService = ({
|
|
|
197
198
|
|
|
198
199
|
sourcemapMethod,
|
|
199
200
|
sourcemapExcludeSources,
|
|
201
|
+
jsenvEventSourceClientInjection,
|
|
200
202
|
jsenvToolbarInjection,
|
|
201
203
|
onHtmlImportmapInfo: ({ htmlUrl, importmapInfo }) => {
|
|
202
204
|
importmapInfos[htmlUrl] = importmapInfo
|
|
@@ -21,12 +21,12 @@ import {
|
|
|
21
21
|
import { moveImportMap } from "@jsenv/importmap"
|
|
22
22
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
23
23
|
|
|
24
|
-
import { fetchUrl } from "@jsenv/core/src/internal/fetchUrl.js"
|
|
25
24
|
import {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
} from "@jsenv/core/
|
|
25
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
26
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
27
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
28
|
+
} from "@jsenv/core/dist/build_manifest.js"
|
|
29
|
+
import { fetchUrl } from "@jsenv/core/src/internal/fetchUrl.js"
|
|
30
30
|
import { stringifyDataUrl } from "@jsenv/core/src/internal/dataUrl.utils.js"
|
|
31
31
|
import {
|
|
32
32
|
parseHtmlString,
|
|
@@ -41,12 +41,17 @@ import {
|
|
|
41
41
|
setHtmlNodeText,
|
|
42
42
|
getUniqueNameForInlineHtmlNode,
|
|
43
43
|
} from "./compileHtml.js"
|
|
44
|
+
import { jsenvCoreDirectoryUrl } from "../jsenvCoreDirectoryUrl.js"
|
|
45
|
+
|
|
46
|
+
const jsenvDistDirectoryUrl = new URL("./dist/", jsenvCoreDirectoryUrl).href
|
|
44
47
|
|
|
45
48
|
export const createTransformHtmlSourceFileService = ({
|
|
46
49
|
logger,
|
|
47
50
|
projectDirectoryUrl,
|
|
51
|
+
projectFileRequestedCallback,
|
|
48
52
|
inlineImportMapIntoHTML,
|
|
49
53
|
jsenvScriptInjection,
|
|
54
|
+
jsenvEventSourceClientInjection,
|
|
50
55
|
jsenvToolbarInjection,
|
|
51
56
|
}) => {
|
|
52
57
|
/**
|
|
@@ -66,6 +71,10 @@ export const createTransformHtmlSourceFileService = ({
|
|
|
66
71
|
const relativeUrl = ressource.slice(1)
|
|
67
72
|
const fileUrl = resolveUrl(relativeUrl, projectDirectoryUrl)
|
|
68
73
|
|
|
74
|
+
if (urlIsInsideOf(fileUrl, jsenvDistDirectoryUrl)) {
|
|
75
|
+
return null
|
|
76
|
+
}
|
|
77
|
+
|
|
69
78
|
const inlineScript = htmlInlineScriptMap.get(fileUrl)
|
|
70
79
|
if (inlineScript) {
|
|
71
80
|
return {
|
|
@@ -93,6 +102,7 @@ export const createTransformHtmlSourceFileService = ({
|
|
|
93
102
|
}
|
|
94
103
|
throw e
|
|
95
104
|
}
|
|
105
|
+
projectFileRequestedCallback(relativeUrl, request)
|
|
96
106
|
htmlInlineScriptMap.forEach((inlineScript, inlineScriptUrl) => {
|
|
97
107
|
if (inlineScript.htmlFileUrl === fileUrl) {
|
|
98
108
|
htmlInlineScriptMap.delete(inlineScriptUrl)
|
|
@@ -107,6 +117,7 @@ export const createTransformHtmlSourceFileService = ({
|
|
|
107
117
|
pushResponse,
|
|
108
118
|
inlineImportMapIntoHTML,
|
|
109
119
|
jsenvScriptInjection,
|
|
120
|
+
jsenvEventSourceClientInjection,
|
|
110
121
|
jsenvToolbarInjection,
|
|
111
122
|
onInlineModuleScript: ({ scriptContent, scriptIdentifier }) => {
|
|
112
123
|
const inlineScriptUrl = resolveUrl(scriptIdentifier, fileUrl)
|
|
@@ -138,8 +149,11 @@ const transformHTMLSourceFile = async ({
|
|
|
138
149
|
inlineImportMapIntoHTML,
|
|
139
150
|
jsenvScriptInjection,
|
|
140
151
|
jsenvToolbarInjection,
|
|
152
|
+
jsenvEventSourceClientInjection,
|
|
141
153
|
onInlineModuleScript = () => {},
|
|
142
154
|
}) => {
|
|
155
|
+
fileUrl = urlWithoutSearch(fileUrl)
|
|
156
|
+
|
|
143
157
|
const htmlAst = parseHtmlString(fileContent)
|
|
144
158
|
if (inlineImportMapIntoHTML) {
|
|
145
159
|
await inlineImportmapScripts({
|
|
@@ -150,27 +164,43 @@ const transformHTMLSourceFile = async ({
|
|
|
150
164
|
})
|
|
151
165
|
}
|
|
152
166
|
|
|
153
|
-
const
|
|
154
|
-
|
|
167
|
+
const browserRuntimeBuildUrlRelativeToProject = urlToRelativeUrl(
|
|
168
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
155
169
|
projectDirectoryUrl,
|
|
156
170
|
)
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
|
|
172
|
+
const eventSourceClientBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
173
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
159
174
|
projectDirectoryUrl,
|
|
160
175
|
)
|
|
176
|
+
|
|
177
|
+
const toolbarInjectorBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
178
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
179
|
+
projectDirectoryUrl,
|
|
180
|
+
)
|
|
181
|
+
|
|
161
182
|
manipulateHtmlAst(htmlAst, {
|
|
162
183
|
scriptInjections: [
|
|
163
|
-
...(
|
|
184
|
+
...(jsenvScriptInjection
|
|
164
185
|
? [
|
|
165
186
|
{
|
|
166
|
-
src: `/${
|
|
187
|
+
src: `/${browserRuntimeBuildUrlRelativeToProject}`,
|
|
167
188
|
},
|
|
168
189
|
]
|
|
169
190
|
: []),
|
|
170
|
-
...(
|
|
191
|
+
...(jsenvEventSourceClientInjection
|
|
171
192
|
? [
|
|
172
193
|
{
|
|
173
|
-
src: `/${
|
|
194
|
+
src: `/${eventSourceClientBuildRelativeUrlForProject}`,
|
|
195
|
+
},
|
|
196
|
+
]
|
|
197
|
+
: []),
|
|
198
|
+
...(jsenvToolbarInjection
|
|
199
|
+
? [
|
|
200
|
+
{
|
|
201
|
+
src: `/${toolbarInjectorBuildRelativeUrlForProject}`,
|
|
202
|
+
defer: "",
|
|
203
|
+
async: "",
|
|
174
204
|
},
|
|
175
205
|
]
|
|
176
206
|
: []),
|
|
@@ -401,3 +431,9 @@ const getJsenvForceInlineAttribute = (htmlNode) => {
|
|
|
401
431
|
)
|
|
402
432
|
return jsenvForceInlineAttribute
|
|
403
433
|
}
|
|
434
|
+
|
|
435
|
+
const urlWithoutSearch = (url) => {
|
|
436
|
+
const urlObject = new URL(url)
|
|
437
|
+
urlObject.search = ""
|
|
438
|
+
return urlObject.href
|
|
439
|
+
}
|
|
@@ -3,12 +3,13 @@ import { moveImportMap, composeTwoImportMaps } from "@jsenv/importmap"
|
|
|
3
3
|
import { createDetailedMessage } from "@jsenv/logger"
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "@jsenv/core/
|
|
6
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
7
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
8
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
9
|
+
} from "@jsenv/core/dist/build_manifest.js"
|
|
10
10
|
import { fetchUrl } from "@jsenv/core/src/internal/fetchUrl.js"
|
|
11
11
|
import { getDefaultImportMap } from "@jsenv/core/src/internal/import-resolution/importmap-default.js"
|
|
12
|
+
|
|
12
13
|
import {
|
|
13
14
|
setJavaScriptSourceMappingUrl,
|
|
14
15
|
sourcemapToBase64Url,
|
|
@@ -49,15 +50,22 @@ export const compileHtml = async ({
|
|
|
49
50
|
sourcemapMethod,
|
|
50
51
|
|
|
51
52
|
jsenvScriptInjection = true,
|
|
53
|
+
jsenvEventSourceClientInjection,
|
|
52
54
|
jsenvToolbarInjection,
|
|
53
55
|
onHtmlImportmapInfo,
|
|
54
56
|
}) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
+
const browserRuntimeBuildUrlRelativeToProject = urlToRelativeUrl(
|
|
58
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
57
59
|
projectDirectoryUrl,
|
|
58
60
|
)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
|
|
62
|
+
const eventSourceClientBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
63
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
64
|
+
projectDirectoryUrl,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
const toolbarInjectorBuildRelativeUrlForProject = urlToRelativeUrl(
|
|
68
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
61
69
|
projectDirectoryUrl,
|
|
62
70
|
)
|
|
63
71
|
|
|
@@ -70,17 +78,26 @@ export const compileHtml = async ({
|
|
|
70
78
|
|
|
71
79
|
manipulateHtmlAst(htmlAst, {
|
|
72
80
|
scriptInjections: [
|
|
73
|
-
...(
|
|
81
|
+
...(jsenvScriptInjection
|
|
82
|
+
? [
|
|
83
|
+
{
|
|
84
|
+
src: `/${browserRuntimeBuildUrlRelativeToProject}`,
|
|
85
|
+
},
|
|
86
|
+
]
|
|
87
|
+
: []),
|
|
88
|
+
...(jsenvEventSourceClientInjection
|
|
74
89
|
? [
|
|
75
90
|
{
|
|
76
|
-
src: `/${
|
|
91
|
+
src: `/${eventSourceClientBuildRelativeUrlForProject}`,
|
|
77
92
|
},
|
|
78
93
|
]
|
|
79
94
|
: []),
|
|
80
|
-
...(
|
|
95
|
+
...(jsenvToolbarInjection
|
|
81
96
|
? [
|
|
82
97
|
{
|
|
83
|
-
src: `/${
|
|
98
|
+
src: `/${toolbarInjectorBuildRelativeUrlForProject}`,
|
|
99
|
+
defer: "",
|
|
100
|
+
async: "",
|
|
84
101
|
},
|
|
85
102
|
]
|
|
86
103
|
: []),
|
|
@@ -29,12 +29,16 @@ import {
|
|
|
29
29
|
createCallbackListNotifiedOnce,
|
|
30
30
|
} from "@jsenv/abort"
|
|
31
31
|
|
|
32
|
+
import {
|
|
33
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
34
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
35
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
36
|
+
} from "@jsenv/core/dist/build_manifest.js"
|
|
32
37
|
import { generateGroupMap } from "@jsenv/core/src/internal/generateGroupMap/generateGroupMap.js"
|
|
33
38
|
import { isBrowserPartOfSupportedRuntimes } from "@jsenv/core/src/internal/generateGroupMap/runtime_support.js"
|
|
34
39
|
import { loadBabelPluginMapFromFile } from "./load_babel_plugin_map_from_file.js"
|
|
35
40
|
import { extractSyntaxBabelPluginMap } from "./babel_plugins.js"
|
|
36
41
|
import {
|
|
37
|
-
jsenvCompileProxyFileInfo,
|
|
38
42
|
sourcemapMainFileInfo,
|
|
39
43
|
sourcemapMappingFileInfo,
|
|
40
44
|
} from "../jsenvInternalFiles.js"
|
|
@@ -104,8 +108,9 @@ export const startCompileServer = async ({
|
|
|
104
108
|
plugins,
|
|
105
109
|
livereloadSSE = false,
|
|
106
110
|
transformHtmlSourceFiles = true,
|
|
107
|
-
jsenvToolbarInjection = false,
|
|
108
111
|
jsenvScriptInjection = true,
|
|
112
|
+
jsenvEventSourceClientInjection = false,
|
|
113
|
+
jsenvToolbarInjection = false,
|
|
109
114
|
inlineImportMapIntoHTML = true,
|
|
110
115
|
}) => {
|
|
111
116
|
assertArguments({
|
|
@@ -294,9 +299,6 @@ export const startCompileServer = async ({
|
|
|
294
299
|
outDirectoryUrl,
|
|
295
300
|
compileServerMetaFileInfo,
|
|
296
301
|
}),
|
|
297
|
-
"service: compile proxy": createCompileProxyService({
|
|
298
|
-
projectDirectoryUrl,
|
|
299
|
-
}),
|
|
300
302
|
"service:compiled file": createCompiledFileService({
|
|
301
303
|
logger,
|
|
302
304
|
|
|
@@ -312,6 +314,7 @@ export const startCompileServer = async ({
|
|
|
312
314
|
customCompilers,
|
|
313
315
|
moduleOutFormat,
|
|
314
316
|
importMetaFormat,
|
|
317
|
+
jsenvEventSourceClientInjection,
|
|
315
318
|
jsenvToolbarInjection,
|
|
316
319
|
|
|
317
320
|
projectFileRequestedCallback,
|
|
@@ -327,8 +330,10 @@ export const startCompileServer = async ({
|
|
|
327
330
|
createTransformHtmlSourceFileService({
|
|
328
331
|
logger,
|
|
329
332
|
projectDirectoryUrl,
|
|
333
|
+
projectFileRequestedCallback,
|
|
330
334
|
inlineImportMapIntoHTML,
|
|
331
335
|
jsenvScriptInjection,
|
|
336
|
+
jsenvEventSourceClientInjection,
|
|
332
337
|
jsenvToolbarInjection,
|
|
333
338
|
}),
|
|
334
339
|
}
|
|
@@ -909,15 +914,24 @@ const createSourceFileService = ({
|
|
|
909
914
|
const relativeUrl = request.pathname.slice(1)
|
|
910
915
|
projectFileRequestedCallback(relativeUrl, request)
|
|
911
916
|
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
mtimeEnabled: projectFileCacheStrategy === "mtime",
|
|
918
|
-
},
|
|
917
|
+
const fileUrl = new URL(request.ressource.slice(1), projectDirectoryUrl)
|
|
918
|
+
.href
|
|
919
|
+
const fileIsInsideJsenvDistDirectory = urlIsInsideOf(
|
|
920
|
+
fileUrl,
|
|
921
|
+
new URL("./dist/", jsenvCoreDirectoryUrl),
|
|
919
922
|
)
|
|
920
923
|
|
|
924
|
+
const responsePromise = fetchFileSystem(fileUrl, {
|
|
925
|
+
headers: request.headers,
|
|
926
|
+
etagEnabled: projectFileCacheStrategy === "etag",
|
|
927
|
+
mtimeEnabled: projectFileCacheStrategy === "mtime",
|
|
928
|
+
...(fileIsInsideJsenvDistDirectory
|
|
929
|
+
? {
|
|
930
|
+
cacheControl: `private,max-age=${60 * 60 * 24 * 30},immutable`,
|
|
931
|
+
}
|
|
932
|
+
: {}),
|
|
933
|
+
})
|
|
934
|
+
|
|
921
935
|
return responsePromise
|
|
922
936
|
}
|
|
923
937
|
}
|
|
@@ -961,6 +975,12 @@ const createCompileServerMetaFileInfo = ({
|
|
|
961
975
|
sourcemapMappingFileInfo.url,
|
|
962
976
|
projectDirectoryUrl,
|
|
963
977
|
)
|
|
978
|
+
// The object below must list everything that can influence how the
|
|
979
|
+
// compiled files are generated. So that the cahce for those generated files is
|
|
980
|
+
// not reused when it should not
|
|
981
|
+
// In some cases the parameters influences only a subset of files and ideally
|
|
982
|
+
// this parameter should somehow invalidate a subset of the cache
|
|
983
|
+
// To keep things simple these parameters currently invalidates the whole cache
|
|
964
984
|
const compileServerMeta = {
|
|
965
985
|
jsenvDirectoryRelativeUrl,
|
|
966
986
|
outDirectoryRelativeUrl,
|
|
@@ -979,8 +999,15 @@ const createCompileServerMetaFileInfo = ({
|
|
|
979
999
|
sourcemapMappingFileRelativeUrl,
|
|
980
1000
|
errorStackRemapping: true,
|
|
981
1001
|
|
|
1002
|
+
// used to consider the logic generating files may have changed
|
|
982
1003
|
jsenvCorePackageVersion,
|
|
1004
|
+
|
|
1005
|
+
// impact only HTML files
|
|
983
1006
|
jsenvToolbarInjection,
|
|
1007
|
+
TOOLBAR_INJECTOR_BUILD_URL,
|
|
1008
|
+
EVENT_SOURCE_CLIENT_BUILD_URL,
|
|
1009
|
+
BROWSER_RUNTIME_BUILD_URL,
|
|
1010
|
+
|
|
984
1011
|
env,
|
|
985
1012
|
}
|
|
986
1013
|
return {
|
|
@@ -1050,27 +1077,6 @@ const createCompileServerMetaService = ({
|
|
|
1050
1077
|
}
|
|
1051
1078
|
}
|
|
1052
1079
|
|
|
1053
|
-
const createCompileProxyService = ({ projectDirectoryUrl }) => {
|
|
1054
|
-
const jsenvCompileProxyRelativeUrlForProject = urlToRelativeUrl(
|
|
1055
|
-
jsenvCompileProxyFileInfo.jsenvBuildUrl,
|
|
1056
|
-
projectDirectoryUrl,
|
|
1057
|
-
)
|
|
1058
|
-
|
|
1059
|
-
return (request) => {
|
|
1060
|
-
if (request.ressource === "/.jsenv/jsenv_compile_proxy.js") {
|
|
1061
|
-
const jsenvCompileProxyBuildServerUrl = `${request.origin}/${jsenvCompileProxyRelativeUrlForProject}`
|
|
1062
|
-
return {
|
|
1063
|
-
status: 307,
|
|
1064
|
-
headers: {
|
|
1065
|
-
location: jsenvCompileProxyBuildServerUrl,
|
|
1066
|
-
},
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
return null
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
1080
|
const readPackage = (packagePath) => {
|
|
1075
1081
|
const buffer = readFileSync(packagePath)
|
|
1076
1082
|
const string = String(buffer)
|