@lwrjs/tools 0.11.0-alpha.8 → 0.11.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/dedupe-bundles.cjs +133 -0
- package/build/cjs/index.cjs +3 -1
- package/build/cjs/plugins/build-server-plugin.cjs +2 -1
- package/build/cjs/plugins/generate-entry-plugin.cjs +1 -0
- package/build/cjs/server-build.cjs +3 -1
- package/build/es/dedupe-bundles.d.ts +8 -0
- package/build/es/dedupe-bundles.js +130 -0
- package/build/es/index.d.ts +1 -0
- package/build/es/index.js +1 -0
- package/build/es/plugins/build-server-plugin.js +2 -1
- package/build/es/plugins/generate-entry-plugin.js +5 -0
- package/build/es/server-build.js +3 -1
- package/package.json +11 -6
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __exportStar = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toModule = (module2) => {
|
|
21
|
+
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/@lwrjs/tools/src/dedupe-bundles.ts
|
|
25
|
+
__markAsModule(exports);
|
|
26
|
+
__export(exports, {
|
|
27
|
+
dedupeBundles: () => dedupeBundles
|
|
28
|
+
});
|
|
29
|
+
var import_fs_extra = __toModule(require("fs-extra"));
|
|
30
|
+
var import_path = __toModule(require("path"));
|
|
31
|
+
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
32
|
+
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
33
|
+
var DEFAULT_KEY = "default";
|
|
34
|
+
async function dedupeBundles(siteRoot, i18n) {
|
|
35
|
+
const bundleMetadataFilePath = import_path.default.join(siteRoot, "/.metadata/bundle-metadata.json");
|
|
36
|
+
const siteBundles = await import_fs_extra.default.readJSON(bundleMetadataFilePath);
|
|
37
|
+
import_diagnostics.logger.info(`[dedupeBundles] Deduplicating ${Object.keys(siteBundles.bundles).length} bundles`);
|
|
38
|
+
const groupedBundles = groupBundlesByLocales(siteBundles);
|
|
39
|
+
import_diagnostics.logger.debug(`[dedupeBundles] Found ${Object.keys(groupedBundles).length} grouped bundles`);
|
|
40
|
+
const updatedBundleMetadata = {bundles: {}};
|
|
41
|
+
const updatedBundles = updatedBundleMetadata.bundles;
|
|
42
|
+
for (const specifier of Object.keys(groupedBundles)) {
|
|
43
|
+
const variants = groupedBundles[specifier];
|
|
44
|
+
const defaultVariant = variants[DEFAULT_KEY];
|
|
45
|
+
if (defaultVariant) {
|
|
46
|
+
updatedBundles[specifier] = defaultVariant;
|
|
47
|
+
const defaultSource = String(import_fs_extra.default.readFileSync(import_path.default.join(siteRoot, defaultVariant.path)));
|
|
48
|
+
for (const variantKey of Object.keys(variants)) {
|
|
49
|
+
if (variantKey !== DEFAULT_KEY) {
|
|
50
|
+
let dedupeSource = false;
|
|
51
|
+
const variant = variants[variantKey];
|
|
52
|
+
const variantSource = String(import_fs_extra.default.readFileSync(import_path.default.join(siteRoot, variant.path)));
|
|
53
|
+
const localeId = extractLocale(variantKey);
|
|
54
|
+
if (localeId) {
|
|
55
|
+
dedupeSource = await (0, import_shared_utils.walkLocaleFallbacks)(localeId, i18n, async (curLocale) => {
|
|
56
|
+
if (curLocale === localeId) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (curLocale === i18n.defaultLocale) {
|
|
60
|
+
return variantSource === defaultSource;
|
|
61
|
+
}
|
|
62
|
+
const curVariant = variants[`l/${curLocale}`];
|
|
63
|
+
if (curVariant) {
|
|
64
|
+
const curPath = import_path.default.join(siteRoot, curVariant.path);
|
|
65
|
+
if (await import_fs_extra.default.pathExists(curPath)) {
|
|
66
|
+
const curVariantSource = String(import_fs_extra.default.readFileSync(curPath));
|
|
67
|
+
return variantSource === curVariantSource;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
if (dedupeSource) {
|
|
74
|
+
import_diagnostics.logger.debug(`[dedupeBundles] Remove duplicate variant ${specifier}|${variantKey}`);
|
|
75
|
+
import_fs_extra.default.removeSync(import_path.default.join(siteRoot, variant.path));
|
|
76
|
+
} else {
|
|
77
|
+
const variant2 = variants[variantKey];
|
|
78
|
+
updatedBundles[`${specifier}|${variantKey}`] = variant2;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
import_diagnostics.logger.info(`[dedupeBundles] Deduplicated down to ${Object.keys(updatedBundleMetadata.bundles).length} bundles`);
|
|
85
|
+
await import_fs_extra.default.writeJSON(bundleMetadataFilePath, updatedBundleMetadata, {spaces: 2});
|
|
86
|
+
deleteEmptyFolders(siteRoot);
|
|
87
|
+
}
|
|
88
|
+
var LOCALE_PATTERN = /(?:^|\/)l\/([\w-_]+)/;
|
|
89
|
+
function extractLocale(variantKey) {
|
|
90
|
+
const match = variantKey.match(LOCALE_PATTERN);
|
|
91
|
+
if (match) {
|
|
92
|
+
return match[1];
|
|
93
|
+
}
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
function groupBundlesByLocales(siteBundles) {
|
|
97
|
+
const groupedBundles = {};
|
|
98
|
+
for (const specifier of Object.keys(siteBundles.bundles)) {
|
|
99
|
+
const parts = specifier.split("|");
|
|
100
|
+
const firstPart = parts[0];
|
|
101
|
+
const secondPart = parts.length > 1 ? parts[1] : DEFAULT_KEY;
|
|
102
|
+
import_diagnostics.logger.debug(`[dedupeBundles] ${specifier} -> groupedBundles[${firstPart}][${secondPart}]`);
|
|
103
|
+
if (!groupedBundles[firstPart]) {
|
|
104
|
+
groupedBundles[firstPart] = {};
|
|
105
|
+
}
|
|
106
|
+
groupedBundles[firstPart][secondPart] = siteBundles.bundles[specifier];
|
|
107
|
+
}
|
|
108
|
+
return groupedBundles;
|
|
109
|
+
}
|
|
110
|
+
function deleteEmptyFolders(directory) {
|
|
111
|
+
if (!import_fs_extra.default.existsSync(directory)) {
|
|
112
|
+
import_diagnostics.logger.warn(`[dedupeBundles] Directory does not exist: ${directory}`);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const files = import_fs_extra.default.readdirSync(directory);
|
|
116
|
+
if (files.length === 0) {
|
|
117
|
+
import_fs_extra.default.rmdirSync(directory);
|
|
118
|
+
import_diagnostics.logger.debug(`[dedupeBundles] Deleted empty folder: ${directory}`);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
files.forEach((file) => {
|
|
122
|
+
const filePath = import_path.default.join(directory, file);
|
|
123
|
+
const isDirectory = import_fs_extra.default.statSync(filePath).isDirectory();
|
|
124
|
+
if (isDirectory) {
|
|
125
|
+
deleteEmptyFolders(filePath);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const updatedFiles = import_fs_extra.default.readdirSync(directory);
|
|
129
|
+
if (updatedFiles.length === 0) {
|
|
130
|
+
import_fs_extra.default.rmdirSync(directory);
|
|
131
|
+
import_diagnostics.logger.debug(`[dedupeBundles] Deleted empty folder: ${directory}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -24,6 +24,8 @@ var __toModule = (module2) => {
|
|
|
24
24
|
// packages/@lwrjs/tools/src/index.ts
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
-
buildServer: () => import_server_build.buildServer
|
|
27
|
+
buildServer: () => import_server_build.buildServer,
|
|
28
|
+
dedupeBundles: () => import_dedupe_bundles.dedupeBundles
|
|
28
29
|
});
|
|
29
30
|
var import_server_build = __toModule(require("./server-build.cjs"));
|
|
31
|
+
var import_dedupe_bundles = __toModule(require("./dedupe-bundles.cjs"));
|
|
@@ -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)}';`);
|
|
@@ -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",
|
|
@@ -67,7 +69,7 @@ async function buildServer(configArg, options) {
|
|
|
67
69
|
await build({outputDir, normalizedOutputDir, minify: !!options?.minify}, configArg);
|
|
68
70
|
const endTime = import_perf_hooks.performance.now();
|
|
69
71
|
const timeDiff = endTime - startTime;
|
|
70
|
-
|
|
72
|
+
import_diagnostics.logger.info(`[Server Build] successfully built the server in ${Math.round(timeDiff)} ms`);
|
|
71
73
|
}
|
|
72
74
|
function createEnvVarHeader() {
|
|
73
75
|
const currentFeatureFlags = (0, import_shared_utils.getFeatureFlags)();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { I18NConfig } from '@lwrjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* De-duplicate generated bundles
|
|
4
|
+
*
|
|
5
|
+
* @param siteRoot The root folder for generated bundles
|
|
6
|
+
*/
|
|
7
|
+
export declare function dedupeBundles(siteRoot: string, i18n: I18NConfig): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=dedupe-bundles.d.ts.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { logger } from '@lwrjs/diagnostics';
|
|
4
|
+
import { walkLocaleFallbacks } from '@lwrjs/shared-utils';
|
|
5
|
+
const DEFAULT_KEY = 'default';
|
|
6
|
+
/**
|
|
7
|
+
* De-duplicate generated bundles
|
|
8
|
+
*
|
|
9
|
+
* @param siteRoot The root folder for generated bundles
|
|
10
|
+
*/
|
|
11
|
+
export async function dedupeBundles(siteRoot, i18n) {
|
|
12
|
+
// Read the bundle site metadata
|
|
13
|
+
const bundleMetadataFilePath = path.join(siteRoot, '/.metadata/bundle-metadata.json');
|
|
14
|
+
const siteBundles = await fs.readJSON(bundleMetadataFilePath);
|
|
15
|
+
logger.info(`[dedupeBundles] Deduplicating ${Object.keys(siteBundles.bundles).length} bundles`);
|
|
16
|
+
// Group the bundles by locale
|
|
17
|
+
const groupedBundles = groupBundlesByLocales(siteBundles);
|
|
18
|
+
logger.debug(`[dedupeBundles] Found ${Object.keys(groupedBundles).length} grouped bundles`);
|
|
19
|
+
const updatedBundleMetadata = { bundles: {} };
|
|
20
|
+
const updatedBundles = updatedBundleMetadata.bundles;
|
|
21
|
+
for (const specifier of Object.keys(groupedBundles)) {
|
|
22
|
+
const variants = groupedBundles[specifier];
|
|
23
|
+
const defaultVariant = variants[DEFAULT_KEY];
|
|
24
|
+
if (defaultVariant) {
|
|
25
|
+
updatedBundles[specifier] = defaultVariant;
|
|
26
|
+
const defaultSource = String(fs.readFileSync(path.join(siteRoot, defaultVariant.path)));
|
|
27
|
+
// Wite out each variant
|
|
28
|
+
for (const variantKey of Object.keys(variants)) {
|
|
29
|
+
if (variantKey !== DEFAULT_KEY) {
|
|
30
|
+
// Find the first source that does not match its parent
|
|
31
|
+
let dedupeSource = false;
|
|
32
|
+
// Read the current variant source
|
|
33
|
+
const variant = variants[variantKey];
|
|
34
|
+
const variantSource = String(fs.readFileSync(path.join(siteRoot, variant.path)));
|
|
35
|
+
const localeId = extractLocale(variantKey);
|
|
36
|
+
// If this locale is n
|
|
37
|
+
if (localeId) {
|
|
38
|
+
// eslint-disable-next-line no-await-in-loop
|
|
39
|
+
dedupeSource = await walkLocaleFallbacks(localeId, i18n, async (curLocale) => {
|
|
40
|
+
// If this is the current locale skip
|
|
41
|
+
if (curLocale === localeId) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
// If this is a default local test against the read default
|
|
45
|
+
if (curLocale === i18n.defaultLocale) {
|
|
46
|
+
return variantSource === defaultSource;
|
|
47
|
+
}
|
|
48
|
+
// See if there is a variant for the current locale
|
|
49
|
+
const curVariant = variants[`l/${curLocale}`];
|
|
50
|
+
if (curVariant) {
|
|
51
|
+
const curPath = path.join(siteRoot, curVariant.path);
|
|
52
|
+
if (await fs.pathExists(curPath)) {
|
|
53
|
+
const curVariantSource = String(fs.readFileSync(curPath));
|
|
54
|
+
return variantSource === curVariantSource;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (dedupeSource) {
|
|
61
|
+
logger.debug(`[dedupeBundles] Remove duplicate variant ${specifier}|${variantKey}`);
|
|
62
|
+
fs.removeSync(path.join(siteRoot, variant.path));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// keep the variant in the metadata
|
|
66
|
+
const variant = variants[variantKey];
|
|
67
|
+
updatedBundles[`${specifier}|${variantKey}`] = variant;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
logger.info(`[dedupeBundles] Deduplicated down to ${Object.keys(updatedBundleMetadata.bundles).length} bundles`);
|
|
74
|
+
// Save the updated bundle metadata
|
|
75
|
+
await fs.writeJSON(bundleMetadataFilePath, updatedBundleMetadata, { spaces: 2 });
|
|
76
|
+
// Clean up empty folders
|
|
77
|
+
deleteEmptyFolders(siteRoot);
|
|
78
|
+
}
|
|
79
|
+
const LOCALE_PATTERN = /(?:^|\/)l\/([\w-_]+)/;
|
|
80
|
+
/**
|
|
81
|
+
* Extract the locale definition from a variant key 'l/{localeId}'
|
|
82
|
+
*/
|
|
83
|
+
function extractLocale(variantKey) {
|
|
84
|
+
const match = variantKey.match(LOCALE_PATTERN);
|
|
85
|
+
if (match) {
|
|
86
|
+
return match[1]; // The 'key' is captured in the first capture group
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
function groupBundlesByLocales(siteBundles) {
|
|
91
|
+
const groupedBundles = {};
|
|
92
|
+
for (const specifier of Object.keys(siteBundles.bundles)) {
|
|
93
|
+
const parts = specifier.split('|');
|
|
94
|
+
// Extract the desired parts
|
|
95
|
+
const firstPart = parts[0];
|
|
96
|
+
const secondPart = parts.length > 1 ? parts[1] : DEFAULT_KEY;
|
|
97
|
+
logger.debug(`[dedupeBundles] ${specifier} -> groupedBundles[${firstPart}][${secondPart}]`);
|
|
98
|
+
if (!groupedBundles[firstPart]) {
|
|
99
|
+
groupedBundles[firstPart] = {};
|
|
100
|
+
}
|
|
101
|
+
groupedBundles[firstPart][secondPart] = siteBundles.bundles[specifier];
|
|
102
|
+
}
|
|
103
|
+
return groupedBundles;
|
|
104
|
+
}
|
|
105
|
+
function deleteEmptyFolders(directory) {
|
|
106
|
+
if (!fs.existsSync(directory)) {
|
|
107
|
+
logger.warn(`[dedupeBundles] Directory does not exist: ${directory}`);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const files = fs.readdirSync(directory);
|
|
111
|
+
if (files.length === 0) {
|
|
112
|
+
fs.rmdirSync(directory);
|
|
113
|
+
logger.debug(`[dedupeBundles] Deleted empty folder: ${directory}`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
files.forEach((file) => {
|
|
117
|
+
const filePath = path.join(directory, file);
|
|
118
|
+
const isDirectory = fs.statSync(filePath).isDirectory();
|
|
119
|
+
if (isDirectory) {
|
|
120
|
+
deleteEmptyFolders(filePath);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
// Check if the directory is empty after deleting its subdirectories
|
|
124
|
+
const updatedFiles = fs.readdirSync(directory);
|
|
125
|
+
if (updatedFiles.length === 0) {
|
|
126
|
+
fs.rmdirSync(directory);
|
|
127
|
+
logger.debug(`[dedupeBundles] Deleted empty folder: ${directory}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=dedupe-bundles.js.map
|
package/build/es/index.d.ts
CHANGED
package/build/es/index.js
CHANGED
|
@@ -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
|
}
|
|
@@ -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',
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.11.0
|
|
7
|
+
"version": "0.11.0",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -32,17 +32,22 @@
|
|
|
32
32
|
"package.cjs"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@lwrjs/
|
|
36
|
-
"
|
|
35
|
+
"@lwrjs/config": "0.11.0",
|
|
36
|
+
"@lwrjs/core": "0.11.0",
|
|
37
|
+
"@lwrjs/diagnostics": "0.11.0",
|
|
38
|
+
"@lwrjs/shared-utils": "0.11.0",
|
|
39
|
+
"esbuild": "^0.17.4",
|
|
40
|
+
"fs-extra": "^11.1.1"
|
|
37
41
|
},
|
|
38
42
|
"devDependencies": {
|
|
39
|
-
"@lwrjs/types": "0.11.0
|
|
43
|
+
"@lwrjs/types": "0.11.0",
|
|
44
|
+
"mock-fs": "^5.2.0"
|
|
40
45
|
},
|
|
41
46
|
"peerDependencies": {
|
|
42
|
-
"lwc": "2.x || 3.x"
|
|
47
|
+
"lwc": "2.x || 3.x || 4.x"
|
|
43
48
|
},
|
|
44
49
|
"engines": {
|
|
45
50
|
"node": ">=16.0.0"
|
|
46
51
|
},
|
|
47
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "fbc883ea90a12672ce6f1adc2201144fda8762bd"
|
|
48
53
|
}
|