@lwrjs/static 0.17.3 → 0.17.5
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.
|
@@ -62,16 +62,14 @@ var StaticBundleProvider = class {
|
|
|
62
62
|
async bundle(moduleId, runtimeEnvironment, runtimeParams) {
|
|
63
63
|
const {specifier, version} = moduleId;
|
|
64
64
|
const {
|
|
65
|
+
debug,
|
|
65
66
|
i18n: {defaultLocale}
|
|
66
67
|
} = runtimeEnvironment;
|
|
67
68
|
const localeId = runtimeParams?.locale || defaultLocale;
|
|
68
69
|
const ssr = runtimeParams?.ssr;
|
|
69
|
-
let debug = runtimeEnvironment.debug;
|
|
70
70
|
let metadata = this.getBundleMetadata({moduleId, localeId, debug, ssr});
|
|
71
71
|
if (!metadata && debug) {
|
|
72
72
|
metadata = this.getBundleMetadata({moduleId, localeId, debug: false, ssr});
|
|
73
|
-
if (metadata)
|
|
74
|
-
debug = false;
|
|
75
73
|
}
|
|
76
74
|
if (!metadata && (0, import_shared_utils.isExternalSpecifier)(moduleId.specifier, this.bundleConfig)) {
|
|
77
75
|
const {specifier: unversionedSepcifier} = (0, import_shared_utils.explodeSpecifier)(moduleId.specifier);
|
|
@@ -88,7 +86,8 @@ var StaticBundleProvider = class {
|
|
|
88
86
|
return void 0;
|
|
89
87
|
}
|
|
90
88
|
const bundlePath = import_path.default.join(this.siteRootDir, metadata.path);
|
|
91
|
-
const
|
|
89
|
+
const resolvedBundlePath = this.getCodePath(bundlePath, debug, specifier, version, localeId, ssr);
|
|
90
|
+
const codePromiser = this.getCodePromiser(resolvedBundlePath, {
|
|
92
91
|
specifier,
|
|
93
92
|
version,
|
|
94
93
|
locale: localeId,
|
|
@@ -222,5 +221,26 @@ var StaticBundleProvider = class {
|
|
|
222
221
|
label: "static-bundle-provider"
|
|
223
222
|
});
|
|
224
223
|
}
|
|
224
|
+
getCodePath(bundlePath, debug, specifier, version, localeId, ssr) {
|
|
225
|
+
const isLambda = (0, import_shared_utils.isLambdaEnv)() || process.env.FORCE_DEBUG_FALLBACK === "true";
|
|
226
|
+
let bundleSourcePath = bundlePath;
|
|
227
|
+
if (debug && isLambda) {
|
|
228
|
+
const metadata = this.getBundleMetadata({
|
|
229
|
+
moduleId: {specifier, version},
|
|
230
|
+
localeId,
|
|
231
|
+
debug: false,
|
|
232
|
+
ssr
|
|
233
|
+
});
|
|
234
|
+
if (!metadata) {
|
|
235
|
+
import_diagnostics.logger.error({
|
|
236
|
+
label: "static-bundle-provider",
|
|
237
|
+
message: `debug-to-prod fallback missing metadata for specifier: ${specifier}`
|
|
238
|
+
});
|
|
239
|
+
return BUNDLE_SOURCE_NOT_FOUND;
|
|
240
|
+
}
|
|
241
|
+
bundleSourcePath = import_path.default.join(this.siteRootDir, metadata.path);
|
|
242
|
+
}
|
|
243
|
+
return bundleSourcePath;
|
|
244
|
+
}
|
|
225
245
|
};
|
|
226
246
|
var static_bundle_provider_default = StaticBundleProvider;
|
|
@@ -43,5 +43,17 @@ export default class StaticBundleProvider implements BundleProvider {
|
|
|
43
43
|
* @param {boolean} ssr - Indicates whether the bundle is for server-side rendering (SSR).
|
|
44
44
|
*/
|
|
45
45
|
logBundleError(moduleId: Partial<AbstractModuleId>, localeId: string, debug: boolean, ssr: boolean): void;
|
|
46
|
+
/**
|
|
47
|
+
* Get the local source code path for the a static bundle
|
|
48
|
+
* If we are running in a lambda and the mode is debug we will return the prod source code instead of the debug source code
|
|
49
|
+
*
|
|
50
|
+
* @param bundlePath The default path for the bundle for prod read from .metadata/bundle-metadata.json, for debug .metadata/bundle-metadata-debug.json
|
|
51
|
+
* @param debug Is the request in debug mode?
|
|
52
|
+
* @param specifier Root specifier for the requested bundle
|
|
53
|
+
* @param version Root specifier version
|
|
54
|
+
* @param localeId Locale id (e.g. en-US) for the current request
|
|
55
|
+
* @param ssr True if this is a server bundle
|
|
56
|
+
*/
|
|
57
|
+
getCodePath(bundlePath: string, debug: boolean, specifier: string, version: string | undefined, localeId: string, ssr: boolean): string;
|
|
46
58
|
}
|
|
47
59
|
//# sourceMappingURL=static-bundle-provider.d.ts.map
|
|
@@ -41,18 +41,15 @@ export default class StaticBundleProvider {
|
|
|
41
41
|
}
|
|
42
42
|
async bundle(moduleId, runtimeEnvironment, runtimeParams) {
|
|
43
43
|
const { specifier, version } = moduleId;
|
|
44
|
-
const { i18n: { defaultLocale }, } = runtimeEnvironment;
|
|
44
|
+
const { debug, i18n: { defaultLocale }, } = runtimeEnvironment;
|
|
45
45
|
const localeId = (runtimeParams?.locale || defaultLocale);
|
|
46
46
|
const ssr = runtimeParams?.ssr;
|
|
47
|
-
let debug = runtimeEnvironment.debug;
|
|
48
47
|
let metadata = this.getBundleMetadata({ moduleId, localeId, debug, ssr });
|
|
49
48
|
if (!metadata && debug) {
|
|
50
49
|
// Fallback to use prod bundles if the debug variant does not exist
|
|
51
50
|
// eg: debug bundles are not shipped to the Lambda
|
|
52
51
|
// eg: locally, an MRT bundle may or may not have debug metadata, depending on how it's generated
|
|
53
52
|
metadata = this.getBundleMetadata({ moduleId, localeId, debug: false, ssr });
|
|
54
|
-
if (metadata)
|
|
55
|
-
debug = false;
|
|
56
53
|
}
|
|
57
54
|
if (!metadata && isExternalSpecifier(moduleId.specifier, this.bundleConfig)) {
|
|
58
55
|
const { specifier: unversionedSepcifier } = explodeSpecifier(moduleId.specifier);
|
|
@@ -71,7 +68,8 @@ export default class StaticBundleProvider {
|
|
|
71
68
|
// Default bundle source path
|
|
72
69
|
const bundlePath = path.join(this.siteRootDir, metadata.path);
|
|
73
70
|
// Get the associated bundle source code
|
|
74
|
-
const
|
|
71
|
+
const resolvedBundlePath = this.getCodePath(bundlePath, debug, specifier, version, localeId, ssr);
|
|
72
|
+
const codePromiser = this.getCodePromiser(resolvedBundlePath, {
|
|
75
73
|
specifier,
|
|
76
74
|
version,
|
|
77
75
|
locale: localeId,
|
|
@@ -223,5 +221,43 @@ export default class StaticBundleProvider {
|
|
|
223
221
|
label: 'static-bundle-provider',
|
|
224
222
|
});
|
|
225
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Get the local source code path for the a static bundle
|
|
226
|
+
* If we are running in a lambda and the mode is debug we will return the prod source code instead of the debug source code
|
|
227
|
+
*
|
|
228
|
+
* @param bundlePath The default path for the bundle for prod read from .metadata/bundle-metadata.json, for debug .metadata/bundle-metadata-debug.json
|
|
229
|
+
* @param debug Is the request in debug mode?
|
|
230
|
+
* @param specifier Root specifier for the requested bundle
|
|
231
|
+
* @param version Root specifier version
|
|
232
|
+
* @param localeId Locale id (e.g. en-US) for the current request
|
|
233
|
+
* @param ssr True if this is a server bundle
|
|
234
|
+
*/
|
|
235
|
+
getCodePath(bundlePath, debug, specifier, version, localeId, ssr) {
|
|
236
|
+
// Flag is used to indicate that we are running on a lambda
|
|
237
|
+
const isLambda = isLambdaEnv() || process.env.FORCE_DEBUG_FALLBACK === 'true'; // Env variable for testing purposes only
|
|
238
|
+
// Default source code path determined from metadata based on debug mode
|
|
239
|
+
let bundleSourcePath = bundlePath;
|
|
240
|
+
// This is the special case where the request is in debug mode and we are on the lambda
|
|
241
|
+
// So we will look up the prod source code instead of the debug source code
|
|
242
|
+
if (debug && isLambda) {
|
|
243
|
+
const metadata = this.getBundleMetadata({
|
|
244
|
+
moduleId: { specifier, version },
|
|
245
|
+
localeId,
|
|
246
|
+
debug: false,
|
|
247
|
+
ssr,
|
|
248
|
+
});
|
|
249
|
+
if (!metadata) {
|
|
250
|
+
// We did not find the bundle prod bundle even though we did find it in the debug metadata before
|
|
251
|
+
logger.error({
|
|
252
|
+
label: 'static-bundle-provider',
|
|
253
|
+
message: `debug-to-prod fallback missing metadata for specifier: ${specifier}`,
|
|
254
|
+
});
|
|
255
|
+
return BUNDLE_SOURCE_NOT_FOUND;
|
|
256
|
+
}
|
|
257
|
+
// Overwrite the default source code path the prod source code path
|
|
258
|
+
bundleSourcePath = path.join(this.siteRootDir, metadata.path);
|
|
259
|
+
}
|
|
260
|
+
return bundleSourcePath;
|
|
261
|
+
}
|
|
226
262
|
}
|
|
227
263
|
//# sourceMappingURL=static-bundle-provider.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.17.
|
|
7
|
+
"version": "0.17.5",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"build/**/*.d.ts"
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@lwrjs/diagnostics": "0.17.
|
|
60
|
-
"@lwrjs/instrumentation": "0.17.
|
|
61
|
-
"@lwrjs/shared-utils": "0.17.
|
|
59
|
+
"@lwrjs/diagnostics": "0.17.5",
|
|
60
|
+
"@lwrjs/instrumentation": "0.17.5",
|
|
61
|
+
"@lwrjs/shared-utils": "0.17.5",
|
|
62
62
|
"lru-cache": "^10.4.3"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@lwrjs/types": "0.17.
|
|
65
|
+
"@lwrjs/types": "0.17.5",
|
|
66
66
|
"@types/express": "^4.17.21",
|
|
67
67
|
"jest": "29.7.0",
|
|
68
68
|
"jest-express": "^1.12.0",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"volta": {
|
|
77
77
|
"extends": "../../../package.json"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "dfca84ca42ce0825cccb796007ce0c77ef7c23f4"
|
|
80
80
|
}
|