@lwrjs/static 0.12.0-alpha.5 → 0.12.0-alpha.6
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.
|
@@ -60,7 +60,7 @@ var StaticModuleProvider = class {
|
|
|
60
60
|
const localeId = runtimeParams?.locale || this.i18n.defaultLocale;
|
|
61
61
|
const metadata = await (0, import_static_utils.getLocalizedBundle)(specifier, this.siteBundles, localeId, this.i18n);
|
|
62
62
|
if (metadata) {
|
|
63
|
-
import_diagnostics.logger.
|
|
63
|
+
import_diagnostics.logger.debug({
|
|
64
64
|
label: `${this.name}`,
|
|
65
65
|
message: `Module Entry request for static bundle ${specifier}`
|
|
66
66
|
});
|
|
@@ -43,8 +43,9 @@ var StaticResourceProvider = class {
|
|
|
43
43
|
}
|
|
44
44
|
async getResource(resourceIdentity, runtimeEnvironment) {
|
|
45
45
|
const {debug} = runtimeEnvironment;
|
|
46
|
-
const metadata =
|
|
47
|
-
|
|
46
|
+
const metadata = this.siteResources.resources[resourceIdentity.specifier];
|
|
47
|
+
const debugMetadata = this.debugSiteResources ? this.debugSiteResources.resources[resourceIdentity.specifier] : void 0;
|
|
48
|
+
if (!metadata && !debugMetadata) {
|
|
48
49
|
import_diagnostics.logger.warn({
|
|
49
50
|
label: `${this.name}`,
|
|
50
51
|
message: `Did not find requested specifier ${resourceIdentity.specifier}`
|
|
@@ -52,17 +53,23 @@ var StaticResourceProvider = class {
|
|
|
52
53
|
return void 0;
|
|
53
54
|
}
|
|
54
55
|
const resourcePath = import_path.default.join(this.siteRootDir, metadata.path);
|
|
56
|
+
const debugResourcePath = debugMetadata ? import_path.default.join(this.siteRootDir, debugMetadata.path) : void 0;
|
|
57
|
+
const useDebug = debug && !(0, import_shared_utils.getFeatureFlags)().SSR_STATIC_BUNDLES && debugResourcePath;
|
|
55
58
|
const type = metadata.mimeType || (0, import_shared_utils.mimeLookup)(resourcePath) || "application/javascript";
|
|
56
59
|
return {
|
|
57
60
|
type,
|
|
58
61
|
stream: () => {
|
|
59
|
-
import_diagnostics.logger.
|
|
62
|
+
import_diagnostics.logger.debug({
|
|
60
63
|
label: `${this.name}`,
|
|
61
64
|
message: `Resource read from lambda ${resourceIdentity.specifier}`
|
|
62
65
|
});
|
|
63
|
-
|
|
66
|
+
if (useDebug) {
|
|
67
|
+
return import_fs_extra.default.createReadStream(debugResourcePath);
|
|
68
|
+
} else {
|
|
69
|
+
return import_fs_extra.default.createReadStream(resourcePath);
|
|
70
|
+
}
|
|
64
71
|
},
|
|
65
|
-
src: resourcePath,
|
|
72
|
+
src: useDebug ? debugResourcePath : resourcePath,
|
|
66
73
|
inline: metadata.inline
|
|
67
74
|
};
|
|
68
75
|
}
|
|
@@ -36,7 +36,7 @@ export default class StaticModuleProvider {
|
|
|
36
36
|
const localeId = (runtimeParams?.locale || this.i18n.defaultLocale);
|
|
37
37
|
const metadata = await getLocalizedBundle(specifier, this.siteBundles, localeId, this.i18n);
|
|
38
38
|
if (metadata) {
|
|
39
|
-
logger.
|
|
39
|
+
logger.debug({
|
|
40
40
|
label: `${this.name}`,
|
|
41
41
|
message: `Module Entry request for static bundle ${specifier}`,
|
|
42
42
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { logger } from '@lwrjs/diagnostics';
|
|
2
|
-
import { mimeLookup } from '@lwrjs/shared-utils';
|
|
2
|
+
import { mimeLookup, getFeatureFlags } from '@lwrjs/shared-utils';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
5
|
export default class StaticResourceProvider {
|
|
@@ -15,10 +15,11 @@ export default class StaticResourceProvider {
|
|
|
15
15
|
}
|
|
16
16
|
async getResource(resourceIdentity, runtimeEnvironment) {
|
|
17
17
|
const { debug } = runtimeEnvironment;
|
|
18
|
-
const metadata =
|
|
18
|
+
const metadata = this.siteResources.resources[resourceIdentity.specifier];
|
|
19
|
+
const debugMetadata = this.debugSiteResources
|
|
19
20
|
? this.debugSiteResources.resources[resourceIdentity.specifier]
|
|
20
|
-
:
|
|
21
|
-
if (!metadata) {
|
|
21
|
+
: undefined;
|
|
22
|
+
if (!metadata && !debugMetadata) {
|
|
22
23
|
logger.warn({
|
|
23
24
|
label: `${this.name}`,
|
|
24
25
|
message: `Did not find requested specifier ${resourceIdentity.specifier}`,
|
|
@@ -26,19 +27,30 @@ export default class StaticResourceProvider {
|
|
|
26
27
|
return undefined;
|
|
27
28
|
}
|
|
28
29
|
const resourcePath = path.join(this.siteRootDir, metadata.path);
|
|
30
|
+
const debugResourcePath = debugMetadata ? path.join(this.siteRootDir, debugMetadata.path) : undefined;
|
|
31
|
+
const useDebug = debug && !getFeatureFlags().SSR_STATIC_BUNDLES && debugResourcePath;
|
|
29
32
|
// Figure out mime type
|
|
30
33
|
const type = metadata.mimeType || mimeLookup(resourcePath) || 'application/javascript';
|
|
31
34
|
return {
|
|
32
35
|
type,
|
|
33
36
|
// Have to make the loader shim code available for SSR
|
|
34
37
|
stream: () => {
|
|
35
|
-
logger.
|
|
38
|
+
logger.debug({
|
|
36
39
|
label: `${this.name}`,
|
|
37
40
|
message: `Resource read from lambda ${resourceIdentity.specifier}`,
|
|
38
41
|
});
|
|
39
|
-
|
|
42
|
+
if (useDebug) {
|
|
43
|
+
// use the debug resource if:
|
|
44
|
+
// - debug mode is ON
|
|
45
|
+
// - SSR_STATIC_BUNDLES is OFF
|
|
46
|
+
// - the debug version of the resource exists
|
|
47
|
+
return fs.createReadStream(debugResourcePath);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return fs.createReadStream(resourcePath);
|
|
51
|
+
}
|
|
40
52
|
},
|
|
41
|
-
src: resourcePath,
|
|
53
|
+
src: useDebug ? debugResourcePath : resourcePath,
|
|
42
54
|
inline: metadata.inline,
|
|
43
55
|
};
|
|
44
56
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.12.0-alpha.
|
|
7
|
+
"version": "0.12.0-alpha.6",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"build/**/*.d.ts"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@lwrjs/diagnostics": "0.12.0-alpha.
|
|
52
|
-
"@lwrjs/shared-utils": "0.12.0-alpha.
|
|
51
|
+
"@lwrjs/diagnostics": "0.12.0-alpha.6",
|
|
52
|
+
"@lwrjs/shared-utils": "0.12.0-alpha.6"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@lwrjs/types": "0.12.0-alpha.
|
|
55
|
+
"@lwrjs/types": "0.12.0-alpha.6",
|
|
56
56
|
"@types/express": "^4.17.21",
|
|
57
57
|
"jest": "^26.6.3",
|
|
58
58
|
"jest-express": "^1.12.0",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"volta": {
|
|
66
66
|
"extends": "../../../package.json"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "d9428f6168feea04d3de54129a5861eb4590b26c"
|
|
69
69
|
}
|