@lwrjs/static 0.17.2-alpha.26 → 0.17.2-alpha.27
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,37 +62,23 @@ var StaticBundleProvider = class {
|
|
|
62
62
|
async bundle(moduleId, runtimeEnvironment, runtimeParams) {
|
|
63
63
|
const {specifier, name, namespace, version} = moduleId;
|
|
64
64
|
const {
|
|
65
|
-
debug,
|
|
66
65
|
i18n: {defaultLocale}
|
|
67
66
|
} = runtimeEnvironment;
|
|
68
67
|
const localeId = runtimeParams?.locale || defaultLocale;
|
|
69
68
|
const ssr = runtimeParams?.ssr;
|
|
70
|
-
|
|
69
|
+
let debug = runtimeEnvironment.debug;
|
|
70
|
+
let metadata = this.getBundleMetadata({moduleId, localeId, debug, ssr});
|
|
71
|
+
if (!metadata && debug) {
|
|
72
|
+
metadata = this.getBundleMetadata({moduleId, localeId, debug: false, ssr});
|
|
73
|
+
if (metadata)
|
|
74
|
+
debug = false;
|
|
75
|
+
}
|
|
71
76
|
if (!metadata) {
|
|
72
|
-
|
|
73
|
-
import_diagnostics.logger.error(new Error("@lwc/ssr-runtime at..."));
|
|
74
|
-
import_diagnostics.logger.error({msg: "@lwc/ssr-runtime input", moduleId, localeId, debug, ssr});
|
|
75
|
-
try {
|
|
76
|
-
const siteBundleId = (0, import_site_metadata.getSiteBundleId)(moduleId, localeId, ssr, this.i18n);
|
|
77
|
-
const siteBundles = this.siteMetadata.getSiteBundles()?.bundles || {};
|
|
78
|
-
const keys = Object.keys(siteBundles);
|
|
79
|
-
const totalBundlesCount = keys?.length;
|
|
80
|
-
const runtimeBundles = keys.filter((key) => key.startsWith("@lwc/ssr-runtime"));
|
|
81
|
-
import_diagnostics.logger.error({
|
|
82
|
-
msg: "@lwc/ssr-runtime metadata",
|
|
83
|
-
siteBundleId,
|
|
84
|
-
runtimeBundles,
|
|
85
|
-
totalBundlesCount
|
|
86
|
-
});
|
|
87
|
-
} catch (error) {
|
|
88
|
-
import_diagnostics.logger.error("Error retrieving siteBundles", {error});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
77
|
+
this.logBundleError(moduleId, localeId, debug, ssr);
|
|
91
78
|
return void 0;
|
|
92
79
|
}
|
|
93
80
|
const bundlePath = import_path.default.join(this.siteRootDir, metadata.path);
|
|
94
|
-
const
|
|
95
|
-
const codePromiser = this.getCodePromiser(resolvedBundlePath, {
|
|
81
|
+
const codePromiser = this.getCodePromiser(bundlePath, {
|
|
96
82
|
specifier,
|
|
97
83
|
version,
|
|
98
84
|
locale: localeId,
|
|
@@ -198,26 +184,29 @@ var StaticBundleProvider = class {
|
|
|
198
184
|
return code;
|
|
199
185
|
};
|
|
200
186
|
}
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
187
|
+
logBundleError(moduleId, localeId, debug, ssr) {
|
|
188
|
+
const moduleSpecifier = moduleId.namespace ? `${moduleId.namespace}/${moduleId.name}` : moduleId.name;
|
|
189
|
+
const siteBundleId = (0, import_site_metadata.getSiteBundleId)(moduleId, localeId, ssr, this.i18n);
|
|
190
|
+
const siteBundles = this.siteMetadata.getSiteBundles()?.bundles || {};
|
|
191
|
+
const siteDebugBundles = this.siteMetadata.getDebugSiteBundles()?.bundles || {};
|
|
192
|
+
const runtimeBundles = Object.keys(siteBundles).filter((key) => key.startsWith(moduleSpecifier));
|
|
193
|
+
const debugBundles = Object.keys(siteDebugBundles).filter((key) => key.startsWith(moduleSpecifier));
|
|
194
|
+
import_diagnostics.logger.warn({
|
|
195
|
+
message: `Static bundle`,
|
|
196
|
+
additionalInfo: {
|
|
197
|
+
moduleId,
|
|
207
198
|
localeId,
|
|
208
|
-
debug
|
|
209
|
-
ssr
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
return bundleSourcePath;
|
|
199
|
+
debug,
|
|
200
|
+
ssr,
|
|
201
|
+
moduleSpecifier,
|
|
202
|
+
siteBundleId,
|
|
203
|
+
debugBundles,
|
|
204
|
+
runtimeBundles,
|
|
205
|
+
totalBundlesCount: Object.keys(siteBundles).length,
|
|
206
|
+
totalDebugBundlesCount: Object.keys(siteDebugBundles).length
|
|
207
|
+
},
|
|
208
|
+
label: "static-bundle-provider"
|
|
209
|
+
});
|
|
221
210
|
}
|
|
222
211
|
};
|
|
223
212
|
var static_bundle_provider_default = StaticBundleProvider;
|
|
@@ -30,16 +30,17 @@ export default class StaticBundleProvider implements BundleProvider {
|
|
|
30
30
|
debug: boolean;
|
|
31
31
|
}): () => Promise<string>;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
* 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
|
|
33
|
+
* Logs an error when a bundle fails to load and provides debugging metadata.
|
|
35
34
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
35
|
+
* This function logs details about the failed bundle load attempt, including the module ID,
|
|
36
|
+
* locale, debug mode, and SSR status. It also attempts to retrieve additional metadata
|
|
37
|
+
* about the site bundles and debug bundles associated with the module.
|
|
38
|
+
*
|
|
39
|
+
* @param {Partial<AbstractModuleId>} moduleId - The module identifier, which may include a namespace and name.
|
|
40
|
+
* @param {string} localeId - The locale associated with the bundle.
|
|
41
|
+
* @param {boolean} debug - Indicates whether debug mode is enabled.
|
|
42
|
+
* @param {boolean} ssr - Indicates whether the bundle is for server-side rendering (SSR).
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
|
+
logBundleError(moduleId: Partial<AbstractModuleId>, localeId: string, debug: boolean, ssr: boolean): void;
|
|
44
45
|
}
|
|
45
46
|
//# sourceMappingURL=static-bundle-provider.d.ts.map
|
|
@@ -35,39 +35,27 @@ export default class StaticBundleProvider {
|
|
|
35
35
|
}
|
|
36
36
|
async bundle(moduleId, runtimeEnvironment, runtimeParams) {
|
|
37
37
|
const { specifier, name, namespace, version } = moduleId;
|
|
38
|
-
const {
|
|
38
|
+
const { i18n: { defaultLocale }, } = runtimeEnvironment;
|
|
39
39
|
const localeId = (runtimeParams?.locale || defaultLocale);
|
|
40
40
|
const ssr = runtimeParams?.ssr;
|
|
41
|
-
|
|
41
|
+
let debug = runtimeEnvironment.debug;
|
|
42
|
+
let metadata = this.getBundleMetadata({ moduleId, localeId, debug, ssr });
|
|
43
|
+
if (!metadata && debug) {
|
|
44
|
+
// Fallback to use prod bundles if the debug variant does not exist
|
|
45
|
+
// eg: debug bundles are not shipped to the Lambda
|
|
46
|
+
// eg: locally, an MRT bundle may or may not have debug metadata, depending on how it's generated
|
|
47
|
+
metadata = this.getBundleMetadata({ moduleId, localeId, debug: false, ssr });
|
|
48
|
+
if (metadata)
|
|
49
|
+
debug = false;
|
|
50
|
+
}
|
|
42
51
|
if (!metadata) {
|
|
43
|
-
|
|
44
|
-
if (moduleId?.namespace === '@lwc' && moduleId?.name === 'ssr-runtime') {
|
|
45
|
-
logger.error(new Error('@lwc/ssr-runtime at...'));
|
|
46
|
-
logger.error({ msg: '@lwc/ssr-runtime input', moduleId, localeId, debug, ssr });
|
|
47
|
-
try {
|
|
48
|
-
const siteBundleId = getSiteBundleId(moduleId, localeId, ssr, this.i18n);
|
|
49
|
-
const siteBundles = this.siteMetadata.getSiteBundles()?.bundles || {};
|
|
50
|
-
const keys = Object.keys(siteBundles);
|
|
51
|
-
const totalBundlesCount = keys?.length;
|
|
52
|
-
const runtimeBundles = keys.filter((key) => key.startsWith('@lwc/ssr-runtime'));
|
|
53
|
-
logger.error({
|
|
54
|
-
msg: '@lwc/ssr-runtime metadata',
|
|
55
|
-
siteBundleId,
|
|
56
|
-
runtimeBundles,
|
|
57
|
-
totalBundlesCount,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
catch (error) {
|
|
61
|
-
logger.error('Error retrieving siteBundles', { error });
|
|
62
|
-
}
|
|
63
|
-
}
|
|
52
|
+
this.logBundleError(moduleId, localeId, debug, ssr);
|
|
64
53
|
return undefined;
|
|
65
54
|
}
|
|
66
55
|
// Default bundle source path
|
|
67
56
|
const bundlePath = path.join(this.siteRootDir, metadata.path);
|
|
68
57
|
// Get the associated bundle source code
|
|
69
|
-
const
|
|
70
|
-
const codePromiser = this.getCodePromiser(resolvedBundlePath, {
|
|
58
|
+
const codePromiser = this.getCodePromiser(bundlePath, {
|
|
71
59
|
specifier,
|
|
72
60
|
version,
|
|
73
61
|
locale: localeId,
|
|
@@ -176,42 +164,44 @@ export default class StaticBundleProvider {
|
|
|
176
164
|
};
|
|
177
165
|
}
|
|
178
166
|
/**
|
|
179
|
-
*
|
|
180
|
-
*
|
|
167
|
+
* Logs an error when a bundle fails to load and provides debugging metadata.
|
|
168
|
+
*
|
|
169
|
+
* This function logs details about the failed bundle load attempt, including the module ID,
|
|
170
|
+
* locale, debug mode, and SSR status. It also attempts to retrieve additional metadata
|
|
171
|
+
* about the site bundles and debug bundles associated with the module.
|
|
181
172
|
*
|
|
182
|
-
* @param
|
|
183
|
-
* @param
|
|
184
|
-
* @param
|
|
185
|
-
* @param
|
|
186
|
-
* @param localeId Locale id (e.g. en-US) for the current request
|
|
187
|
-
* @param ssr True if this is a server bundle
|
|
173
|
+
* @param {Partial<AbstractModuleId>} moduleId - The module identifier, which may include a namespace and name.
|
|
174
|
+
* @param {string} localeId - The locale associated with the bundle.
|
|
175
|
+
* @param {boolean} debug - Indicates whether debug mode is enabled.
|
|
176
|
+
* @param {boolean} ssr - Indicates whether the bundle is for server-side rendering (SSR).
|
|
188
177
|
*/
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
//
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
178
|
+
logBundleError(moduleId, localeId, debug, ssr) {
|
|
179
|
+
const moduleSpecifier = moduleId.namespace
|
|
180
|
+
? `${moduleId.namespace}/${moduleId.name}`
|
|
181
|
+
: moduleId.name;
|
|
182
|
+
const siteBundleId = getSiteBundleId(moduleId, localeId, ssr, this.i18n);
|
|
183
|
+
// Retrieve site bundles and debug bundles
|
|
184
|
+
const siteBundles = this.siteMetadata.getSiteBundles()?.bundles || {};
|
|
185
|
+
const siteDebugBundles = this.siteMetadata.getDebugSiteBundles()?.bundles || {};
|
|
186
|
+
// Extract keys and filter bundles by module specifier
|
|
187
|
+
const runtimeBundles = Object.keys(siteBundles).filter((key) => key.startsWith(moduleSpecifier));
|
|
188
|
+
const debugBundles = Object.keys(siteDebugBundles).filter((key) => key.startsWith(moduleSpecifier));
|
|
189
|
+
logger.warn({
|
|
190
|
+
message: `Static bundle`,
|
|
191
|
+
additionalInfo: {
|
|
192
|
+
moduleId,
|
|
199
193
|
localeId,
|
|
200
|
-
debug
|
|
194
|
+
debug,
|
|
201
195
|
ssr,
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
// Overwrite the default source code path the prod source code path
|
|
212
|
-
bundleSourcePath = path.join(this.siteRootDir, metadata.path);
|
|
213
|
-
}
|
|
214
|
-
return bundleSourcePath;
|
|
196
|
+
moduleSpecifier,
|
|
197
|
+
siteBundleId,
|
|
198
|
+
debugBundles,
|
|
199
|
+
runtimeBundles,
|
|
200
|
+
totalBundlesCount: Object.keys(siteBundles).length,
|
|
201
|
+
totalDebugBundlesCount: Object.keys(siteDebugBundles).length,
|
|
202
|
+
},
|
|
203
|
+
label: 'static-bundle-provider',
|
|
204
|
+
});
|
|
215
205
|
}
|
|
216
206
|
}
|
|
217
207
|
//# 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.2-alpha.
|
|
7
|
+
"version": "0.17.2-alpha.27",
|
|
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.2-alpha.
|
|
60
|
-
"@lwrjs/instrumentation": "0.17.2-alpha.
|
|
61
|
-
"@lwrjs/shared-utils": "0.17.2-alpha.
|
|
59
|
+
"@lwrjs/diagnostics": "0.17.2-alpha.27",
|
|
60
|
+
"@lwrjs/instrumentation": "0.17.2-alpha.27",
|
|
61
|
+
"@lwrjs/shared-utils": "0.17.2-alpha.27",
|
|
62
62
|
"lru-cache": "^10.4.3"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@lwrjs/types": "0.17.2-alpha.
|
|
65
|
+
"@lwrjs/types": "0.17.2-alpha.27",
|
|
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": "b6f4a80f77b05902c4365f1c1eb657d944d01db0"
|
|
80
80
|
}
|