@jsenv/core 27.0.0-alpha.1 → 27.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -5
- package/src/build/build.js +208 -78
- package/src/build/build_urls_generator.js +16 -7
- package/src/build/inject_service_worker_urls.js +25 -0
- package/src/build/inject_version_mappings.js +4 -3
- package/src/build/plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js +16 -14
- package/src/dev/start_dev_server.js +6 -3
- package/src/execute/execute.js +7 -1
- package/src/omega/core_plugins/babel/{babel_helper → helpers}/babel_plugin_babel_helpers_as_jsenv_imports.js +1 -2
- package/src/omega/core_plugins/babel/helpers/babel_plugin_structure.js +69 -80
- package/src/omega/core_plugins/babel/jsenv_plugin_babel.js +19 -5
- package/src/omega/core_plugins/html_supervisor/client/uneval_exception.js +1 -1
- package/src/omega/core_plugins/import_meta_scenarios/jsenv_plugin_import_meta_scenarios.js +16 -6
- package/src/omega/core_plugins/inject_globals/jsenv_plugin_inject_globals.js +27 -0
- package/src/omega/core_plugins/inline/jsenv_plugin_new_inline_content.js +1 -4
- package/src/omega/core_plugins.js +3 -0
- package/src/omega/file_url_converter.js +8 -50
- package/src/omega/kitchen.js +14 -15
- package/src/omega/runtime_support/features_compatibility.js +40 -1
- package/src/omega/runtime_support/runtime_support.js +48 -16
- package/src/omega/url_graph/url_graph_load.js +1 -0
- package/src/omega/url_graph.js +1 -0
- package/src/test/execute_plan.js +5 -3
- package/src/test/execute_test_plan.js +11 -1
- package/src/omega/core_plugins/babel/babel_helper/babel_helper_directory.js +0 -29
- package/src/omega/core_plugins/babel/babel_helper/client/.eslintrc.cjs +0 -24
- package/src/omega/core_plugins/babel/babel_helper/client/AsyncGenerator/AsyncGenerator.js +0 -81
- package/src/omega/core_plugins/babel/babel_helper/client/AwaitValue/AwaitValue.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -33
- package/src/omega/core_plugins/babel/babel_helper/client/arrayLikeToArray/arrayLikeToArray.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/arrayWithHoles/arrayWithHoles.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/arrayWithoutHoles/arrayWithoutHoles.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/assertThisInitialized/assertThisInitialized.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -40
- package/src/omega/core_plugins/babel/babel_helper/client/asyncIterator/asyncIterator.js +0 -65
- package/src/omega/core_plugins/babel/babel_helper/client/asyncToGenerator/asyncToGenerator.js +0 -34
- package/src/omega/core_plugins/babel/babel_helper/client/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -20
- package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -13
- package/src/omega/core_plugins/babel/babel_helper/client/classCallCheck/classCallCheck.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/classNameTDZError/classNameTDZError.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldGet/classPrivateFieldGet.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateFieldSet/classPrivateFieldSet.js +0 -8
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateMethodGet/classPrivateMethodGet.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classPrivateMethodSet/classPrivateMethodSet.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -9
- package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -15
- package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/construct/construct.js +0 -16
- package/src/omega/core_plugins/babel/babel_helper/client/createClass/createClass.js +0 -15
- package/src/omega/core_plugins/babel/babel_helper/client/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -60
- package/src/omega/core_plugins/babel/babel_helper/client/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -23
- package/src/omega/core_plugins/babel/babel_helper/client/createRawReactElement/createRawReactElement.js +0 -50
- package/src/omega/core_plugins/babel/babel_helper/client/createSuper/createSuper.js +0 -22
- package/src/omega/core_plugins/babel/babel_helper/client/decorate/decorate.js +0 -403
- package/src/omega/core_plugins/babel/babel_helper/client/defaults/defaults.js +0 -11
- package/src/omega/core_plugins/babel/babel_helper/client/defineEnumerableProperties/defineEnumerableProperties.js +0 -23
- package/src/omega/core_plugins/babel/babel_helper/client/defineProperty/defineProperty.js +0 -18
- package/src/omega/core_plugins/babel/babel_helper/client/extends/extends.js +0 -14
- package/src/omega/core_plugins/babel/babel_helper/client/get/get.js +0 -19
- package/src/omega/core_plugins/babel/babel_helper/client/getPrototypeOf/getPrototypeOf.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/inherits/inherits.js +0 -19
- package/src/omega/core_plugins/babel/babel_helper/client/inheritsLoose/inheritsLoose.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/initializerDefineProperty/initializerDefineProperty.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/initializerWarningHelper/initializerWarningHelper.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/instanceof/instanceof.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/interopRequireDefault/interopRequireDefault.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/interopRequireWildcard/interopRequireWildcard.js +0 -37
- package/src/omega/core_plugins/babel/babel_helper/client/isNativeFunction/isNativeFunction.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -21
- package/src/omega/core_plugins/babel/babel_helper/client/iterableToArray/iterableToArray.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/iterableToArrayLimit/iterableToArrayLimit.js +0 -36
- package/src/omega/core_plugins/babel/babel_helper/client/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/jsx/jsx.js +0 -50
- package/src/omega/core_plugins/babel/babel_helper/client/maybeArrayLike/maybeArrayLike.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/newArrowCheck/newArrowCheck.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/nonIterableRest/nonIterableRest.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/nonIterableSpread/nonIterableSpread.js +0 -5
- package/src/omega/core_plugins/babel/babel_helper/client/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/objectSpread/objectSpread.js +0 -23
- package/src/omega/core_plugins/babel/babel_helper/client/objectSpread2/objectSpread2.js +0 -41
- package/src/omega/core_plugins/babel/babel_helper/client/objectWithoutProperties/objectWithoutProperties.js +0 -19
- package/src/omega/core_plugins/babel/babel_helper/client/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -13
- package/src/omega/core_plugins/babel/babel_helper/client/possibleConstructorReturn/possibleConstructorReturn.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/readOnlyError/readOnlyError.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/readme.md +0 -8
- package/src/omega/core_plugins/babel/babel_helper/client/set/set.js +0 -44
- package/src/omega/core_plugins/babel/babel_helper/client/setPrototypeOf/setPrototypeOf.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -8
- package/src/omega/core_plugins/babel/babel_helper/client/slicedToArray/slicedToArray.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/slicedToArrayLoose/slicedToArrayLoose.js +0 -13
- package/src/omega/core_plugins/babel/babel_helper/client/superPropBase/superPropBase.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -7
- package/src/omega/core_plugins/babel/babel_helper/client/tdz/tdz.js +0 -4
- package/src/omega/core_plugins/babel/babel_helper/client/temporalRef/temporalRef.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/temporalUndefined/temporalUndefined.js +0 -3
- package/src/omega/core_plugins/babel/babel_helper/client/toArray/toArray.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/toConsumableArray/toConsumableArray.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/toPrimitive/toPrimitive.js +0 -10
- package/src/omega/core_plugins/babel/babel_helper/client/toPropertyKey/toPropertyKey.js +0 -6
- package/src/omega/core_plugins/babel/babel_helper/client/typeof/typeof.js +0 -14
- package/src/omega/core_plugins/babel/babel_helper/client/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -12
- package/src/omega/core_plugins/babel/babel_helper/client/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -8
- package/src/omega/core_plugins/babel/babel_helper/client/wrapNativeSuper/wrapNativeSuper.js +0 -30
- package/src/omega/core_plugins/babel/babel_helper/client/wrapRegExp/wrapRegExp.js +0 -63
- package/src/omega/core_plugins/babel/babel_helper/client/writeOnlyError/writeOnlyError.js +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "27.0.0-alpha.
|
|
3
|
+
"version": "27.0.0-alpha.10",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"node": ">=16.13.0"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
"registry": "https://registry.npmjs.org"
|
|
14
|
+
"access": "public"
|
|
16
15
|
},
|
|
17
16
|
"type": "module",
|
|
18
17
|
"imports": {},
|
|
@@ -54,7 +53,7 @@
|
|
|
54
53
|
"@c88/v8-coverage": "0.1.1",
|
|
55
54
|
"@financial-times/polyfill-useragent-normaliser": "2.0.1",
|
|
56
55
|
"@jsenv/abort": "4.1.2",
|
|
57
|
-
"@jsenv/babel-plugins": "1.0.
|
|
56
|
+
"@jsenv/babel-plugins": "1.0.2",
|
|
58
57
|
"@jsenv/filesystem": "3.1.0",
|
|
59
58
|
"@jsenv/importmap": "1.2.0",
|
|
60
59
|
"@jsenv/integrity": "0.0.1",
|
|
@@ -107,4 +106,4 @@
|
|
|
107
106
|
"redux": "4.1.2",
|
|
108
107
|
"rollup": "2.70.1"
|
|
109
108
|
}
|
|
110
|
-
}
|
|
109
|
+
}
|
package/src/build/build.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
injectQueryParams,
|
|
23
23
|
setUrlFilename,
|
|
24
24
|
} from "@jsenv/utils/urls/url_utils.js"
|
|
25
|
-
import {
|
|
25
|
+
import { createVersionGenerator } from "@jsenv/utils/versioning/version_generator.js"
|
|
26
26
|
import { generateSourcemapUrl } from "@jsenv/utils/sourcemap/sourcemap_utils.js"
|
|
27
27
|
import {
|
|
28
28
|
parseHtmlString,
|
|
@@ -38,11 +38,12 @@ import { loadUrlGraph } from "../omega/url_graph/url_graph_load.js"
|
|
|
38
38
|
import { createUrlGraphSummary } from "../omega/url_graph/url_graph_report.js"
|
|
39
39
|
import { sortUrlGraphByDependencies } from "../omega/url_graph/url_graph_sort.js"
|
|
40
40
|
|
|
41
|
-
import { createBuilUrlsGenerator } from "./build_urls_generator.js"
|
|
42
|
-
import { injectVersionMappings } from "./inject_version_mappings.js"
|
|
43
41
|
import { jsenvPluginBundleJsModule } from "./plugins/bundle_js_module/jsenv_plugin_bundle_js_module.js"
|
|
44
42
|
import { jsenvPluginMinifyJs } from "./plugins/minify_js/jsenv_plugin_minify_js.js"
|
|
45
43
|
import { jsenvPluginMinifyHtml } from "./plugins/minify_html/jsenv_plugin_minify_html.js"
|
|
44
|
+
import { createBuilUrlsGenerator } from "./build_urls_generator.js"
|
|
45
|
+
import { injectVersionMappings } from "./inject_version_mappings.js"
|
|
46
|
+
import { injectServiceWorkerUrls } from "./inject_service_worker_urls.js"
|
|
46
47
|
|
|
47
48
|
export const build = async ({
|
|
48
49
|
signal = new AbortController().signal,
|
|
@@ -59,6 +60,7 @@ export const build = async ({
|
|
|
59
60
|
nodeEsmResolution,
|
|
60
61
|
fileSystemMagicResolution,
|
|
61
62
|
babel,
|
|
63
|
+
injectedGlobals,
|
|
62
64
|
runtimeSupport = defaultRuntimeSupport,
|
|
63
65
|
sourcemaps = isPreview ? "file" : false,
|
|
64
66
|
|
|
@@ -70,6 +72,8 @@ export const build = async ({
|
|
|
70
72
|
writeOnFileSystem = true,
|
|
71
73
|
buildDirectoryClean = true,
|
|
72
74
|
baseUrl = "/",
|
|
75
|
+
assetManifest = true,
|
|
76
|
+
assetManifestFileRelativeUrl = "asset-manifest.json",
|
|
73
77
|
}) => {
|
|
74
78
|
const logger = createLogger({ logLevel })
|
|
75
79
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl)
|
|
@@ -84,7 +88,7 @@ export const build = async ({
|
|
|
84
88
|
const entryPointKeys = Object.keys(entryPoints)
|
|
85
89
|
if (entryPointKeys.length === 1) {
|
|
86
90
|
logger.info(`
|
|
87
|
-
build ${entryPointKeys[0]}`)
|
|
91
|
+
build "${entryPointKeys[0]}"`)
|
|
88
92
|
} else {
|
|
89
93
|
logger.info(`
|
|
90
94
|
build ${entryPointKeys.length} entry points`)
|
|
@@ -112,6 +116,7 @@ build ${entryPointKeys.length} entry points`)
|
|
|
112
116
|
nodeEsmResolution,
|
|
113
117
|
fileSystemMagicResolution,
|
|
114
118
|
babel,
|
|
119
|
+
injectedGlobals,
|
|
115
120
|
}),
|
|
116
121
|
jsenvPluginBundleJsModule(),
|
|
117
122
|
...(minify ? [jsenvPluginMinifyJs(), jsenvPluginMinifyHtml()] : []),
|
|
@@ -119,22 +124,23 @@ build ${entryPointKeys.length} entry points`)
|
|
|
119
124
|
scenario: "build",
|
|
120
125
|
sourcemaps,
|
|
121
126
|
})
|
|
122
|
-
const
|
|
123
|
-
Object.keys(entryPoints).forEach((key) => {
|
|
124
|
-
cookEntryFile({
|
|
125
|
-
trace: `"${key}" in entryPoints parameter`,
|
|
126
|
-
type: "entry_point",
|
|
127
|
-
specifier: key,
|
|
128
|
-
})
|
|
129
|
-
})
|
|
130
|
-
}
|
|
127
|
+
const entryUrls = []
|
|
131
128
|
try {
|
|
132
129
|
await loadUrlGraph({
|
|
133
130
|
urlGraph: rawGraph,
|
|
134
131
|
kitchen: rawGraphKitchen,
|
|
135
132
|
outDirectoryUrl: new URL(`.jsenv/build/`, rootDirectoryUrl),
|
|
136
133
|
runtimeSupport,
|
|
137
|
-
startLoading:
|
|
134
|
+
startLoading: (cookEntryFile) => {
|
|
135
|
+
Object.keys(entryPoints).forEach((key) => {
|
|
136
|
+
const [, entryUrlInfo] = cookEntryFile({
|
|
137
|
+
trace: `"${key}" in entryPoints parameter`,
|
|
138
|
+
type: "entry_point",
|
|
139
|
+
specifier: key,
|
|
140
|
+
})
|
|
141
|
+
entryUrls.push(entryUrlInfo.url)
|
|
142
|
+
})
|
|
143
|
+
},
|
|
138
144
|
})
|
|
139
145
|
} catch (e) {
|
|
140
146
|
prebuildTask.fail()
|
|
@@ -180,30 +186,39 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
|
|
|
180
186
|
return
|
|
181
187
|
}
|
|
182
188
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
189
|
+
GRAPH.forEach(rawGraph, (rawUrlInfo) => {
|
|
190
|
+
if (rawUrlInfo.data.isEntryPoint) {
|
|
191
|
+
addToBundlerIfAny(rawUrlInfo)
|
|
192
|
+
if (rawUrlInfo.type === "html") {
|
|
193
|
+
rawUrlInfo.dependencies.forEach((dependencyUrl) => {
|
|
194
|
+
const dependencyUrlInfo = rawGraph.getUrlInfo(dependencyUrl)
|
|
195
|
+
if (dependencyUrlInfo.isInline) {
|
|
196
|
+
if (dependencyUrlInfo.type === "js_module") {
|
|
197
|
+
// bundle inline script type module deps
|
|
198
|
+
dependencyUrlInfo.references.forEach((inlineScriptRef) => {
|
|
199
|
+
if (inlineScriptRef.type === "js_import_export") {
|
|
200
|
+
addToBundlerIfAny(rawGraph.getUrlInfo(inlineScriptRef.url))
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
// inline content cannot be bundled
|
|
205
|
+
return
|
|
200
206
|
}
|
|
201
|
-
|
|
202
|
-
|
|
207
|
+
addToBundlerIfAny(dependencyUrlInfo)
|
|
208
|
+
})
|
|
209
|
+
return
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// File referenced with new URL('./file.js', import.meta.url)
|
|
213
|
+
// are entry points that can be bundled
|
|
214
|
+
// For instance we will bundle service worker/workers detected like this
|
|
215
|
+
if (rawUrlInfo.type === "js_module") {
|
|
216
|
+
rawUrlInfo.references.forEach((reference) => {
|
|
217
|
+
if (reference.type === "js_import_meta_url_pattern") {
|
|
218
|
+
const urlInfo = rawGraph.getUrlInfo(reference.url)
|
|
219
|
+
addToBundlerIfAny(urlInfo)
|
|
203
220
|
}
|
|
204
|
-
addToBundlerIfAny(dependencyUrlInfo)
|
|
205
221
|
})
|
|
206
|
-
return
|
|
207
222
|
}
|
|
208
223
|
})
|
|
209
224
|
await Object.keys(bundlers).reduce(async (previous, type) => {
|
|
@@ -238,6 +253,7 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
|
|
|
238
253
|
const rawUrlInfo = rawGraph.getUrlInfo(url)
|
|
239
254
|
bundleUrlInfos[url] = {
|
|
240
255
|
type,
|
|
256
|
+
subtype: rawUrlInfo ? rawUrlInfo.subtype : undefined,
|
|
241
257
|
...bundleUrlInfo,
|
|
242
258
|
data: {
|
|
243
259
|
...(rawUrlInfo ? rawUrlInfo.data : {}),
|
|
@@ -344,8 +360,7 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
|
|
|
344
360
|
return buildUrl
|
|
345
361
|
}
|
|
346
362
|
if (reference.isInline) {
|
|
347
|
-
const
|
|
348
|
-
const rawUrlInfo = rawGraph.urlInfos[url]
|
|
363
|
+
const rawUrlInfo = GRAPH.find(rawGraph, (rawUrlInfo) => {
|
|
349
364
|
if (!rawUrlInfo.isInline) {
|
|
350
365
|
return false
|
|
351
366
|
}
|
|
@@ -354,10 +369,9 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
|
|
|
354
369
|
}
|
|
355
370
|
return false
|
|
356
371
|
})
|
|
357
|
-
if (!
|
|
372
|
+
if (!rawUrlInfo) {
|
|
358
373
|
throw new Error(`cannot find raw url`)
|
|
359
374
|
}
|
|
360
|
-
const rawUrlInfo = rawGraph.getUrlInfo(rawUrl)
|
|
361
375
|
const parentUrlInfo = finalGraph.getUrlInfo(reference.parentUrl)
|
|
362
376
|
const buildUrl = buildUrlsGenerator.generate(
|
|
363
377
|
reference.url,
|
|
@@ -365,7 +379,7 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
|
|
|
365
379
|
parentUrlInfo,
|
|
366
380
|
)
|
|
367
381
|
rawUrls[buildUrl] = reference.url
|
|
368
|
-
reference.data.rawUrl =
|
|
382
|
+
reference.data.rawUrl = rawUrlInfo.url
|
|
369
383
|
return buildUrl
|
|
370
384
|
}
|
|
371
385
|
if (reference.type === "sourcemap_comment") {
|
|
@@ -402,6 +416,7 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
|
|
|
402
416
|
const rawUrl = finalUrlInfo.data.rawUrl
|
|
403
417
|
const bundleUrlInfo = bundleUrlInfos[rawUrl]
|
|
404
418
|
const urlInfo = bundleUrlInfo || rawGraph.getUrlInfo(rawUrl)
|
|
419
|
+
finalUrlInfo.subtype = urlInfo.subtype
|
|
405
420
|
return {
|
|
406
421
|
data: bundleUrlInfo ? bundleUrlInfo.data : undefined,
|
|
407
422
|
originalContent: urlInfo.originalContent,
|
|
@@ -447,13 +462,23 @@ ${Object.keys(rawGraph.urlInfos).join("\n")}`,
|
|
|
447
462
|
sourcemaps,
|
|
448
463
|
})
|
|
449
464
|
const buildTask = createTaskLog(logger, "build")
|
|
465
|
+
const postBuildEntryUrls = []
|
|
450
466
|
try {
|
|
451
467
|
await loadUrlGraph({
|
|
452
468
|
urlGraph: finalGraph,
|
|
453
469
|
kitchen: finalGraphKitchen,
|
|
454
470
|
outDirectoryUrl: new URL(".jsenv/postbuild/", rootDirectoryUrl),
|
|
455
471
|
runtimeSupport,
|
|
456
|
-
startLoading:
|
|
472
|
+
startLoading: (cookEntryFile) => {
|
|
473
|
+
entryUrls.forEach((entryUrl) => {
|
|
474
|
+
const [, postBuildEntryUrlInfo] = cookEntryFile({
|
|
475
|
+
trace: `entryPoint`,
|
|
476
|
+
type: "entry_point",
|
|
477
|
+
specifier: entryUrl,
|
|
478
|
+
})
|
|
479
|
+
postBuildEntryUrls.push(postBuildEntryUrlInfo.url)
|
|
480
|
+
})
|
|
481
|
+
},
|
|
457
482
|
})
|
|
458
483
|
} catch (e) {
|
|
459
484
|
buildTask.fail()
|
|
@@ -480,8 +505,8 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
480
505
|
if (urlInfo.isInline) {
|
|
481
506
|
return
|
|
482
507
|
}
|
|
483
|
-
const
|
|
484
|
-
|
|
508
|
+
const versionGenerator = createVersionGenerator()
|
|
509
|
+
versionGenerator.augmentWithContent({
|
|
485
510
|
content: urlInfo.content,
|
|
486
511
|
contentType: urlInfo.contentType,
|
|
487
512
|
lineBreakNormalization,
|
|
@@ -493,7 +518,7 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
493
518
|
return
|
|
494
519
|
}
|
|
495
520
|
if (dependencyUrlInfo.data.version) {
|
|
496
|
-
|
|
521
|
+
versionGenerator.augmentWithDependencyVersion(
|
|
497
522
|
dependencyUrlInfo.data.version,
|
|
498
523
|
)
|
|
499
524
|
} else {
|
|
@@ -501,14 +526,14 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
501
526
|
// it means there is a circular dependency between this file
|
|
502
527
|
// and it's dependency
|
|
503
528
|
// in that case we'll use the dependency content
|
|
504
|
-
|
|
529
|
+
versionGenerator.augmentWithContent({
|
|
505
530
|
content: dependencyUrlInfo.content,
|
|
506
531
|
contentType: dependencyUrlInfo.contentType,
|
|
507
532
|
lineBreakNormalization,
|
|
508
533
|
})
|
|
509
534
|
}
|
|
510
535
|
})
|
|
511
|
-
urlInfo.data.version =
|
|
536
|
+
urlInfo.data.version = versionGenerator.generate()
|
|
512
537
|
urlInfo.data.versionedUrl = injectVersionIntoBuildUrl({
|
|
513
538
|
buildUrl: urlInfo.url,
|
|
514
539
|
version: urlInfo.data.version,
|
|
@@ -540,12 +565,12 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
540
565
|
{
|
|
541
566
|
name: "jsenv:versioning",
|
|
542
567
|
appliesDuring: { build: true },
|
|
543
|
-
resolve: (
|
|
544
|
-
const buildUrl = buildUrls[specifier]
|
|
568
|
+
resolve: (reference) => {
|
|
569
|
+
const buildUrl = buildUrls[reference.specifier]
|
|
545
570
|
if (buildUrl) {
|
|
546
571
|
return buildUrl
|
|
547
572
|
}
|
|
548
|
-
const url = new URL(specifier, parentUrl).href
|
|
573
|
+
const url = new URL(reference.specifier, reference.parentUrl).href
|
|
549
574
|
return url
|
|
550
575
|
},
|
|
551
576
|
formatReferencedUrl: (reference) => {
|
|
@@ -555,7 +580,11 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
555
580
|
// specifier comes from "normalize" hook done a bit earlier in this file
|
|
556
581
|
// we want to get back their build url to access their infos
|
|
557
582
|
const referencedUrlInfo = finalGraph.getUrlInfo(reference.url)
|
|
558
|
-
if (
|
|
583
|
+
if (
|
|
584
|
+
referencedUrlInfo.data.isEntryPoint ||
|
|
585
|
+
referencedUrlInfo.subtype === "service_worker" ||
|
|
586
|
+
referencedUrlInfo.type === "webmanifest"
|
|
587
|
+
) {
|
|
559
588
|
return reference.specifier
|
|
560
589
|
}
|
|
561
590
|
// data:* urls and so on
|
|
@@ -593,13 +622,12 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
593
622
|
}
|
|
594
623
|
return versionedSpecifier
|
|
595
624
|
},
|
|
596
|
-
load: (
|
|
597
|
-
const urlInfo = finalGraph.getUrlInfo(url)
|
|
625
|
+
load: (finalUrlInfo) => {
|
|
598
626
|
return {
|
|
599
|
-
originalContent:
|
|
600
|
-
contentType:
|
|
601
|
-
content:
|
|
602
|
-
sourcemap:
|
|
627
|
+
originalContent: finalUrlInfo.originalContent,
|
|
628
|
+
contentType: finalUrlInfo.contentType,
|
|
629
|
+
content: finalUrlInfo.content,
|
|
630
|
+
sourcemap: finalUrlInfo.sourcemap,
|
|
603
631
|
}
|
|
604
632
|
},
|
|
605
633
|
},
|
|
@@ -608,15 +636,22 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
608
636
|
sourcemaps,
|
|
609
637
|
})
|
|
610
638
|
// arrange state before reloading all files
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
urlInfo.data.promise = null
|
|
639
|
+
GRAPH.forEach(finalGraph, (finalUrlInfo) => {
|
|
640
|
+
finalUrlInfo.data.promise = null
|
|
614
641
|
})
|
|
615
642
|
await loadUrlGraph({
|
|
616
643
|
urlGraph: finalGraph,
|
|
617
644
|
kitchen: versioningKitchen,
|
|
618
645
|
runtimeSupport,
|
|
619
|
-
startLoading:
|
|
646
|
+
startLoading: (cookEntryFile) => {
|
|
647
|
+
postBuildEntryUrls.forEach((postBuildEntryUrl) => {
|
|
648
|
+
cookEntryFile({
|
|
649
|
+
trace: `entryPoint`,
|
|
650
|
+
type: "entry_point",
|
|
651
|
+
specifier: postBuildEntryUrl,
|
|
652
|
+
})
|
|
653
|
+
})
|
|
654
|
+
},
|
|
620
655
|
})
|
|
621
656
|
if (usedVersionMappings.length) {
|
|
622
657
|
const versionMappingsNeeded = {}
|
|
@@ -624,12 +659,12 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
624
659
|
versionMappingsNeeded[specifier] = versionMappings[specifier]
|
|
625
660
|
})
|
|
626
661
|
await Promise.all(
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
if (!buildUrlInfo.data.isEntryPoint) {
|
|
662
|
+
GRAPH.map(finalGraph, async (urlInfo) => {
|
|
663
|
+
if (!urlInfo.data.isEntryPoint) {
|
|
630
664
|
return
|
|
631
665
|
}
|
|
632
|
-
await injectVersionMappings(
|
|
666
|
+
await injectVersionMappings({
|
|
667
|
+
urlInfo,
|
|
633
668
|
kitchen: finalGraphKitchen,
|
|
634
669
|
versionMappings: versionMappingsNeeded,
|
|
635
670
|
})
|
|
@@ -643,34 +678,98 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
643
678
|
versioningTask.done()
|
|
644
679
|
}
|
|
645
680
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
const buildManifest = {}
|
|
649
|
-
Object.keys(finalGraph.urlInfos).forEach((url) => {
|
|
650
|
-
if (!url.startsWith("file:")) {
|
|
681
|
+
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
682
|
+
if (!urlInfo.url.startsWith("file:")) {
|
|
651
683
|
return
|
|
652
684
|
}
|
|
653
|
-
const
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
685
|
+
const version = urlInfo.data.version
|
|
686
|
+
const useVersionedUrl =
|
|
687
|
+
!urlInfo.data.isEntryPoint &&
|
|
688
|
+
urlInfo.subtype !== "service_worker" &&
|
|
689
|
+
urlInfo.type !== "webmanifest" &&
|
|
690
|
+
version
|
|
691
|
+
const buildUrl = useVersionedUrl ? urlInfo.data.versionedUrl : urlInfo.url
|
|
657
692
|
if (!urlIsInsideOf(buildUrl, buildDirectoryUrl)) {
|
|
658
693
|
throw new Error(`build url outside build directory`)
|
|
659
694
|
}
|
|
660
695
|
const buildRelativeUrl = urlToRelativeUrl(buildUrl, buildDirectoryUrl)
|
|
661
|
-
|
|
662
|
-
|
|
696
|
+
urlInfo.data.buildUrl = buildUrl
|
|
697
|
+
urlInfo.data.buildUrlIsVersioned = useVersionedUrl
|
|
698
|
+
urlInfo.data.buildRelativeUrl = buildRelativeUrl
|
|
699
|
+
})
|
|
700
|
+
|
|
701
|
+
const hasServiceWorker = Boolean(
|
|
702
|
+
GRAPH.find(
|
|
703
|
+
finalGraph,
|
|
704
|
+
(finalUrlInfo) => finalUrlInfo.subtype === "service_worker",
|
|
705
|
+
),
|
|
706
|
+
)
|
|
707
|
+
if (hasServiceWorker) {
|
|
708
|
+
const serviceWorkerUrls = {}
|
|
709
|
+
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
710
|
+
if (!urlInfo.url.startsWith("file:")) {
|
|
711
|
+
return
|
|
712
|
+
}
|
|
713
|
+
if (urlInfo.isInline) {
|
|
714
|
+
return
|
|
715
|
+
}
|
|
716
|
+
if (urlInfo.data.buildUrlIsVersioned) {
|
|
717
|
+
serviceWorkerUrls[urlInfo.data.buildRelativeUrl] = {
|
|
718
|
+
versioned: true,
|
|
719
|
+
}
|
|
720
|
+
return
|
|
721
|
+
}
|
|
722
|
+
if (!urlInfo.data.version) {
|
|
723
|
+
// when url is not versioned we compute a "version" for that url anyway
|
|
724
|
+
// so that service worker source still changes and navigator
|
|
725
|
+
// detect there is a change
|
|
726
|
+
const versionGenerator = createVersionGenerator()
|
|
727
|
+
versionGenerator.augmentWithContent({
|
|
728
|
+
content: urlInfo.content,
|
|
729
|
+
contentType: urlInfo.contentType,
|
|
730
|
+
lineBreakNormalization,
|
|
731
|
+
})
|
|
732
|
+
const version = versionGenerator.generate()
|
|
733
|
+
urlInfo.data.version = version
|
|
734
|
+
}
|
|
735
|
+
serviceWorkerUrls[urlInfo.data.buildRelativeUrl] = {
|
|
736
|
+
versioned: false,
|
|
737
|
+
version: urlInfo.data.version,
|
|
738
|
+
}
|
|
739
|
+
})
|
|
740
|
+
await Promise.all(
|
|
741
|
+
GRAPH.map(finalGraph, async (urlInfo) => {
|
|
742
|
+
if (urlInfo.subtype !== "service_worker") {
|
|
743
|
+
return
|
|
744
|
+
}
|
|
745
|
+
await injectServiceWorkerUrls({
|
|
746
|
+
urlInfo,
|
|
747
|
+
kitchen: finalGraphKitchen,
|
|
748
|
+
serviceWorkerUrls,
|
|
749
|
+
})
|
|
750
|
+
}),
|
|
751
|
+
)
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
const buildManifest = {}
|
|
755
|
+
const buildFileContents = {}
|
|
756
|
+
const buildInlineFileContents = {}
|
|
757
|
+
GRAPH.forEach(finalGraph, (urlInfo) => {
|
|
758
|
+
const { buildUrlIsVersioned, buildRelativeUrl } = urlInfo.data
|
|
759
|
+
if (urlInfo.isInline) {
|
|
760
|
+
buildInlineFileContents[buildRelativeUrl] = urlInfo.content
|
|
663
761
|
} else {
|
|
664
|
-
buildFileContents[buildRelativeUrl] =
|
|
762
|
+
buildFileContents[buildRelativeUrl] = urlInfo.content
|
|
665
763
|
}
|
|
666
|
-
if (
|
|
764
|
+
if (buildUrlIsVersioned) {
|
|
667
765
|
const buildRelativeUrlWithoutVersioning = urlToRelativeUrl(
|
|
668
|
-
|
|
766
|
+
urlInfo.url,
|
|
669
767
|
buildDirectoryUrl,
|
|
670
768
|
)
|
|
671
769
|
buildManifest[buildRelativeUrlWithoutVersioning] = buildRelativeUrl
|
|
672
770
|
}
|
|
673
771
|
})
|
|
772
|
+
|
|
674
773
|
logger.debug(
|
|
675
774
|
`graph urls post-versioning:
|
|
676
775
|
${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
@@ -689,6 +788,16 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
689
788
|
)
|
|
690
789
|
}),
|
|
691
790
|
)
|
|
791
|
+
if (
|
|
792
|
+
versioning !== "none" &&
|
|
793
|
+
assetManifest &&
|
|
794
|
+
Object.keys(buildManifest).length
|
|
795
|
+
) {
|
|
796
|
+
await writeFile(
|
|
797
|
+
new URL(assetManifestFileRelativeUrl, buildDirectoryUrl),
|
|
798
|
+
JSON.stringify(buildManifest, null, " "),
|
|
799
|
+
)
|
|
800
|
+
}
|
|
692
801
|
}
|
|
693
802
|
logger.info(createUrlGraphSummary(finalGraph, { title: "build files" }))
|
|
694
803
|
return {
|
|
@@ -698,6 +807,27 @@ ${Object.keys(finalGraph.urlInfos).join("\n")}`,
|
|
|
698
807
|
}
|
|
699
808
|
}
|
|
700
809
|
|
|
810
|
+
const GRAPH = {
|
|
811
|
+
map: (graph, callback) => {
|
|
812
|
+
return Object.keys(graph.urlInfos).map((url) => {
|
|
813
|
+
return callback(graph.urlInfos[url])
|
|
814
|
+
})
|
|
815
|
+
},
|
|
816
|
+
|
|
817
|
+
forEach: (graph, callback) => {
|
|
818
|
+
Object.keys(graph.urlInfos).forEach((url) => {
|
|
819
|
+
callback(graph.urlInfos[url], url)
|
|
820
|
+
})
|
|
821
|
+
},
|
|
822
|
+
|
|
823
|
+
find: (graph, callback) => {
|
|
824
|
+
const urlFound = Object.keys(graph.urlInfos).find((url) => {
|
|
825
|
+
return callback(graph.urlInfos[url])
|
|
826
|
+
})
|
|
827
|
+
return graph.urlInfos[urlFound]
|
|
828
|
+
},
|
|
829
|
+
}
|
|
830
|
+
|
|
701
831
|
const injectVersionIntoBuildUrl = ({ buildUrl, version, versioning }) => {
|
|
702
832
|
if (versioning === "search_param") {
|
|
703
833
|
return injectQueryParams(buildUrl, {
|
|
@@ -6,6 +6,12 @@ export const createBuilUrlsGenerator = ({ buildDirectoryUrl }) => {
|
|
|
6
6
|
const cache = {}
|
|
7
7
|
const generate = memoizeByUrl((url, urlInfo, parentUrlInfo) => {
|
|
8
8
|
const directoryPath = determineDirectoryPath(urlInfo, parentUrlInfo)
|
|
9
|
+
let names = cache[directoryPath]
|
|
10
|
+
if (!names) {
|
|
11
|
+
names = []
|
|
12
|
+
cache[directoryPath] = names
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
let name = urlToFilename(url)
|
|
10
16
|
const { searchParams } = new URL(url)
|
|
11
17
|
if (
|
|
@@ -15,12 +21,7 @@ export const createBuilUrlsGenerator = ({ buildDirectoryUrl }) => {
|
|
|
15
21
|
) {
|
|
16
22
|
name = `${name}.js`
|
|
17
23
|
}
|
|
18
|
-
|
|
19
|
-
if (!names) {
|
|
20
|
-
names = []
|
|
21
|
-
cache[directoryPath] = names
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
+
const [basename, extension] = splitFileExtension(name)
|
|
24
25
|
let nameCandidate = name
|
|
25
26
|
let integer = 1
|
|
26
27
|
// eslint-disable-next-line no-constant-condition
|
|
@@ -30,7 +31,7 @@ export const createBuilUrlsGenerator = ({ buildDirectoryUrl }) => {
|
|
|
30
31
|
break
|
|
31
32
|
}
|
|
32
33
|
integer++
|
|
33
|
-
nameCandidate = `${
|
|
34
|
+
nameCandidate = `${basename}${integer}${extension}`
|
|
34
35
|
}
|
|
35
36
|
return `${buildDirectoryUrl}${directoryPath}${nameCandidate}`
|
|
36
37
|
})
|
|
@@ -40,6 +41,14 @@ export const createBuilUrlsGenerator = ({ buildDirectoryUrl }) => {
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
const splitFileExtension = (filename) => {
|
|
45
|
+
const dotLastIndex = filename.lastIndexOf(".")
|
|
46
|
+
if (dotLastIndex === -1) {
|
|
47
|
+
return [filename, ""]
|
|
48
|
+
}
|
|
49
|
+
return [filename.slice(0, dotLastIndex), filename.slice(dotLastIndex)]
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
const determineDirectoryPath = (urlInfo, parentUrlInfo) => {
|
|
44
53
|
if (urlInfo.isInline) {
|
|
45
54
|
const parentDirectoryPath = determineDirectoryPath(parentUrlInfo)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
|
|
2
|
+
|
|
3
|
+
export const injectServiceWorkerUrls = async ({
|
|
4
|
+
urlInfo,
|
|
5
|
+
kitchen,
|
|
6
|
+
serviceWorkerUrls,
|
|
7
|
+
}) => {
|
|
8
|
+
const magicSource = createMagicSource(urlInfo.content)
|
|
9
|
+
const urlsWithoutSelf = {
|
|
10
|
+
...serviceWorkerUrls,
|
|
11
|
+
}
|
|
12
|
+
delete urlsWithoutSelf[urlInfo.data.buildRelativeUrl]
|
|
13
|
+
magicSource.prepend(generateClientCode(urlsWithoutSelf))
|
|
14
|
+
const { content, sourcemap } = magicSource.toContentAndSourcemap()
|
|
15
|
+
await kitchen.urlInfoTransformer.applyFinalTransformations(urlInfo, {
|
|
16
|
+
content,
|
|
17
|
+
sourcemap,
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const generateClientCode = (serviceWorkerUrls) => {
|
|
22
|
+
return `
|
|
23
|
+
self.serviceWorkerUrls = ${JSON.stringify(serviceWorkerUrls, null, " ")};
|
|
24
|
+
`
|
|
25
|
+
}
|
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
} from "@jsenv/utils/html_ast/html_ast.js"
|
|
9
9
|
import { createMagicSource } from "@jsenv/utils/sourcemap/magic_source.js"
|
|
10
10
|
|
|
11
|
-
export const injectVersionMappings = async (
|
|
11
|
+
export const injectVersionMappings = async ({
|
|
12
12
|
urlInfo,
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
kitchen,
|
|
14
|
+
versionMappings,
|
|
15
|
+
}) => {
|
|
15
16
|
const injector = injectors[urlInfo.type]
|
|
16
17
|
if (injector) {
|
|
17
18
|
const { content, sourcemap } = injector(urlInfo, { versionMappings })
|
|
@@ -131,15 +131,6 @@ const rollupPluginJsenv = ({
|
|
|
131
131
|
const rollupFileInfo = rollupResult[fileName]
|
|
132
132
|
// there is 3 types of file: "placeholder", "asset", "chunk"
|
|
133
133
|
if (rollupFileInfo.type === "chunk") {
|
|
134
|
-
const { facadeModuleId } = rollupFileInfo
|
|
135
|
-
let url
|
|
136
|
-
if (facadeModuleId) {
|
|
137
|
-
url = fileUrlConverter.asFileUrl(facadeModuleId)
|
|
138
|
-
} else {
|
|
139
|
-
const { sources } = rollupFileInfo.map
|
|
140
|
-
const sourcePath = sources[sources.length - 1]
|
|
141
|
-
url = fileUrlConverter.asFileUrl(sourcePath)
|
|
142
|
-
}
|
|
143
134
|
const jsModuleBundleUrlInfo = {
|
|
144
135
|
// buildRelativeUrl: rollupFileInfo.fileName,
|
|
145
136
|
data: {
|
|
@@ -149,6 +140,12 @@ const rollupPluginJsenv = ({
|
|
|
149
140
|
content: rollupFileInfo.code,
|
|
150
141
|
sourcemap: rollupFileInfo.map,
|
|
151
142
|
}
|
|
143
|
+
let url
|
|
144
|
+
if (rollupFileInfo.facadeModuleId) {
|
|
145
|
+
url = fileUrlConverter.asFileUrl(rollupFileInfo.facadeModuleId)
|
|
146
|
+
} else {
|
|
147
|
+
url = new URL(rollupFileInfo.fileName, rootDirectoryUrl).href
|
|
148
|
+
}
|
|
152
149
|
jsModuleBundleUrlInfos[url] = jsModuleBundleUrlInfo
|
|
153
150
|
}
|
|
154
151
|
})
|
|
@@ -171,13 +168,18 @@ const rollupPluginJsenv = ({
|
|
|
171
168
|
},
|
|
172
169
|
chunkFileNames: (chunkInfo) => {
|
|
173
170
|
// preserves relative path parts:
|
|
174
|
-
// the goal is to
|
|
171
|
+
// the goal is to maintain the original relative path (relative to the root directory)
|
|
175
172
|
// so that later in the build process, when resolving these urls, we are able to
|
|
176
173
|
// re-resolve the specifier againt the original parent url and find the original url
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
174
|
+
if (chunkInfo.facadeModuleId) {
|
|
175
|
+
const fileUrl = fileUrlConverter.asFileUrl(chunkInfo.facadeModuleId)
|
|
176
|
+
const relativePath = urlToRelativeUrl(fileUrl, rootDirectoryUrl)
|
|
177
|
+
return relativePath
|
|
178
|
+
}
|
|
179
|
+
// chunk generated dynamically by rollup to share code.
|
|
180
|
+
// we prefix with "__rollup__/" to avoid potential conflict of filename
|
|
181
|
+
// between this one and a file with the same name existing in the root directory
|
|
182
|
+
return `__rollup__/${chunkInfo.name}.js`
|
|
181
183
|
},
|
|
182
184
|
// https://rollupjs.org/guide/en/#outputpaths
|
|
183
185
|
// paths: (id) => {
|