@lwrjs/static 0.15.0-alpha.37 → 0.15.0-alpha.39
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.
|
@@ -32,6 +32,7 @@ var import_path = __toModule(require("path"));
|
|
|
32
32
|
var import_fs_extra = __toModule(require("fs-extra"));
|
|
33
33
|
var import_lru_cache = __toModule(require("lru-cache"));
|
|
34
34
|
var import_site_metadata = __toModule(require("../site-metadata.cjs"));
|
|
35
|
+
var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
|
|
35
36
|
var BUNDLE_SOURCE_NOT_FOUND = "Bundle Source Path Not Found";
|
|
36
37
|
var StaticBundleProvider = class {
|
|
37
38
|
constructor(config, context) {
|
|
@@ -71,7 +72,13 @@ var StaticBundleProvider = class {
|
|
|
71
72
|
}
|
|
72
73
|
const bundlePath = import_path.default.join(this.siteRootDir, metadata.path);
|
|
73
74
|
const resolvedBundlePath = this.getCodePath(bundlePath, debug, specifier, version, localeId, ssr);
|
|
74
|
-
const codePromiser = this.getCodePromiser(resolvedBundlePath,
|
|
75
|
+
const codePromiser = this.getCodePromiser(resolvedBundlePath, {
|
|
76
|
+
specifier,
|
|
77
|
+
version,
|
|
78
|
+
locale: localeId,
|
|
79
|
+
ssr,
|
|
80
|
+
debug
|
|
81
|
+
});
|
|
75
82
|
const imports = metadata.imports.map((importSpecifier) => this.getModuleReference(importSpecifier, localeId, debug, false));
|
|
76
83
|
const dynamicImports = metadata.dynamicImports?.map((importSpecifier) => this.getModuleReference(importSpecifier, localeId, debug, false));
|
|
77
84
|
const id = (0, import_shared_utils.getSpecifier)(moduleId);
|
|
@@ -125,7 +132,13 @@ var StaticBundleProvider = class {
|
|
|
125
132
|
}
|
|
126
133
|
return includedModule;
|
|
127
134
|
}
|
|
128
|
-
getCodePromiser(bundleSourcePath,
|
|
135
|
+
getCodePromiser(bundleSourcePath, {
|
|
136
|
+
specifier,
|
|
137
|
+
version,
|
|
138
|
+
locale,
|
|
139
|
+
ssr,
|
|
140
|
+
debug
|
|
141
|
+
}) {
|
|
129
142
|
const cache = this.codeCache;
|
|
130
143
|
return async () => {
|
|
131
144
|
let code = cache?.get(bundleSourcePath);
|
|
@@ -134,10 +147,22 @@ var StaticBundleProvider = class {
|
|
|
134
147
|
if (bundleSourcePath === BUNDLE_SOURCE_NOT_FOUND) {
|
|
135
148
|
throw new Error(BUNDLE_SOURCE_NOT_FOUND);
|
|
136
149
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
await (0, import_instrumentation.getTracer)().trace({
|
|
151
|
+
name: import_instrumentation.BundleSpan.ReadBundle,
|
|
152
|
+
attributes: {
|
|
153
|
+
specifier,
|
|
154
|
+
version: version ?? "",
|
|
155
|
+
locale,
|
|
156
|
+
ssr: ssr ? "TRUE" : "FALSE",
|
|
157
|
+
debug: debug ? "TRUE" : "FALSE",
|
|
158
|
+
bundleSourcePath
|
|
159
|
+
}
|
|
160
|
+
}, async () => {
|
|
161
|
+
code = await import_fs_extra.default.readFile(import_path.default.join(bundleSourcePath), "utf-8");
|
|
162
|
+
if (cache) {
|
|
163
|
+
cache.set(bundleSourcePath, code);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
141
166
|
} catch (err) {
|
|
142
167
|
import_diagnostics.logger.warn({
|
|
143
168
|
label: "static-bundle-provider",
|
|
@@ -22,7 +22,13 @@ export default class StaticBundleProvider implements BundleProvider {
|
|
|
22
22
|
* Takes a key from the site bundle metadata and creates an appropriate runtime BaseModuleReference to use in the LWR runtime.
|
|
23
23
|
*/
|
|
24
24
|
private getModuleReference;
|
|
25
|
-
getCodePromiser(bundleSourcePath: string, specifier
|
|
25
|
+
getCodePromiser(bundleSourcePath: string, { specifier, version, locale, ssr, debug, }: {
|
|
26
|
+
specifier: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
locale: string;
|
|
29
|
+
ssr: boolean;
|
|
30
|
+
debug: boolean;
|
|
31
|
+
}): () => Promise<string>;
|
|
26
32
|
/**
|
|
27
33
|
* Get the local source code path for the a static bundle
|
|
28
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
|
|
@@ -4,6 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
5
|
import { LRUCache } from 'lru-cache';
|
|
6
6
|
import { getSiteBundleId, parseSiteId, resolveStaticBundleVersion } from '../site-metadata.js';
|
|
7
|
+
import { getTracer, BundleSpan } from '@lwrjs/instrumentation';
|
|
7
8
|
const BUNDLE_SOURCE_NOT_FOUND = 'Bundle Source Path Not Found';
|
|
8
9
|
export default class StaticBundleProvider {
|
|
9
10
|
constructor(config, context) {
|
|
@@ -43,7 +44,13 @@ export default class StaticBundleProvider {
|
|
|
43
44
|
const bundlePath = path.join(this.siteRootDir, metadata.path);
|
|
44
45
|
// Get the associated bundle source code
|
|
45
46
|
const resolvedBundlePath = this.getCodePath(bundlePath, debug, specifier, version, localeId, ssr);
|
|
46
|
-
const codePromiser = this.getCodePromiser(resolvedBundlePath,
|
|
47
|
+
const codePromiser = this.getCodePromiser(resolvedBundlePath, {
|
|
48
|
+
specifier,
|
|
49
|
+
version,
|
|
50
|
+
locale: localeId,
|
|
51
|
+
ssr,
|
|
52
|
+
debug,
|
|
53
|
+
});
|
|
47
54
|
const imports = metadata.imports.map((importSpecifier) => this.getModuleReference(importSpecifier, localeId, debug, false));
|
|
48
55
|
const dynamicImports = metadata.dynamicImports?.map((importSpecifier) => this.getModuleReference(importSpecifier, localeId, debug, false));
|
|
49
56
|
const id = getSpecifier(moduleId);
|
|
@@ -100,7 +107,7 @@ export default class StaticBundleProvider {
|
|
|
100
107
|
}
|
|
101
108
|
return includedModule;
|
|
102
109
|
}
|
|
103
|
-
getCodePromiser(bundleSourcePath, specifier) {
|
|
110
|
+
getCodePromiser(bundleSourcePath, { specifier, version, locale, ssr, debug, }) {
|
|
104
111
|
const cache = this.codeCache;
|
|
105
112
|
return async () => {
|
|
106
113
|
let code = cache?.get(bundleSourcePath);
|
|
@@ -110,10 +117,22 @@ export default class StaticBundleProvider {
|
|
|
110
117
|
if (bundleSourcePath === BUNDLE_SOURCE_NOT_FOUND) {
|
|
111
118
|
throw new Error(BUNDLE_SOURCE_NOT_FOUND);
|
|
112
119
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
120
|
+
await getTracer().trace({
|
|
121
|
+
name: BundleSpan.ReadBundle,
|
|
122
|
+
attributes: {
|
|
123
|
+
specifier,
|
|
124
|
+
version: version ?? '',
|
|
125
|
+
locale,
|
|
126
|
+
ssr: ssr ? 'TRUE' : 'FALSE',
|
|
127
|
+
debug: debug ? 'TRUE' : 'FALSE',
|
|
128
|
+
bundleSourcePath,
|
|
129
|
+
},
|
|
130
|
+
}, async () => {
|
|
131
|
+
code = await fs.readFile(path.join(bundleSourcePath), 'utf-8');
|
|
132
|
+
if (cache) {
|
|
133
|
+
cache.set(bundleSourcePath, code);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
117
136
|
}
|
|
118
137
|
catch (err) {
|
|
119
138
|
// Ran it an un-expected error reading the bundle source code
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.15.0-alpha.
|
|
7
|
+
"version": "0.15.0-alpha.39",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -52,12 +52,13 @@
|
|
|
52
52
|
"build/**/*.d.ts"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@lwrjs/diagnostics": "0.15.0-alpha.
|
|
56
|
-
"@lwrjs/
|
|
55
|
+
"@lwrjs/diagnostics": "0.15.0-alpha.39",
|
|
56
|
+
"@lwrjs/instrumentation": "0.15.0-alpha.39",
|
|
57
|
+
"@lwrjs/shared-utils": "0.15.0-alpha.39",
|
|
57
58
|
"lru-cache": "^10.4.3"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@lwrjs/types": "0.15.0-alpha.
|
|
61
|
+
"@lwrjs/types": "0.15.0-alpha.39",
|
|
61
62
|
"@types/express": "^4.17.21",
|
|
62
63
|
"jest": "^26.6.3",
|
|
63
64
|
"jest-express": "^1.12.0",
|
|
@@ -71,5 +72,5 @@
|
|
|
71
72
|
"volta": {
|
|
72
73
|
"extends": "../../../package.json"
|
|
73
74
|
},
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "27d047854320831ffa9aa6137e2f40691c896448"
|
|
75
76
|
}
|