@jsenv/core 27.0.0-alpha.62 → 27.0.0-alpha.65
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/html/explorer.html +557 -0
- package/dist/js/controllable_file.mjs +227 -0
- package/dist/{event_source_client.js → js/event_source_client.js} +19 -244
- package/dist/js/global_this.js +32 -0
- package/dist/js/html_supervisor_installer.js +522 -0
- package/dist/js/html_supervisor_setup.js +79 -0
- package/dist/{import_meta_hot.js → js/import_meta_hot.js} +1 -3
- package/dist/js/inline_content.js +8 -0
- package/dist/js/new_stylesheet.js +409 -0
- package/dist/js/regenerator_runtime.js +721 -0
- package/dist/js/s.js +429 -0
- package/dist/main.js +13362 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/AsyncGenerator/AsyncGenerator.js +95 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/AwaitValue/AwaitValue.js +3 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/applyDecoratorDescriptor/applyDecoratorDescriptor.js +29 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +9 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/arrayWithHoles/arrayWithHoles.js +4 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/assertThisInitialized/assertThisInitialized.js +8 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +52 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/asyncIterator/asyncIterator.js +78 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/asyncToGenerator/asyncToGenerator.js +39 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +4 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +24 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +7 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +14 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classCallCheck/classCallCheck.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +6 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +8 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classNameTDZError/classNameTDZError.js +4 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +6 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +6 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +7 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +7 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +7 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +3 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +8 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +9 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +3 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/construct/construct.js +15 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createClass/createClass.js +18 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +63 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +22 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createRawReactElement/createRawReactElement.js +50 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/createSuper/createSuper.js +22 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/decorate/decorate.js +622 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/defaults/defaults.js +14 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +26 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/defineProperty/defineProperty.js +19 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/extends/extends.js +16 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/get/get.js +21 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/getPrototypeOf/getPrototypeOf.js +2 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/inherits/inherits.js +21 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/inheritsLoose/inheritsLoose.js +6 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +10 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +3 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/instanceof/instanceof.js +7 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/interopRequireDefault/interopRequireDefault.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +49 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/isNativeFunction/isNativeFunction.js +4 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +21 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/iterableToArray/iterableToArray.js +3 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +38 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +13 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/jsx/jsx.js +49 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/maybeArrayLike/maybeArrayLike.js +10 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/newArrowCheck/newArrowCheck.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/nonIterableRest/nonIterableRest.js +3 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/nonIterableSpread/nonIterableSpread.js +3 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +3 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectSpread/objectSpread.js +22 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectSpread2/objectSpread2.js +41 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +20 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +15 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +10 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/readOnlyError/readOnlyError.js +4 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/readme.md +8 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/set/set.js +51 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/setPrototypeOf/setPrototypeOf.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +8 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/slicedToArray/slicedToArray.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +7 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/superPropBase/superPropBase.js +10 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +11 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +8 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/tdz/tdz.js +4 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/temporalRef/temporalRef.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/temporalUndefined/temporalUndefined.js +3 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/toArray/toArray.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/toConsumableArray/toConsumableArray.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/toPrimitive/toPrimitive.js +14 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/toPropertyKey/toPropertyKey.js +5 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/typeof/typeof.js +7 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +10 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +7 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +35 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/wrapRegExp/wrapRegExp.js +67 -0
- package/dist/node_modules/@jsenv/babel-plugins/src/babel_helpers/writeOnlyError/writeOnlyError.js +4 -0
- package/dist/other/jsenv.png +0 -0
- package/main.js +1 -0
- package/package.json +18 -14
- package/src/build/build.js +169 -69
- package/src/build/build_urls_generator.js +18 -2
- package/src/build/inject_global_version_mappings.js +18 -5
- package/src/build/inject_service_worker_urls.js +1 -1
- package/src/build/resync_ressource_hints.js +56 -9
- package/src/build/start_build_server.js +41 -30
- package/src/dev/plugins/explorer/client/explorer.html +1 -1
- package/src/dev/start_dev_server.js +21 -5
- package/src/execute/execute.js +3 -0
- package/src/execute/runtimes/browsers/from_playwright.js +10 -0
- package/src/execute/runtimes/node/node_process.js +8 -0
- package/src/omega/errors.js +10 -7
- package/src/omega/kitchen.js +251 -340
- package/src/omega/server/file_service.js +34 -17
- package/src/omega/url_graph/url_graph_load.js +10 -17
- package/src/omega/url_graph/url_graph_report.js +2 -2
- package/src/omega/url_graph/url_info_transformations.js +1 -4
- package/src/omega/url_graph.js +7 -3
- package/src/omega/url_specifier_encoding.js +59 -0
- package/src/plugins/autoreload/dev_sse/jsenv_plugin_dev_sse_client.js +5 -10
- package/src/plugins/autoreload/jsenv_plugin_autoreload.js +1 -3
- package/src/plugins/bundling/js_module/bundle_js_module.js +66 -24
- package/src/plugins/file_urls/jsenv_plugin_file_urls.js +171 -53
- package/src/plugins/html_supervisor/client/html_supervisor_installer.js +1 -1
- package/src/plugins/html_supervisor/jsenv_plugin_html_supervisor.js +9 -13
- package/src/plugins/http_urls/jsenv_plugin_http_urls.js +6 -6
- package/src/plugins/import_meta_hot/jsenv_plugin_import_meta_hot.js +5 -10
- package/src/plugins/importmap/jsenv_plugin_importmap.js +2 -4
- package/src/plugins/inject_globals/jsenv_plugin_inject_globals.js +51 -42
- package/src/plugins/inline/jsenv_plugin_data_urls.js +1 -4
- package/src/plugins/inline/jsenv_plugin_html_inline_content.js +3 -5
- package/src/plugins/inline/jsenv_plugin_inline_query_param.js +1 -4
- package/src/plugins/inline/jsenv_plugin_js_inline_content.js +1 -4
- package/src/plugins/node_esm_resolution/jsenv_plugin_node_esm_resolution.js +16 -2
- package/src/plugins/node_runtime/jsenv_plugin_node_runtime.js +12 -0
- package/src/plugins/plugin_controller.js +17 -3
- package/src/plugins/plugins.js +15 -15
- package/src/plugins/transpilation/as_js_classic/client/s.js +362 -807
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js +20 -10
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic_html.js +302 -0
- package/src/plugins/transpilation/as_js_classic/{jsenv_plugin_workers_type_module_as_classic.js → jsenv_plugin_as_js_classic_workers.js} +2 -2
- package/src/plugins/transpilation/babel/jsenv_plugin_babel.js +5 -2
- package/src/plugins/transpilation/import_assertions/jsenv_plugin_import_assertions.js +1 -2
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +2 -0
- package/src/plugins/url_analysis/html/html_urls.js +3 -0
- package/src/plugins/url_analysis/js/js_urls.js +2 -1
- package/src/plugins/url_analysis/jsenv_plugin_url_analysis.js +87 -1
- package/src/plugins/url_analysis/webmanifest/webmanifest_urls.js +3 -0
- package/src/plugins/url_resolution/jsenv_plugin_url_resolution.js +0 -3
- package/src/test/execute_plan.js +34 -13
- package/src/test/execute_test_plan.js +2 -0
- package/src/test/logs_file_execution.js +47 -38
- package/dist/event_source_client.js.map +0 -188
- package/dist/html_supervisor_installer.js +0 -1236
- package/dist/html_supervisor_installer.js.map +0 -337
- package/dist/html_supervisor_setup.js +0 -95
- package/dist/html_supervisor_setup.js.map +0 -57
- package/dist/import_meta_hot.js.map +0 -42
- package/src/jsenv_root_directory_url.js +0 -1
- package/src/omega/compat/default_runtime_compat.js +0 -11
- package/src/plugins/filesystem_magic/jsenv_plugin_filesystem_magic.js +0 -61
- package/src/plugins/transpilation/as_js_classic/client/s.js.md +0 -1
- package/src/plugins/transpilation/as_js_classic/jsenv_plugin_script_type_module_as_classic.js +0 -270
- package/src/plugins/transpilation/babel/new_stylesheet/client/.eslintrc.cjs +0 -24
- package/src/plugins/transpilation/fetch_original_url_info.js +0 -30
package/src/build/build.js
CHANGED
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
setUrlFilename,
|
|
26
26
|
asUrlUntilPathname,
|
|
27
27
|
normalizeUrl,
|
|
28
|
+
asUrlWithoutSearch,
|
|
29
|
+
ensurePathnameTrailingSlash,
|
|
28
30
|
} from "@jsenv/utils/urls/url_utils.js"
|
|
29
31
|
import { createVersionGenerator } from "@jsenv/utils/versioning/version_generator.js"
|
|
30
32
|
import { generateSourcemapUrl } from "@jsenv/utils/sourcemap/sourcemap_utils.js"
|
|
@@ -34,10 +36,10 @@ import {
|
|
|
34
36
|
} from "@jsenv/utils/html_ast/html_ast.js"
|
|
35
37
|
import { sortByDependencies } from "@jsenv/utils/graph/sort_by_dependencies.js"
|
|
36
38
|
|
|
39
|
+
import { createUrlGraph } from "../omega/url_graph.js"
|
|
37
40
|
import { jsenvPluginUrlAnalysis } from "../plugins/url_analysis/jsenv_plugin_url_analysis.js"
|
|
38
41
|
import { jsenvPluginInline } from "../plugins/inline/jsenv_plugin_inline.js"
|
|
39
42
|
import { jsenvPluginAsJsClassic } from "../plugins/transpilation/as_js_classic/jsenv_plugin_as_js_classic.js"
|
|
40
|
-
import { createUrlGraph } from "../omega/url_graph.js"
|
|
41
43
|
import { getCorePlugins } from "../plugins/plugins.js"
|
|
42
44
|
import { createKitchen } from "../omega/kitchen.js"
|
|
43
45
|
import { loadUrlGraph } from "../omega/url_graph/url_graph_load.js"
|
|
@@ -86,13 +88,27 @@ export const build = async ({
|
|
|
86
88
|
rootDirectoryUrl,
|
|
87
89
|
buildDirectoryUrl,
|
|
88
90
|
entryPoints = {},
|
|
91
|
+
baseUrl = "/",
|
|
89
92
|
|
|
93
|
+
// default runtimeCompat corresponds to dynamic import
|
|
94
|
+
// (meaning we can keep <script type="module">)
|
|
95
|
+
runtimeCompat = {
|
|
96
|
+
// android: "8",
|
|
97
|
+
chrome: "63",
|
|
98
|
+
edge: "79",
|
|
99
|
+
firefox: "67",
|
|
100
|
+
ios: "11.3",
|
|
101
|
+
opera: "50",
|
|
102
|
+
safari: "11.3",
|
|
103
|
+
samsung: "8.2",
|
|
104
|
+
},
|
|
90
105
|
plugins = [],
|
|
91
106
|
sourcemaps = false,
|
|
107
|
+
urlAnalysis = {},
|
|
92
108
|
nodeEsmResolution,
|
|
93
109
|
fileSystemMagicResolution,
|
|
110
|
+
directoryReferenceAllowed,
|
|
94
111
|
injectedGlobals,
|
|
95
|
-
runtimeCompat,
|
|
96
112
|
transpilation = {},
|
|
97
113
|
bundling = true,
|
|
98
114
|
minification = true,
|
|
@@ -112,7 +128,6 @@ export const build = async ({
|
|
|
112
128
|
buildDirectoryClean = true,
|
|
113
129
|
writeOnFileSystem = true,
|
|
114
130
|
writeGeneratedFiles = false,
|
|
115
|
-
baseUrl = "/",
|
|
116
131
|
assetManifest = true,
|
|
117
132
|
assetManifestFileRelativeUrl = "asset-manifest.json",
|
|
118
133
|
}) => {
|
|
@@ -151,12 +166,16 @@ build "${entryPointKeys[0]}"`)
|
|
|
151
166
|
logger.info(`
|
|
152
167
|
build ${entryPointKeys.length} entry points`)
|
|
153
168
|
}
|
|
169
|
+
const useExplicitJsClassicConversion = entryPointKeys.some((key) =>
|
|
170
|
+
entryPoints[key].includes("?as_js_classic"),
|
|
171
|
+
)
|
|
154
172
|
|
|
155
173
|
const rawGraph = createUrlGraph()
|
|
156
174
|
const prebuildTask = createTaskLog("prebuild", {
|
|
157
175
|
disabled: infoLogsAreDisabled,
|
|
158
176
|
})
|
|
159
177
|
let urlCount = 0
|
|
178
|
+
const prebuildRedirections = new Map()
|
|
160
179
|
const rawGraphKitchen = createKitchen({
|
|
161
180
|
signal,
|
|
162
181
|
logger,
|
|
@@ -176,16 +195,37 @@ build ${entryPointKeys.length} entry points`)
|
|
|
176
195
|
prebuildTask.setRightText(urlCount)
|
|
177
196
|
},
|
|
178
197
|
},
|
|
198
|
+
{
|
|
199
|
+
appliesDuring: "build",
|
|
200
|
+
fetchUrlContent: (urlInfo, context) => {
|
|
201
|
+
if (context.reference.original) {
|
|
202
|
+
prebuildRedirections.set(
|
|
203
|
+
context.reference.original.url,
|
|
204
|
+
context.reference.url,
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
formatUrl: (reference) => {
|
|
209
|
+
if (!reference.shouldHandle) {
|
|
210
|
+
return `ignore:${reference.specifier}`
|
|
211
|
+
}
|
|
212
|
+
return null
|
|
213
|
+
},
|
|
214
|
+
},
|
|
179
215
|
...getCorePlugins({
|
|
180
216
|
rootDirectoryUrl,
|
|
181
217
|
urlGraph: rawGraph,
|
|
182
218
|
scenario: "build",
|
|
219
|
+
runtimeCompat,
|
|
183
220
|
|
|
221
|
+
urlAnalysis,
|
|
184
222
|
nodeEsmResolution,
|
|
185
223
|
fileSystemMagicResolution,
|
|
224
|
+
directoryReferenceAllowed,
|
|
186
225
|
injectedGlobals,
|
|
187
226
|
transpilation: {
|
|
188
227
|
...transpilation,
|
|
228
|
+
babelHelpersAsImport: !useExplicitJsClassicConversion,
|
|
189
229
|
jsModuleAsJsClassic: false,
|
|
190
230
|
},
|
|
191
231
|
minification,
|
|
@@ -199,6 +239,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
199
239
|
operation: buildOperation,
|
|
200
240
|
urlGraph: rawGraph,
|
|
201
241
|
kitchen: rawGraphKitchen,
|
|
242
|
+
writeGeneratedFiles,
|
|
202
243
|
outDirectoryUrl: new URL(`.jsenv/build/`, rootDirectoryUrl),
|
|
203
244
|
startLoading: (cookEntryFile) => {
|
|
204
245
|
Object.keys(entryPoints).forEach((key) => {
|
|
@@ -209,6 +250,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
209
250
|
})
|
|
210
251
|
entryUrls.push(entryUrlInfo.url)
|
|
211
252
|
entryUrlInfo.filename = entryPoints[key]
|
|
253
|
+
// entryUrlInfo.data.entryPointKey = key
|
|
212
254
|
})
|
|
213
255
|
},
|
|
214
256
|
})
|
|
@@ -222,8 +264,8 @@ build ${entryPointKeys.length} entry points`)
|
|
|
222
264
|
buildDirectoryUrl,
|
|
223
265
|
})
|
|
224
266
|
const rawUrls = {}
|
|
267
|
+
const bundleRedirections = {}
|
|
225
268
|
const buildUrls = {}
|
|
226
|
-
const rawUrlRedirections = {}
|
|
227
269
|
const bundleUrlInfos = {}
|
|
228
270
|
const bundlers = {}
|
|
229
271
|
rawGraphKitchen.pluginController.plugins.forEach((plugin) => {
|
|
@@ -313,7 +355,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
313
355
|
})
|
|
314
356
|
}
|
|
315
357
|
})
|
|
316
|
-
const
|
|
358
|
+
const bundleInternalRedirections = {}
|
|
317
359
|
await Object.keys(bundlers).reduce(async (previous, type) => {
|
|
318
360
|
await previous
|
|
319
361
|
const bundler = bundlers[type]
|
|
@@ -334,7 +376,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
334
376
|
},
|
|
335
377
|
urlInfosToBundle,
|
|
336
378
|
{
|
|
337
|
-
...rawGraphKitchen.
|
|
379
|
+
...rawGraphKitchen.kitchenContext,
|
|
338
380
|
buildDirectoryUrl,
|
|
339
381
|
},
|
|
340
382
|
)
|
|
@@ -355,15 +397,20 @@ build ${entryPointKeys.length} entry points`)
|
|
|
355
397
|
const buildUrl = buildUrlsGenerator.generate(url, {
|
|
356
398
|
urlInfo: bundleUrlInfo,
|
|
357
399
|
})
|
|
358
|
-
|
|
400
|
+
bundleRedirections[url] = buildUrl
|
|
359
401
|
rawUrls[buildUrl] = url
|
|
360
402
|
bundleUrlInfos[buildUrl] = bundleUrlInfo
|
|
403
|
+
if (buildUrl.includes("?")) {
|
|
404
|
+
bundleUrlInfos[asUrlWithoutSearch(buildUrl)] = bundleUrlInfo
|
|
405
|
+
}
|
|
361
406
|
if (bundlerGeneratedUrlInfo.data.bundleRelativeUrl) {
|
|
362
407
|
const urlForBundler = new URL(
|
|
363
408
|
bundlerGeneratedUrlInfo.data.bundleRelativeUrl,
|
|
364
409
|
buildDirectoryUrl,
|
|
365
410
|
).href
|
|
366
|
-
|
|
411
|
+
if (urlForBundler !== buildUrl) {
|
|
412
|
+
bundleInternalRedirections[urlForBundler] = buildUrl
|
|
413
|
+
}
|
|
367
414
|
}
|
|
368
415
|
})
|
|
369
416
|
} catch (e) {
|
|
@@ -373,7 +420,11 @@ build ${entryPointKeys.length} entry points`)
|
|
|
373
420
|
bundleTask.done()
|
|
374
421
|
}, Promise.resolve())
|
|
375
422
|
|
|
376
|
-
const
|
|
423
|
+
const urlAnalysisPlugin = jsenvPluginUrlAnalysis({
|
|
424
|
+
rootDirectoryUrl,
|
|
425
|
+
...urlAnalysis,
|
|
426
|
+
})
|
|
427
|
+
const postBuildRedirections = {}
|
|
377
428
|
const finalGraph = createUrlGraph()
|
|
378
429
|
const optimizeUrlContentHooks =
|
|
379
430
|
rawGraphKitchen.pluginController.addHook("optimizeUrlContent")
|
|
@@ -387,31 +438,58 @@ build ${entryPointKeys.length} entry points`)
|
|
|
387
438
|
runtimeCompat,
|
|
388
439
|
writeGeneratedFiles,
|
|
389
440
|
plugins: [
|
|
390
|
-
|
|
391
|
-
jsenvPluginAsJsClassic({
|
|
392
|
-
|
|
393
|
-
}),
|
|
394
|
-
jsenvPluginInline({
|
|
395
|
-
fetchInlineUrls: false,
|
|
396
|
-
}),
|
|
441
|
+
urlAnalysisPlugin,
|
|
442
|
+
jsenvPluginAsJsClassic({ systemJsInjection: true }),
|
|
443
|
+
jsenvPluginInline({ fetchInlineUrls: false }),
|
|
397
444
|
{
|
|
398
445
|
name: "jsenv:postbuild",
|
|
399
|
-
appliesDuring:
|
|
446
|
+
appliesDuring: "build",
|
|
400
447
|
resolveUrl: (reference) => {
|
|
401
|
-
|
|
402
|
-
|
|
448
|
+
const performInternalRedirections = (url) => {
|
|
449
|
+
const prebuildRedirection = prebuildRedirections.get(url)
|
|
450
|
+
if (prebuildRedirection) {
|
|
451
|
+
logger.debug(
|
|
452
|
+
`\nprebuild redirection\n${url} ->\n${prebuildRedirection}\n`,
|
|
453
|
+
)
|
|
454
|
+
url = prebuildRedirection
|
|
455
|
+
}
|
|
456
|
+
const bundleRedirection = bundleRedirections[url]
|
|
457
|
+
if (bundleRedirection) {
|
|
458
|
+
logger.debug(
|
|
459
|
+
`\nbundler redirection\n${url} ->\n${bundleRedirection}\n`,
|
|
460
|
+
)
|
|
461
|
+
url = bundleRedirection
|
|
462
|
+
}
|
|
463
|
+
const bundleInternalRedirection = bundleInternalRedirections[url]
|
|
464
|
+
if (bundleInternalRedirection) {
|
|
465
|
+
logger.debug(
|
|
466
|
+
`\nbundler internal redirection\n${url} ->\n${bundleInternalRedirection}\n`,
|
|
467
|
+
)
|
|
468
|
+
url = bundleInternalRedirection
|
|
469
|
+
}
|
|
470
|
+
return url
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (reference.type === "filesystem") {
|
|
474
|
+
const parentRawUrl = rawUrls[reference.parentUrl]
|
|
475
|
+
const baseUrl = ensurePathnameTrailingSlash(parentRawUrl)
|
|
476
|
+
return performInternalRedirections(
|
|
477
|
+
new URL(reference.specifier, baseUrl).href,
|
|
478
|
+
)
|
|
403
479
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
const urlRedirectedByBundle = bundleUrlRedirections[url]
|
|
409
|
-
if (urlRedirectedByBundle) {
|
|
410
|
-
return urlRedirectedByBundle
|
|
480
|
+
if (reference.specifier[0] === "/") {
|
|
481
|
+
return performInternalRedirections(
|
|
482
|
+
new URL(reference.specifier.slice(1), buildDirectoryUrl).href,
|
|
483
|
+
)
|
|
411
484
|
}
|
|
412
|
-
|
|
413
|
-
|
|
485
|
+
return performInternalRedirections(
|
|
486
|
+
new URL(
|
|
487
|
+
reference.specifier,
|
|
488
|
+
reference.baseUrl || reference.parentUrl,
|
|
489
|
+
).href,
|
|
490
|
+
)
|
|
414
491
|
},
|
|
492
|
+
// redirecting urls into the build directory
|
|
415
493
|
redirectUrl: (reference) => {
|
|
416
494
|
if (!reference.url.startsWith("file:")) {
|
|
417
495
|
return null
|
|
@@ -421,11 +499,6 @@ build ${entryPointKeys.length} entry points`)
|
|
|
421
499
|
if (rawUrl) {
|
|
422
500
|
return reference.url
|
|
423
501
|
}
|
|
424
|
-
// from rollup or postcss
|
|
425
|
-
const bundleUrlInfo = bundleUrlInfos[reference.url]
|
|
426
|
-
if (bundleUrlInfo) {
|
|
427
|
-
return reference.url
|
|
428
|
-
}
|
|
429
502
|
// from "js_module_as_js_classic":
|
|
430
503
|
// - injecting "?as_js_classic" for the first time
|
|
431
504
|
// - injecting "?as_js_classic" because the parentUrl has it
|
|
@@ -441,9 +514,8 @@ build ${entryPointKeys.length} entry points`)
|
|
|
441
514
|
}
|
|
442
515
|
let rawUrl
|
|
443
516
|
if (urlIsInsideOf(reference.url, buildDirectoryUrl)) {
|
|
444
|
-
// rawUrl = rawUrls[reference.url] || reference.url
|
|
445
517
|
const originalBuildUrl =
|
|
446
|
-
|
|
518
|
+
postBuildRedirections[referenceOriginalUrl]
|
|
447
519
|
rawUrl = originalBuildUrl
|
|
448
520
|
? rawUrls[originalBuildUrl]
|
|
449
521
|
: reference.url
|
|
@@ -465,7 +537,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
465
537
|
filename: reference.filename,
|
|
466
538
|
},
|
|
467
539
|
})
|
|
468
|
-
|
|
540
|
+
postBuildRedirections[originalBuildUrl] = buildUrl
|
|
469
541
|
rawUrls[buildUrl] = rawUrl
|
|
470
542
|
return buildUrl
|
|
471
543
|
}
|
|
@@ -509,11 +581,16 @@ build ${entryPointKeys.length} entry points`)
|
|
|
509
581
|
return buildUrl
|
|
510
582
|
}
|
|
511
583
|
const rawUrlInfo = rawGraph.getUrlInfo(reference.url)
|
|
584
|
+
const parentUrlInfo = finalGraph.getUrlInfo(reference.parentUrl)
|
|
512
585
|
// files from root directory but not given to rollup nor postcss
|
|
513
586
|
if (rawUrlInfo) {
|
|
514
587
|
const buildUrl = buildUrlsGenerator.generate(reference.url, {
|
|
515
588
|
urlInfo: rawUrlInfo,
|
|
589
|
+
parentUrlInfo,
|
|
516
590
|
})
|
|
591
|
+
if (buildUrl.includes("?")) {
|
|
592
|
+
rawUrls[asUrlWithoutSearch(buildUrl)] = rawUrlInfo.url
|
|
593
|
+
}
|
|
517
594
|
rawUrls[buildUrl] = rawUrlInfo.url
|
|
518
595
|
return buildUrl
|
|
519
596
|
}
|
|
@@ -534,6 +611,9 @@ build ${entryPointKeys.length} entry points`)
|
|
|
534
611
|
},
|
|
535
612
|
formatUrl: (reference) => {
|
|
536
613
|
if (!reference.generatedUrl.startsWith("file:")) {
|
|
614
|
+
if (!versioning && reference.generatedUrl.startsWith("ignore:")) {
|
|
615
|
+
return reference.generatedUrl.slice("ignore:".length)
|
|
616
|
+
}
|
|
537
617
|
return null
|
|
538
618
|
}
|
|
539
619
|
if (!urlIsInsideOf(reference.generatedUrl, buildDirectoryUrl)) {
|
|
@@ -541,6 +621,10 @@ build ${entryPointKeys.length} entry points`)
|
|
|
541
621
|
`urls should be inside build directory at this stage, found "${reference.url}"`,
|
|
542
622
|
)
|
|
543
623
|
}
|
|
624
|
+
if (reference.isRessourceHint) {
|
|
625
|
+
// return the raw url, we will resync at the end
|
|
626
|
+
return rawUrls[reference.url]
|
|
627
|
+
}
|
|
544
628
|
// remove eventual search params and hash
|
|
545
629
|
const urlUntilPathname = asUrlUntilPathname(reference.generatedUrl)
|
|
546
630
|
let specifier
|
|
@@ -566,23 +650,18 @@ build ${entryPointKeys.length} entry points`)
|
|
|
566
650
|
return specifier
|
|
567
651
|
},
|
|
568
652
|
fetchUrlContent: async (finalUrlInfo, context) => {
|
|
569
|
-
if (!finalUrlInfo.url.startsWith("file:")) {
|
|
570
|
-
return { external: true }
|
|
571
|
-
}
|
|
572
653
|
const fromBundleOrRawGraph = (url) => {
|
|
573
654
|
const bundleUrlInfo = bundleUrlInfos[url]
|
|
574
655
|
if (bundleUrlInfo) {
|
|
656
|
+
logger.debug(`fetching from bundle ${url}`)
|
|
575
657
|
return bundleUrlInfo
|
|
576
658
|
}
|
|
577
659
|
const rawUrl = rawUrls[url] || url
|
|
578
660
|
const rawUrlInfo = rawGraph.getUrlInfo(rawUrl)
|
|
579
661
|
if (!rawUrlInfo) {
|
|
580
|
-
const originalBuildUrl = buildUrlRedirections[url]
|
|
581
|
-
if (originalBuildUrl) {
|
|
582
|
-
return fromBundleOrRawGraph(originalBuildUrl)
|
|
583
|
-
}
|
|
584
662
|
throw new Error(`Cannot find url`)
|
|
585
663
|
}
|
|
664
|
+
logger.debug(`fetching from raw graph ${url}`)
|
|
586
665
|
if (rawUrlInfo.isInline) {
|
|
587
666
|
// Inline content, such as <script> inside html, is transformed during the previous phase.
|
|
588
667
|
// If we read the inline content it would be considered as the original content.
|
|
@@ -609,10 +688,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
609
688
|
specifier: context.reference.specifier,
|
|
610
689
|
injected: true,
|
|
611
690
|
})
|
|
612
|
-
await rawGraphKitchen.cook({
|
|
613
|
-
reference: ref,
|
|
614
|
-
urlInfo: rawUrlInfo,
|
|
615
|
-
})
|
|
691
|
+
await rawGraphKitchen.cook(rawUrlInfo, { reference: ref })
|
|
616
692
|
return rawUrlInfo
|
|
617
693
|
}
|
|
618
694
|
// reference updated during "postbuild":
|
|
@@ -625,7 +701,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
625
701
|
},
|
|
626
702
|
{
|
|
627
703
|
name: "jsenv:optimize",
|
|
628
|
-
appliesDuring:
|
|
704
|
+
appliesDuring: "build",
|
|
629
705
|
finalizeUrlContent: async (urlInfo, context) => {
|
|
630
706
|
if (optimizeUrlContentHooks.length) {
|
|
631
707
|
await rawGraphKitchen.pluginController.callAsyncHooks(
|
|
@@ -652,6 +728,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
652
728
|
urlGraph: finalGraph,
|
|
653
729
|
kitchen: finalGraphKitchen,
|
|
654
730
|
outDirectoryUrl: new URL(".jsenv/postbuild/", rootDirectoryUrl),
|
|
731
|
+
writeGeneratedFiles,
|
|
655
732
|
skipRessourceHint: true,
|
|
656
733
|
startLoading: (cookEntryFile) => {
|
|
657
734
|
entryUrls.forEach((entryUrl) => {
|
|
@@ -688,6 +765,7 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
688
765
|
runtimeCompat,
|
|
689
766
|
writeGeneratedFiles,
|
|
690
767
|
rawGraph,
|
|
768
|
+
urlAnalysisPlugin,
|
|
691
769
|
finalGraph,
|
|
692
770
|
finalGraphKitchen,
|
|
693
771
|
lineBreakNormalization,
|
|
@@ -695,10 +773,10 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
695
773
|
})
|
|
696
774
|
}
|
|
697
775
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
698
|
-
if (!urlInfo.
|
|
776
|
+
if (!urlInfo.shouldHandle) {
|
|
699
777
|
return
|
|
700
778
|
}
|
|
701
|
-
if (urlInfo.
|
|
779
|
+
if (!urlInfo.url.startsWith("file:")) {
|
|
702
780
|
return
|
|
703
781
|
}
|
|
704
782
|
if (urlInfo.type === "html") {
|
|
@@ -720,10 +798,11 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
720
798
|
urlInfo.data.buildUrlSpecifier = buildUrlSpecifier
|
|
721
799
|
})
|
|
722
800
|
await resyncRessourceHints({
|
|
801
|
+
logger,
|
|
723
802
|
finalGraphKitchen,
|
|
724
803
|
finalGraph,
|
|
725
804
|
rawUrls,
|
|
726
|
-
|
|
805
|
+
postBuildRedirections,
|
|
727
806
|
})
|
|
728
807
|
buildOperation.throwIfAborted()
|
|
729
808
|
const cleanupActions = []
|
|
@@ -753,10 +832,13 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
753
832
|
const buildFileContents = {}
|
|
754
833
|
const buildInlineContents = {}
|
|
755
834
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
756
|
-
if (urlInfo.
|
|
835
|
+
if (!urlInfo.shouldHandle) {
|
|
836
|
+
return
|
|
837
|
+
}
|
|
838
|
+
if (!urlInfo.url.startsWith("file:")) {
|
|
757
839
|
return
|
|
758
840
|
}
|
|
759
|
-
if (urlInfo.
|
|
841
|
+
if (urlInfo.type === "directory") {
|
|
760
842
|
return
|
|
761
843
|
}
|
|
762
844
|
const buildRelativeUrl = urlToRelativeUrl(
|
|
@@ -890,6 +972,7 @@ const applyUrlVersioning = async ({
|
|
|
890
972
|
runtimeCompat,
|
|
891
973
|
writeGeneratedFiles,
|
|
892
974
|
rawGraph,
|
|
975
|
+
urlAnalysisPlugin,
|
|
893
976
|
finalGraph,
|
|
894
977
|
finalGraphKitchen,
|
|
895
978
|
lineBreakNormalization,
|
|
@@ -911,7 +994,7 @@ const applyUrlVersioning = async ({
|
|
|
911
994
|
// ignore:
|
|
912
995
|
// - inline files:
|
|
913
996
|
// they are already taken into account in the file where they appear
|
|
914
|
-
// -
|
|
997
|
+
// - ignored files:
|
|
915
998
|
// we don't know their content
|
|
916
999
|
// - unused files without reference
|
|
917
1000
|
// File updated such as style.css -> style.css.js or file.js->file.es5.js
|
|
@@ -921,7 +1004,7 @@ const applyUrlVersioning = async ({
|
|
|
921
1004
|
if (urlInfo.isInline) {
|
|
922
1005
|
return
|
|
923
1006
|
}
|
|
924
|
-
if (urlInfo.
|
|
1007
|
+
if (!urlInfo.shouldHandle) {
|
|
925
1008
|
return
|
|
926
1009
|
}
|
|
927
1010
|
if (!urlInfo.data.isEntryPoint && urlInfo.dependents.size === 0) {
|
|
@@ -944,8 +1027,8 @@ const applyUrlVersioning = async ({
|
|
|
944
1027
|
lineBreakNormalization,
|
|
945
1028
|
})
|
|
946
1029
|
urlInfo.dependencies.forEach((dependencyUrl) => {
|
|
947
|
-
// this dependency is inline
|
|
948
|
-
if (
|
|
1030
|
+
// this dependency is inline
|
|
1031
|
+
if (dependencyUrl.startsWith("data:")) {
|
|
949
1032
|
return
|
|
950
1033
|
}
|
|
951
1034
|
const dependencyUrlInfo = finalGraph.getUrlInfo(dependencyUrl)
|
|
@@ -953,7 +1036,7 @@ const applyUrlVersioning = async ({
|
|
|
953
1036
|
// this content is part of the file, no need to take into account twice
|
|
954
1037
|
dependencyUrlInfo.isInline ||
|
|
955
1038
|
// this dependency content is not known
|
|
956
|
-
dependencyUrlInfo.
|
|
1039
|
+
!dependencyUrlInfo.shouldHandle
|
|
957
1040
|
) {
|
|
958
1041
|
return
|
|
959
1042
|
}
|
|
@@ -995,7 +1078,7 @@ const applyUrlVersioning = async ({
|
|
|
995
1078
|
runtimeCompat,
|
|
996
1079
|
writeGeneratedFiles,
|
|
997
1080
|
plugins: [
|
|
998
|
-
|
|
1081
|
+
urlAnalysisPlugin,
|
|
999
1082
|
jsenvPluginInline({
|
|
1000
1083
|
fetchInlineUrls: false,
|
|
1001
1084
|
analyzeConvertedScripts: true, // to be able to version their urls
|
|
@@ -1005,18 +1088,38 @@ const applyUrlVersioning = async ({
|
|
|
1005
1088
|
name: "jsenv:versioning",
|
|
1006
1089
|
appliesDuring: { build: true },
|
|
1007
1090
|
resolveUrl: (reference) => {
|
|
1008
|
-
if (reference.specifier[0] === "#") {
|
|
1009
|
-
reference.external = true
|
|
1010
|
-
}
|
|
1011
1091
|
const buildUrl = buildUrls[reference.specifier]
|
|
1012
1092
|
if (buildUrl) {
|
|
1013
1093
|
return buildUrl
|
|
1014
1094
|
}
|
|
1015
|
-
const
|
|
1095
|
+
const urlObject = new URL(
|
|
1096
|
+
reference.specifier,
|
|
1097
|
+
reference.baseUrl || reference.parentUrl,
|
|
1098
|
+
)
|
|
1099
|
+
const url = urlObject.href
|
|
1100
|
+
// during versioning we revisit the deps
|
|
1101
|
+
// but the code used to enforce trailing slash on directories
|
|
1102
|
+
// is not applied because "jsenv:file_url_resolution" is not used
|
|
1103
|
+
// so here we search if the url with a trailing slash exists
|
|
1104
|
+
if (
|
|
1105
|
+
reference.type === "filesystem" &&
|
|
1106
|
+
!urlObject.pathname.endsWith("/")
|
|
1107
|
+
) {
|
|
1108
|
+
const urlWithTrailingSlash = `${url}/`
|
|
1109
|
+
const specifier = Object.keys(buildUrls).find(
|
|
1110
|
+
(key) => buildUrls[key] === urlWithTrailingSlash,
|
|
1111
|
+
)
|
|
1112
|
+
if (specifier) {
|
|
1113
|
+
return urlWithTrailingSlash
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1016
1116
|
return url
|
|
1017
1117
|
},
|
|
1018
1118
|
formatUrl: (reference) => {
|
|
1019
|
-
if (reference.isInline) {
|
|
1119
|
+
if (reference.isInline || reference.url.startsWith("data:")) {
|
|
1120
|
+
return null
|
|
1121
|
+
}
|
|
1122
|
+
if (reference.isRessourceHint) {
|
|
1020
1123
|
return null
|
|
1021
1124
|
}
|
|
1022
1125
|
// specifier comes from "normalize" hook done a bit earlier in this file
|
|
@@ -1025,8 +1128,7 @@ const applyUrlVersioning = async ({
|
|
|
1025
1128
|
if (!canUseVersionedUrl(referencedUrlInfo)) {
|
|
1026
1129
|
return reference.specifier
|
|
1027
1130
|
}
|
|
1028
|
-
|
|
1029
|
-
if (!referencedUrlInfo.url.startsWith("file:")) {
|
|
1131
|
+
if (!referencedUrlInfo.shouldHandle) {
|
|
1030
1132
|
return null
|
|
1031
1133
|
}
|
|
1032
1134
|
const versionedUrl = referencedUrlInfo.data.versionedUrl
|
|
@@ -1063,9 +1165,6 @@ const applyUrlVersioning = async ({
|
|
|
1063
1165
|
return versionedSpecifier
|
|
1064
1166
|
},
|
|
1065
1167
|
fetchUrlContent: (versionedUrlInfo) => {
|
|
1066
|
-
if (!versionedUrlInfo.url.startsWith("file:")) {
|
|
1067
|
-
return { external: true }
|
|
1068
|
-
}
|
|
1069
1168
|
if (versionedUrlInfo.isInline) {
|
|
1070
1169
|
const rawUrlInfo = rawGraph.getUrlInfo(
|
|
1071
1170
|
rawUrls[versionedUrlInfo.url],
|
|
@@ -1090,6 +1189,7 @@ const applyUrlVersioning = async ({
|
|
|
1090
1189
|
urlGraph: finalGraph,
|
|
1091
1190
|
kitchen: versioningKitchen,
|
|
1092
1191
|
skipRessourceHint: true,
|
|
1192
|
+
writeGeneratedFiles,
|
|
1093
1193
|
startLoading: (cookEntryFile) => {
|
|
1094
1194
|
postBuildEntryUrls.forEach((postBuildEntryUrl) => {
|
|
1095
1195
|
cookEntryFile({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { urlToFilename } from "@jsenv/filesystem"
|
|
1
|
+
import { urlToFilename, urlToRelativeUrl } from "@jsenv/filesystem"
|
|
2
2
|
|
|
3
3
|
import { memoizeByFirstArgument } from "@jsenv/utils/memoize/memoize_by_first_argument.js"
|
|
4
4
|
|
|
@@ -17,6 +17,7 @@ export const createBuilUrlsGenerator = ({ buildDirectoryUrl }) => {
|
|
|
17
17
|
|
|
18
18
|
const generate = memoizeByFirstArgument((url, { urlInfo, parentUrlInfo }) => {
|
|
19
19
|
const directoryPath = determineDirectoryPath({
|
|
20
|
+
buildDirectoryUrl,
|
|
20
21
|
urlInfo,
|
|
21
22
|
parentUrlInfo,
|
|
22
23
|
})
|
|
@@ -69,9 +70,24 @@ const splitFileExtension = (filename) => {
|
|
|
69
70
|
return [filename.slice(0, dotLastIndex), filename.slice(dotLastIndex)]
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
const determineDirectoryPath = ({
|
|
73
|
+
const determineDirectoryPath = ({
|
|
74
|
+
buildDirectoryUrl,
|
|
75
|
+
urlInfo,
|
|
76
|
+
parentUrlInfo,
|
|
77
|
+
}) => {
|
|
78
|
+
if (urlInfo.type === "directory") {
|
|
79
|
+
return ""
|
|
80
|
+
}
|
|
81
|
+
if (parentUrlInfo && parentUrlInfo.type === "directory") {
|
|
82
|
+
const parentDirectoryPath = urlToRelativeUrl(
|
|
83
|
+
parentUrlInfo.url,
|
|
84
|
+
buildDirectoryUrl,
|
|
85
|
+
)
|
|
86
|
+
return parentDirectoryPath
|
|
87
|
+
}
|
|
73
88
|
if (urlInfo.isInline) {
|
|
74
89
|
const parentDirectoryPath = determineDirectoryPath({
|
|
90
|
+
buildDirectoryUrl,
|
|
75
91
|
urlInfo: parentUrlInfo,
|
|
76
92
|
})
|
|
77
93
|
return parentDirectoryPath
|
|
@@ -41,7 +41,11 @@ const injectVersionMappings = async ({ urlInfo, kitchen, versionMappings }) => {
|
|
|
41
41
|
|
|
42
42
|
const jsInjector = (urlInfo, { versionMappings }) => {
|
|
43
43
|
const magicSource = createMagicSource(urlInfo.content)
|
|
44
|
-
magicSource.prepend(
|
|
44
|
+
magicSource.prepend(
|
|
45
|
+
generateClientCodeForVersionMappings(versionMappings, {
|
|
46
|
+
globalName: urlInfo.data.isWebWorkerEntryPoint ? "self" : "window",
|
|
47
|
+
}),
|
|
48
|
+
)
|
|
45
49
|
return magicSource.toContentAndSourcemap()
|
|
46
50
|
}
|
|
47
51
|
|
|
@@ -57,7 +61,9 @@ const injectors = {
|
|
|
57
61
|
htmlAst,
|
|
58
62
|
createHtmlNode({
|
|
59
63
|
"tagName": "script",
|
|
60
|
-
"textContent": generateClientCodeForVersionMappings(versionMappings
|
|
64
|
+
"textContent": generateClientCodeForVersionMappings(versionMappings, {
|
|
65
|
+
globalName: "window",
|
|
66
|
+
}),
|
|
61
67
|
"injected-by": "jsenv:versioning",
|
|
62
68
|
}),
|
|
63
69
|
)
|
|
@@ -69,12 +75,19 @@ const injectors = {
|
|
|
69
75
|
js_module: jsInjector,
|
|
70
76
|
}
|
|
71
77
|
|
|
72
|
-
const generateClientCodeForVersionMappings = (
|
|
78
|
+
const generateClientCodeForVersionMappings = (
|
|
79
|
+
versionMappings,
|
|
80
|
+
{ globalName },
|
|
81
|
+
) => {
|
|
73
82
|
return `
|
|
83
|
+
;(function() {
|
|
84
|
+
|
|
74
85
|
var __versionMappings__ = ${JSON.stringify(versionMappings, null, " ")};
|
|
75
|
-
|
|
76
|
-
__envGlobal__.__v__ = function (specifier) {
|
|
86
|
+
${globalName}.__v__ = function (specifier) {
|
|
77
87
|
return __versionMappings__[specifier] || specifier
|
|
78
88
|
};
|
|
89
|
+
|
|
90
|
+
})();
|
|
91
|
+
|
|
79
92
|
`
|
|
80
93
|
}
|
|
@@ -22,7 +22,7 @@ export const injectServiceWorkerUrls = async ({
|
|
|
22
22
|
}
|
|
23
23
|
const serviceWorkerUrls = {}
|
|
24
24
|
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
25
|
-
if (urlInfo.isInline || urlInfo.
|
|
25
|
+
if (urlInfo.isInline || !urlInfo.shouldHandle) {
|
|
26
26
|
return
|
|
27
27
|
}
|
|
28
28
|
if (!urlInfo.url.startsWith("file:")) {
|