@lwrjs/lwc-ssr 0.13.2 → 0.13.4

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.
@@ -53,7 +53,8 @@ async function createAMDModuleLoader(config, resourceRegistry, bundleRegistry, r
53
53
  fn(context, ...Object.values(context));
54
54
  } else {
55
55
  ((context) => {
56
- eval(`${Object.keys(context).reduce((c, k) => c + `const ${k} = context['${k}'];`, "globalThis=context;")} ${source}`);
56
+ const evalSource = `${Object.keys(context).reduce((c, k) => c + `const ${k} = context['${k}'];`, "const globalThis=context;")} ${source}`;
57
+ eval(evalSource);
57
58
  })(context);
58
59
  }
59
60
  };
@@ -79,7 +80,7 @@ async function createAMDModuleLoader(config, resourceRegistry, bundleRegistry, r
79
80
  const moduleId = (0, import_shared_utils.explodeSpecifier)(bundle);
80
81
  const def = await bundleRegistry.getModuleBundle(moduleId, runtimeEnvironment, runtimeParams);
81
82
  if (typeof def.src === "string" && !def.code.includes("//# sourceURL=")) {
82
- const srcUrl = (0, import_shared_utils.isLocalDev)() ? (0, import_shared_utils.getLocalDevOverrideUrl)(config.cacheDir, moduleId.specifier, def.src) : def.src;
83
+ const srcUrl = def.srcOverride ?? def.src;
83
84
  def.code += `
84
85
  //# sourceURL=${import_path.default.resolve(srcUrl)}`;
85
86
  }
@@ -187,7 +187,7 @@ var Renderer = class {
187
187
  getCachedBootstrapContext(route, runtimeEnvironment, runtimeParams, serverData, reevaluateModules) {
188
188
  let loader, bootstrapServiceEvaluationMap;
189
189
  if (reevaluateModules) {
190
- if (!this.cachedBootstrapContext) {
190
+ if (!this.cachedBootstrapContext || (0, import_shared_utils.isLocalDev)()) {
191
191
  this.cachedBootstrapContext = {
192
192
  loader: (0, import_moduleLoader.createModuleLoader)(this.config, this.resourceRegistry, this.bundleRegistry, runtimeEnvironment, runtimeParams, serverData, route.bootstrap),
193
193
  bootstrapServiceEvaluationMap: new Map()
@@ -1,7 +1,7 @@
1
1
  import path from 'path';
2
2
  import crypto from 'crypto';
3
3
  import { getTracer } from '@lwrjs/instrumentation';
4
- import { explodeSpecifier, getLocalDevOverrideUrl, getSpecifier, isLocalDev } from '@lwrjs/shared-utils';
4
+ import { explodeSpecifier, getSpecifier } from '@lwrjs/shared-utils';
5
5
  import { FetchController, createFetchEndowment, getLoaderConfig, getLoaderId, getLoaderShim, } from './utils.js';
6
6
  export const FETCH_ABORT_KEY = '__fetchAbortId__';
7
7
  const BOOTSTRAP_SPECIFIER = '@lwrjs/ssr-bootstrap';
@@ -23,13 +23,15 @@ async function createAMDModuleLoader(config, resourceRegistry, bundleRegistry, r
23
23
  const useEval = process.env.SSR_DEBUG === 'true';
24
24
  const init = (source) => {
25
25
  if (!useEval) {
26
+ // Runtime Default: use new Function() for source evaluation due its to performance benefits / code isolation
26
27
  const fn = new Function('globalThis', ...Object.keys(context), source);
27
28
  fn(context, ...Object.values(context));
28
29
  }
29
30
  else {
30
- // use eval to ensure source map line numbers are correct for debugging
31
+ // Debugging: use eval() when debugging SSR to ensure source map line numbers are correct
31
32
  ((context) => {
32
- eval(`${Object.keys(context).reduce((c, k) => c + `const ${k} = context['${k}'];`, 'globalThis=context;')} ${source}`);
33
+ const evalSource = `${Object.keys(context).reduce((c, k) => c + `const ${k} = context['${k}'];`, 'const globalThis=context;')} ${source}`;
34
+ eval(evalSource);
33
35
  })(context);
34
36
  }
35
37
  };
@@ -61,9 +63,7 @@ async function createAMDModuleLoader(config, resourceRegistry, bundleRegistry, r
61
63
  const def = await bundleRegistry.getModuleBundle(moduleId, runtimeEnvironment, runtimeParams);
62
64
  if (typeof def.src === 'string' && !def.code.includes('//# sourceURL=')) {
63
65
  // @view bundles are stored in a special location during local-dev
64
- const srcUrl = isLocalDev()
65
- ? getLocalDevOverrideUrl(config.cacheDir, moduleId.specifier, def.src)
66
- : def.src;
66
+ const srcUrl = def.srcOverride ?? def.src;
67
67
  def.code += `\n//# sourceURL=${path.resolve(srcUrl)}`;
68
68
  }
69
69
  const staticImports = def.bundleRecord.imports?.map((dep) => getSpecifier(dep)) ?? [];
@@ -1,7 +1,7 @@
1
1
  // TODO: investigate perf impact W-16056356
2
2
  import { LRUCache } from 'lru-cache';
3
3
  import { LwrUnresolvableError, createSingleDiagnosticError, descriptions, logger, stringifyError, } from '@lwrjs/diagnostics';
4
- import { buildEnvironmentContext, getCacheKeyFromJson, getSpecifier, isLambdaEnv, moduleSpecifierToKebabCase, getFeatureFlags, TaskPool, } from '@lwrjs/shared-utils';
4
+ import { buildEnvironmentContext, getCacheKeyFromJson, getSpecifier, isLambdaEnv, moduleSpecifierToKebabCase, getFeatureFlags, TaskPool, isLocalDev, } from '@lwrjs/shared-utils';
5
5
  import { ViewSpan, getTracer } from '@lwrjs/instrumentation';
6
6
  import { getServerBootstrapServices, getRenderTimeout } from './utils.js';
7
7
  import { createModuleLoader } from './moduleLoader.js';
@@ -228,7 +228,7 @@ export class Renderer {
228
228
  let loader, bootstrapServiceEvaluationMap;
229
229
  // when `REEEVALUTE_MODULES` is true, we only have a single context/loader, regardless of the env
230
230
  if (reevaluateModules) {
231
- if (!this.cachedBootstrapContext) {
231
+ if (!this.cachedBootstrapContext || isLocalDev()) {
232
232
  this.cachedBootstrapContext = {
233
233
  loader: createModuleLoader(this.config, this.resourceRegistry, this.bundleRegistry, runtimeEnvironment, runtimeParams, serverData, route.bootstrap),
234
234
  bootstrapServiceEvaluationMap: new Map(),
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.13.2",
7
+ "version": "0.13.4",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -42,18 +42,18 @@
42
42
  "build/**/*.d.ts"
43
43
  ],
44
44
  "dependencies": {
45
- "@lwrjs/config": "0.13.2",
46
- "@lwrjs/diagnostics": "0.13.2",
47
- "@lwrjs/instrumentation": "0.13.2",
48
- "@lwrjs/loader": "0.13.2",
49
- "@lwrjs/shared-utils": "0.13.2",
45
+ "@lwrjs/config": "0.13.4",
46
+ "@lwrjs/diagnostics": "0.13.4",
47
+ "@lwrjs/instrumentation": "0.13.4",
48
+ "@lwrjs/loader": "0.13.4",
49
+ "@lwrjs/shared-utils": "0.13.4",
50
50
  "fs-extra": "^11.2.0",
51
51
  "lru-cache": "^10.4.3"
52
52
  },
53
53
  "devDependencies": {
54
- "@lwrjs/types": "0.13.2",
54
+ "@lwrjs/types": "0.13.4",
55
55
  "jest": "^26.6.3",
56
- "mock-fs": "^5.2.0",
56
+ "memfs": "^4.9.3",
57
57
  "ts-jest": "^26.5.6"
58
58
  },
59
59
  "engines": {
@@ -62,5 +62,5 @@
62
62
  "volta": {
63
63
  "extends": "../../../package.json"
64
64
  },
65
- "gitHead": "607ec6610069ef1214b4c20f146ab97225554405"
65
+ "gitHead": "398664835cd2c6c6714e88c6f196e9963f7b6595"
66
66
  }