@lwrjs/tools 0.9.0-alpha.36 → 0.9.0
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 +2 -1
- package/build/cjs/server-build.cjs +7 -6
- package/build/es/plugins/build-server-plugin.d.ts +1 -1
- package/build/es/plugins/build-server-plugin.js +2 -1
- package/build/es/server-build.d.ts +1 -0
- package/build/es/server-build.js +7 -6
- package/package.json +4 -4
|
@@ -102,7 +102,7 @@ function printRouteHandlers(routeHandlers) {
|
|
|
102
102
|
return `'${id}': ${handler}`;
|
|
103
103
|
}).join(",")}}`;
|
|
104
104
|
}
|
|
105
|
-
function buildLwrServer(config) {
|
|
105
|
+
function buildLwrServer(config, buildDir) {
|
|
106
106
|
return {
|
|
107
107
|
name: "lwr-server-build",
|
|
108
108
|
setup(build) {
|
|
@@ -140,6 +140,7 @@ function buildLwrServer(config) {
|
|
|
140
140
|
...serviceImports,
|
|
141
141
|
...hooksConfig.imports,
|
|
142
142
|
...routeHandlersConfig.imports,
|
|
143
|
+
`export const buildDir = '${buildDir || "app"}';`,
|
|
143
144
|
`export const appConfig = ${JSON.stringify(remoteAppConfig)};`,
|
|
144
145
|
`export const runtimeEnvironment = ${JSON.stringify(runtimeEnvironment)};`,
|
|
145
146
|
`export const globalData = ${JSON.stringify(globalData)};`,
|
|
@@ -35,7 +35,7 @@ var import_config = __toModule(require("@lwrjs/config"));
|
|
|
35
35
|
var import_generate_entry_plugin = __toModule(require("./plugins/generate-entry-plugin.cjs"));
|
|
36
36
|
var import_build_server_plugin = __toModule(require("./plugins/build-server-plugin.cjs"));
|
|
37
37
|
async function build(buildOptions, config) {
|
|
38
|
-
const {outputDir, minify} = buildOptions;
|
|
38
|
+
const {outputDir, normalizedOutputDir, minify} = buildOptions;
|
|
39
39
|
await import_esbuild.default.build({
|
|
40
40
|
entryPoints: ["./lwr.entry.js"],
|
|
41
41
|
bundle: true,
|
|
@@ -57,15 +57,16 @@ async function build(buildOptions, config) {
|
|
|
57
57
|
banner: {
|
|
58
58
|
js: createEnvVarHeader()
|
|
59
59
|
},
|
|
60
|
-
plugins: [(0, import_generate_entry_plugin.default)(), (0, import_build_server_plugin.default)(config)],
|
|
61
|
-
outfile: import_path.default.join(
|
|
60
|
+
plugins: [(0, import_generate_entry_plugin.default)(), (0, import_build_server_plugin.default)(config, outputDir)],
|
|
61
|
+
outfile: import_path.default.join(normalizedOutputDir, "ssr.js")
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
async function buildServer(configArg, options) {
|
|
65
65
|
const startTime = import_perf_hooks.performance.now();
|
|
66
|
-
const outputDir =
|
|
67
|
-
|
|
68
|
-
await
|
|
66
|
+
const outputDir = options?.outputDir || "/build";
|
|
67
|
+
const normalizedOutputDir = import_path.default.join(configArg?.rootDir || process.cwd(), outputDir);
|
|
68
|
+
await import_fs_extra.default.ensureDir(normalizedOutputDir);
|
|
69
|
+
await build({outputDir, normalizedOutputDir, minify: !!options?.minify}, configArg);
|
|
69
70
|
const endTime = import_perf_hooks.performance.now();
|
|
70
71
|
const timeDiff = endTime - startTime;
|
|
71
72
|
import_shared_utils.logger.info(`[Server Build] successfully built the server in ${Math.round(timeDiff)} ms`);
|
|
@@ -14,5 +14,5 @@ import type { LwrGlobalConfig } from '@lwrjs/types';
|
|
|
14
14
|
* @param config - programmatic global config
|
|
15
15
|
* @returns esbuild plugin
|
|
16
16
|
*/
|
|
17
|
-
export default function buildLwrServer(config?: LwrGlobalConfig): Plugin;
|
|
17
|
+
export default function buildLwrServer(config?: LwrGlobalConfig, buildDir?: string): Plugin;
|
|
18
18
|
//# sourceMappingURL=build-server-plugin.d.ts.map
|
|
@@ -94,7 +94,7 @@ function printRouteHandlers(routeHandlers) {
|
|
|
94
94
|
* @param config - programmatic global config
|
|
95
95
|
* @returns esbuild plugin
|
|
96
96
|
*/
|
|
97
|
-
export default function buildLwrServer(config) {
|
|
97
|
+
export default function buildLwrServer(config, buildDir) {
|
|
98
98
|
return {
|
|
99
99
|
name: 'lwr-server-build',
|
|
100
100
|
setup(build) {
|
|
@@ -136,6 +136,7 @@ export default function buildLwrServer(config) {
|
|
|
136
136
|
...serviceImports,
|
|
137
137
|
...hooksConfig.imports,
|
|
138
138
|
...routeHandlersConfig.imports,
|
|
139
|
+
`export const buildDir = '${buildDir || 'app'}';`,
|
|
139
140
|
`export const appConfig = ${JSON.stringify(remoteAppConfig)};`,
|
|
140
141
|
`export const runtimeEnvironment = ${JSON.stringify(runtimeEnvironment)};`,
|
|
141
142
|
`export const globalData = ${JSON.stringify(globalData)};`,
|
package/build/es/server-build.js
CHANGED
|
@@ -7,7 +7,7 @@ import { LWR_VERSION, LWC_VERSION } from '@lwrjs/config';
|
|
|
7
7
|
import generateLwrEntry from './plugins/generate-entry-plugin.js';
|
|
8
8
|
import buildLwrServer from './plugins/build-server-plugin.js';
|
|
9
9
|
async function build(buildOptions, config) {
|
|
10
|
-
const { outputDir, minify } = buildOptions;
|
|
10
|
+
const { outputDir, normalizedOutputDir, minify } = buildOptions;
|
|
11
11
|
// building specifically for MRT/Lambda
|
|
12
12
|
await esbuild.build({
|
|
13
13
|
entryPoints: ['./lwr.entry.js'],
|
|
@@ -37,9 +37,9 @@ async function build(buildOptions, config) {
|
|
|
37
37
|
banner: {
|
|
38
38
|
js: createEnvVarHeader(),
|
|
39
39
|
},
|
|
40
|
-
plugins: [generateLwrEntry(), buildLwrServer(config)],
|
|
40
|
+
plugins: [generateLwrEntry(), buildLwrServer(config, outputDir)],
|
|
41
41
|
// MRT expects an entry point named `ssr.js`
|
|
42
|
-
outfile: path.join(
|
|
42
|
+
outfile: path.join(normalizedOutputDir, 'ssr.js'),
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -51,9 +51,10 @@ async function build(buildOptions, config) {
|
|
|
51
51
|
*/
|
|
52
52
|
export async function buildServer(configArg, options) {
|
|
53
53
|
const startTime = performance.now();
|
|
54
|
-
const outputDir =
|
|
55
|
-
|
|
56
|
-
await
|
|
54
|
+
const outputDir = options?.outputDir || '/build';
|
|
55
|
+
const normalizedOutputDir = path.join(configArg?.rootDir || process.cwd(), outputDir);
|
|
56
|
+
await fs.ensureDir(normalizedOutputDir);
|
|
57
|
+
await build({ outputDir, normalizedOutputDir, minify: !!options?.minify }, configArg);
|
|
57
58
|
const endTime = performance.now();
|
|
58
59
|
const timeDiff = endTime - startTime;
|
|
59
60
|
logger.info(`[Server Build] successfully built the server in ${Math.round(timeDiff)} ms`);
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.9.0
|
|
7
|
+
"version": "0.9.0",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"package.cjs"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@lwrjs/core": "0.9.0
|
|
35
|
+
"@lwrjs/core": "0.9.0",
|
|
36
36
|
"esbuild": "^0.17.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@lwrjs/types": "0.9.0
|
|
39
|
+
"@lwrjs/types": "0.9.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"lwc": "2.x"
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=16.0.0 <20"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "4e42b0dc5453f92b36b42aa8132c5bc281e616b7"
|
|
48
48
|
}
|