@lwrjs/tools 0.12.0-alpha.3 → 0.12.0-alpha.31

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.
@@ -116,7 +116,7 @@ function buildLwrServer(config, buildDir) {
116
116
  namespace: "lwr-server-build"
117
117
  }));
118
118
  build.onLoad({filter: /.*/, namespace: "lwr-server-build"}, async (args) => {
119
- const {appConfig, runtimeEnvironment, globalData} = await (0, import_config.loadConfig)(config, {
119
+ const {appConfig, runtimeEnvironment, globalData} = (0, import_config.loadConfig)(config, {
120
120
  skipDirNormalization: true,
121
121
  useStaticProviders: true
122
122
  });
@@ -42,11 +42,10 @@ function generateLwrEntry() {
42
42
  build.onLoad({filter: /.*/, namespace: "lwr-entry"}, (args) => ({
43
43
  contents: [
44
44
  `/* This module is generated */`,
45
- `import 'source-map-support/register'`,
46
45
  `import { createHandler } from '@lwrjs/lambda';`,
47
46
  `import * as build from './lwr.build.js';`,
48
- `const handler = createHandler(build);`,
49
- `export { handler as get };`
47
+ `const handler = !process.env.LOCAL ? createHandler(build) : undefined;`,
48
+ `export { handler as get, build as MRT_APP_CONFIG };`
50
49
  ].join("\n"),
51
50
  loader: "ts",
52
51
  resolveDir: import_path.default.dirname(args.path)
@@ -46,6 +46,7 @@ async function build(buildOptions, config) {
46
46
  format: "cjs",
47
47
  platform: "node",
48
48
  logLevel: "silent",
49
+ legalComments: "none",
49
50
  mainFields: ["module", "main"],
50
51
  external: [
51
52
  "node:*",
@@ -78,11 +79,12 @@ function createEnvVarHeader() {
78
79
  const currentFeatureFlags = (0, import_shared_utils.getFeatureFlags)();
79
80
  let initFeatureFlagsString = "";
80
81
  for (const [key, val] of Object.entries(currentFeatureFlags)) {
81
- if (val) {
82
- initFeatureFlagsString += `process.env.${key} = '${val.toString()}';`;
82
+ if (val && val !== "false") {
83
+ initFeatureFlagsString += `process.env.${key} ||= '${val.toString()}';`;
83
84
  }
84
85
  }
85
86
  const LWR_VERSION_ASSIGNMENT = `globalThis.LWR_VERSION='${import_config.LWR_VERSION}';`;
86
87
  const LWC_VERSION_ASSIGNMENT = `globalThis.LWC_VERSION='${import_config.LWC_VERSION}';`;
87
- return `${LWR_VERSION_ASSIGNMENT}${LWC_VERSION_ASSIGNMENT}${initFeatureFlagsString}`;
88
+ const PWA_KIT_RUNTIME_VERSION_ASSIGNMENT = `globalThis.PWA_KIT_RUNTIME_VERSION='${import_config.PWA_KIT_RUNTIME_VERSION}';`;
89
+ return `${LWR_VERSION_ASSIGNMENT}${LWC_VERSION_ASSIGNMENT}${PWA_KIT_RUNTIME_VERSION_ASSIGNMENT}${initFeatureFlagsString}`;
88
90
  }
@@ -110,7 +110,7 @@ export default function buildLwrServer(config, buildDir) {
110
110
  namespace: 'lwr-server-build',
111
111
  }));
112
112
  build.onLoad({ filter: /.*/, namespace: 'lwr-server-build' }, async (args) => {
113
- const { appConfig, runtimeEnvironment, globalData } = await loadConfig(config, {
113
+ const { appConfig, runtimeEnvironment, globalData } = loadConfig(config, {
114
114
  skipDirNormalization: true,
115
115
  useStaticProviders: true,
116
116
  });
@@ -24,11 +24,6 @@ export default function generateLwrEntry() {
24
24
  build.onLoad({ filter: /.*/, namespace: 'lwr-entry' }, (args) => ({
25
25
  contents: [
26
26
  `/* This module is generated */`,
27
- // This package is not technically necessary as node 12 includes this functionality, but in the
28
- // LWR@MRT environment, we have no control over environment variables so we have no way to configure
29
- // NODE_OPTIONS='--enable-source-maps'. So this is a necessary workaround for now with minimal downside.
30
- // See: https://nodejs.org/docs/latest-v18.x/api/cli.html#--enable-source-maps
31
- `import 'source-map-support/register'`,
32
27
  `import { createHandler } from '@lwrjs/lambda';`,
33
28
  // Importing the server build module at this point enables support for ESM bundling.
34
29
  // If the server build module was imported in `createHandler`, it would need to be exposed
@@ -37,9 +32,9 @@ export default function generateLwrEntry() {
37
32
  // The server build module MUST NOT require asynchronous initialization to support running on MRT
38
33
  // Once MRT supports ESM, top-level await could be used at this point to perform some asynchronous
39
34
  // initialization.
40
- `const handler = createHandler(build);`,
35
+ `const handler = !process.env.LOCAL ? createHandler(build) : undefined;`,
41
36
  // MRT expects the handler to be a named export: `get`
42
- `export { handler as get };`,
37
+ `export { handler as get, build as MRT_APP_CONFIG };`,
43
38
  ].join('\n'),
44
39
  loader: 'ts',
45
40
  resolveDir: path.dirname(args.path),
@@ -4,7 +4,7 @@ import esbuild from 'esbuild';
4
4
  import { performance } from 'perf_hooks';
5
5
  import { logger } from '@lwrjs/diagnostics';
6
6
  import { getFeatureFlags } from '@lwrjs/shared-utils';
7
- import { LWR_VERSION, LWC_VERSION } from '@lwrjs/config';
7
+ import { LWR_VERSION, LWC_VERSION, PWA_KIT_RUNTIME_VERSION } from '@lwrjs/config';
8
8
  import generateLwrEntry from './plugins/generate-entry-plugin.js';
9
9
  import buildLwrServer from './plugins/build-server-plugin.js';
10
10
  async function build(buildOptions, config) {
@@ -19,6 +19,7 @@ async function build(buildOptions, config) {
19
19
  format: 'cjs',
20
20
  platform: 'node',
21
21
  logLevel: 'silent',
22
+ legalComments: 'none',
22
23
  // Alow us to roll up additional require() dependencies
23
24
  mainFields: ['module', 'main'],
24
25
  external: [
@@ -69,12 +70,14 @@ function createEnvVarHeader() {
69
70
  const currentFeatureFlags = getFeatureFlags();
70
71
  let initFeatureFlagsString = '';
71
72
  for (const [key, val] of Object.entries(currentFeatureFlags)) {
72
- if (val) {
73
- initFeatureFlagsString += `process.env.${key} = '${val.toString()}';`;
73
+ if (val && val !== 'false') {
74
+ // Allow server env vars take precedence via ||=
75
+ initFeatureFlagsString += `process.env.${key} ||= '${val.toString()}';`;
74
76
  }
75
77
  }
76
78
  const LWR_VERSION_ASSIGNMENT = `globalThis.LWR_VERSION='${LWR_VERSION}';`;
77
79
  const LWC_VERSION_ASSIGNMENT = `globalThis.LWC_VERSION='${LWC_VERSION}';`;
78
- return `${LWR_VERSION_ASSIGNMENT}${LWC_VERSION_ASSIGNMENT}${initFeatureFlagsString}`;
80
+ const PWA_KIT_RUNTIME_VERSION_ASSIGNMENT = `globalThis.PWA_KIT_RUNTIME_VERSION='${PWA_KIT_RUNTIME_VERSION}';`;
81
+ return `${LWR_VERSION_ASSIGNMENT}${LWC_VERSION_ASSIGNMENT}${PWA_KIT_RUNTIME_VERSION_ASSIGNMENT}${initFeatureFlagsString}`;
79
82
  }
80
83
  //# sourceMappingURL=server-build.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.12.0-alpha.3",
7
+ "version": "0.12.0-alpha.31",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -32,15 +32,15 @@
32
32
  "package.cjs"
33
33
  ],
34
34
  "dependencies": {
35
- "@lwrjs/config": "0.12.0-alpha.3",
36
- "@lwrjs/core": "0.12.0-alpha.3",
37
- "@lwrjs/diagnostics": "0.12.0-alpha.3",
38
- "@lwrjs/shared-utils": "0.12.0-alpha.3",
35
+ "@lwrjs/config": "0.12.0-alpha.31",
36
+ "@lwrjs/core": "0.12.0-alpha.31",
37
+ "@lwrjs/diagnostics": "0.12.0-alpha.31",
38
+ "@lwrjs/shared-utils": "0.12.0-alpha.31",
39
39
  "esbuild": "^0.17.4",
40
- "fs-extra": "^11.1.1"
40
+ "fs-extra": "^11.2.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@lwrjs/types": "0.12.0-alpha.3",
43
+ "@lwrjs/types": "0.12.0-alpha.31",
44
44
  "mock-fs": "^5.2.0"
45
45
  },
46
46
  "peerDependencies": {
@@ -49,5 +49,5 @@
49
49
  "engines": {
50
50
  "node": ">=18.0.0"
51
51
  },
52
- "gitHead": "48f97b40cbacce6cd6a6faee9206a465832c6774"
52
+ "gitHead": "ef2602996527852ec4694104723baae93a130b87"
53
53
  }