@lwrjs/tools 0.11.0-alpha.0 → 0.11.0-alpha.10
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.
- package/build/cjs/plugins/build-server-plugin.cjs +7 -6
- package/build/cjs/plugins/generate-entry-plugin.cjs +1 -0
- package/build/cjs/server-build.cjs +3 -3
- package/build/es/plugins/build-server-plugin.js +7 -6
- package/build/es/plugins/generate-entry-plugin.js +5 -0
- package/build/es/server-build.js +3 -4
- package/package.json +5 -4
|
@@ -29,6 +29,7 @@ __export(exports, {
|
|
|
29
29
|
var import_path = __toModule(require("path"));
|
|
30
30
|
var import_config = __toModule(require("@lwrjs/config"));
|
|
31
31
|
var import_modules = __toModule(require("@lwrjs/config/modules"));
|
|
32
|
+
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
32
33
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
33
34
|
function getServices(t) {
|
|
34
35
|
return t;
|
|
@@ -65,7 +66,7 @@ function processHooks(hooksConfig, hooks, rootDir) {
|
|
|
65
66
|
continue;
|
|
66
67
|
}
|
|
67
68
|
if (hooks[index].initConfigs) {
|
|
68
|
-
|
|
69
|
+
import_diagnostics.logger.warn("Consider splitting `initConfigs` hooks to a separate file.");
|
|
69
70
|
}
|
|
70
71
|
const name = "hook" + index;
|
|
71
72
|
output.imports.push(`import ${name} from '${(0, import_shared_utils.normalizeDirectory)(entry, rootDir)}';`);
|
|
@@ -78,11 +79,11 @@ function processRouteHandlers(routeHandlers, rootDir) {
|
|
|
78
79
|
imports: [],
|
|
79
80
|
routeHandlers: {}
|
|
80
81
|
};
|
|
81
|
-
for (const [id,
|
|
82
|
+
for (const [id, handler] of Object.entries(routeHandlers)) {
|
|
82
83
|
if (!output.routeHandlers[id]) {
|
|
83
84
|
const name = `routeHandler${output.imports.length}`;
|
|
84
|
-
output.imports.push(`import ${name} from '${(0, import_shared_utils.normalizeDirectory)(handler, rootDir)}';`);
|
|
85
|
-
output.routeHandlers[id] =
|
|
85
|
+
output.imports.push(`import ${name} from '${(0, import_shared_utils.normalizeDirectory)(handler || id, rootDir)}';`);
|
|
86
|
+
output.routeHandlers[id] = name;
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
return output;
|
|
@@ -99,8 +100,8 @@ function printHooks(hooks) {
|
|
|
99
100
|
}).join(",")}]`;
|
|
100
101
|
}
|
|
101
102
|
function printRouteHandlers(routeHandlers) {
|
|
102
|
-
return `{${Object.entries(routeHandlers).map(([id,
|
|
103
|
-
return `'${id}':
|
|
103
|
+
return `{${Object.entries(routeHandlers).map(([id, handler]) => {
|
|
104
|
+
return `'${id}': ${handler}`;
|
|
104
105
|
}).join(",")}}`;
|
|
105
106
|
}
|
|
106
107
|
function buildLwrServer(config, buildDir) {
|
|
@@ -42,6 +42,7 @@ 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'`,
|
|
45
46
|
`import { createHandler } from '@lwrjs/lambda';`,
|
|
46
47
|
`import * as build from './lwr.build.js';`,
|
|
47
48
|
`const handler = createHandler(build);`,
|
|
@@ -30,6 +30,7 @@ var import_path = __toModule(require("path"));
|
|
|
30
30
|
var import_fs_extra = __toModule(require("fs-extra"));
|
|
31
31
|
var import_esbuild = __toModule(require("esbuild"));
|
|
32
32
|
var import_perf_hooks = __toModule(require("perf_hooks"));
|
|
33
|
+
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
33
34
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
34
35
|
var import_config = __toModule(require("@lwrjs/config"));
|
|
35
36
|
var import_generate_entry_plugin = __toModule(require("./plugins/generate-entry-plugin.cjs"));
|
|
@@ -41,6 +42,7 @@ async function build(buildOptions, config) {
|
|
|
41
42
|
bundle: true,
|
|
42
43
|
minify,
|
|
43
44
|
sourcemap: true,
|
|
45
|
+
sourcesContent: false,
|
|
44
46
|
format: "cjs",
|
|
45
47
|
platform: "node",
|
|
46
48
|
logLevel: "silent",
|
|
@@ -48,8 +50,6 @@ async function build(buildOptions, config) {
|
|
|
48
50
|
external: [
|
|
49
51
|
"node:*",
|
|
50
52
|
"fsevents",
|
|
51
|
-
"iltorb",
|
|
52
|
-
"shrink-ray-current",
|
|
53
53
|
"esbuild*",
|
|
54
54
|
"esinstall",
|
|
55
55
|
"@lwrjs/loader"
|
|
@@ -69,7 +69,7 @@ async function buildServer(configArg, options) {
|
|
|
69
69
|
await build({outputDir, normalizedOutputDir, minify: !!options?.minify}, configArg);
|
|
70
70
|
const endTime = import_perf_hooks.performance.now();
|
|
71
71
|
const timeDiff = endTime - startTime;
|
|
72
|
-
|
|
72
|
+
import_diagnostics.logger.info(`[Server Build] successfully built the server in ${Math.round(timeDiff)} ms`);
|
|
73
73
|
}
|
|
74
74
|
function createEnvVarHeader() {
|
|
75
75
|
const currentFeatureFlags = (0, import_shared_utils.getFeatureFlags)();
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { executeConfigHooks, loadConfig } from '@lwrjs/config';
|
|
3
3
|
import { loadHooks } from '@lwrjs/config/modules';
|
|
4
|
-
import { logger
|
|
4
|
+
import { logger } from '@lwrjs/diagnostics';
|
|
5
|
+
import { normalizeDirectory } from '@lwrjs/shared-utils';
|
|
5
6
|
function getServices(t) {
|
|
6
7
|
return t;
|
|
7
8
|
}
|
|
@@ -50,11 +51,11 @@ function processRouteHandlers(routeHandlers, rootDir) {
|
|
|
50
51
|
imports: [],
|
|
51
52
|
routeHandlers: {},
|
|
52
53
|
};
|
|
53
|
-
for (const [id,
|
|
54
|
+
for (const [id, handler] of Object.entries(routeHandlers)) {
|
|
54
55
|
if (!output.routeHandlers[id]) {
|
|
55
56
|
const name = `routeHandler${output.imports.length}`;
|
|
56
|
-
output.imports.push(`import ${name} from '${normalizeDirectory(handler, rootDir)}';`);
|
|
57
|
-
output.routeHandlers[id] =
|
|
57
|
+
output.imports.push(`import ${name} from '${normalizeDirectory(handler || id, rootDir)}';`);
|
|
58
|
+
output.routeHandlers[id] = name;
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
return output;
|
|
@@ -76,8 +77,8 @@ function printHooks(hooks) {
|
|
|
76
77
|
}
|
|
77
78
|
function printRouteHandlers(routeHandlers) {
|
|
78
79
|
return `{${Object.entries(routeHandlers)
|
|
79
|
-
.map(([id,
|
|
80
|
-
return `'${id}':
|
|
80
|
+
.map(([id, handler]) => {
|
|
81
|
+
return `'${id}': ${handler}`;
|
|
81
82
|
})
|
|
82
83
|
.join(',')}}`;
|
|
83
84
|
}
|
|
@@ -24,6 +24,11 @@ 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'`,
|
|
27
32
|
`import { createHandler } from '@lwrjs/lambda';`,
|
|
28
33
|
// Importing the server build module at this point enables support for ESM bundling.
|
|
29
34
|
// If the server build module was imported in `createHandler`, it would need to be exposed
|
package/build/es/server-build.js
CHANGED
|
@@ -2,7 +2,8 @@ import path from 'path';
|
|
|
2
2
|
import fs from 'fs-extra';
|
|
3
3
|
import esbuild from 'esbuild';
|
|
4
4
|
import { performance } from 'perf_hooks';
|
|
5
|
-
import {
|
|
5
|
+
import { logger } from '@lwrjs/diagnostics';
|
|
6
|
+
import { getFeatureFlags } from '@lwrjs/shared-utils';
|
|
6
7
|
import { LWR_VERSION, LWC_VERSION } from '@lwrjs/config';
|
|
7
8
|
import generateLwrEntry from './plugins/generate-entry-plugin.js';
|
|
8
9
|
import buildLwrServer from './plugins/build-server-plugin.js';
|
|
@@ -14,6 +15,7 @@ async function build(buildOptions, config) {
|
|
|
14
15
|
bundle: true,
|
|
15
16
|
minify,
|
|
16
17
|
sourcemap: true,
|
|
18
|
+
sourcesContent: false,
|
|
17
19
|
format: 'cjs',
|
|
18
20
|
platform: 'node',
|
|
19
21
|
logLevel: 'silent',
|
|
@@ -24,9 +26,6 @@ async function build(buildOptions, config) {
|
|
|
24
26
|
'node:*',
|
|
25
27
|
// fsevents used by chokidar used by nunjucks
|
|
26
28
|
'fsevents',
|
|
27
|
-
// Used for express compression. Should be an optional dependency and should be omitted at runtime
|
|
28
|
-
'iltorb',
|
|
29
|
-
'shrink-ray-current',
|
|
30
29
|
// These dependencies are not needed to serve a basic generated site, but they are still excluded
|
|
31
30
|
// in case there is a need to add a custom module provider.
|
|
32
31
|
'esbuild*',
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.11.0-alpha.
|
|
7
|
+
"version": "0.11.0-alpha.10",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -32,11 +32,12 @@
|
|
|
32
32
|
"package.cjs"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@lwrjs/core": "0.11.0-alpha.
|
|
35
|
+
"@lwrjs/core": "0.11.0-alpha.10",
|
|
36
|
+
"@lwrjs/diagnostics": "0.11.0-alpha.10",
|
|
36
37
|
"esbuild": "^0.17.4"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
|
-
"@lwrjs/types": "0.11.0-alpha.
|
|
40
|
+
"@lwrjs/types": "0.11.0-alpha.10"
|
|
40
41
|
},
|
|
41
42
|
"peerDependencies": {
|
|
42
43
|
"lwc": "2.x || 3.x"
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"engines": {
|
|
45
46
|
"node": ">=16.0.0"
|
|
46
47
|
},
|
|
47
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "34b1e289e8de12531f5624b64512e870157195d4"
|
|
48
49
|
}
|