@lwrjs/tools 0.11.4 → 0.11.5

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.
@@ -34,9 +34,15 @@ var DEFAULT_KEY = "default";
34
34
  async function dedupeBundles(siteRoot, i18n) {
35
35
  const bundleMetadataFilePath = import_path.default.join(siteRoot, "/.metadata/bundle-metadata.json");
36
36
  const siteBundles = await import_fs_extra.default.readJSON(bundleMetadataFilePath);
37
- import_diagnostics.logger.info(`[dedupeBundles] Deduplicating ${Object.keys(siteBundles.bundles).length} bundles`);
37
+ import_diagnostics.logger.info({
38
+ label: `dedupeBundles`,
39
+ message: `Deduplicating ${Object.keys(siteBundles.bundles).length} bundles`
40
+ });
38
41
  const groupedBundles = groupBundlesByLocales(siteBundles);
39
- import_diagnostics.logger.debug(`[dedupeBundles] Found ${Object.keys(groupedBundles).length} grouped bundles`);
42
+ import_diagnostics.logger.debug({
43
+ label: `dedupeBundles`,
44
+ message: `Found ${Object.keys(groupedBundles).length} grouped bundles`
45
+ });
40
46
  const updatedBundleMetadata = {bundles: {}};
41
47
  const updatedBundles = updatedBundleMetadata.bundles;
42
48
  for (const specifier of Object.keys(groupedBundles)) {
@@ -71,7 +77,10 @@ async function dedupeBundles(siteRoot, i18n) {
71
77
  });
72
78
  }
73
79
  if (dedupeSource) {
74
- import_diagnostics.logger.debug(`[dedupeBundles] Remove duplicate variant ${specifier}|${variantKey}`);
80
+ import_diagnostics.logger.debug({
81
+ label: `dedupeBundles`,
82
+ message: `Remove duplicate variant ${specifier}|${variantKey}`
83
+ });
75
84
  import_fs_extra.default.removeSync(import_path.default.join(siteRoot, variant.path));
76
85
  } else {
77
86
  const variant2 = variants[variantKey];
@@ -81,7 +90,10 @@ async function dedupeBundles(siteRoot, i18n) {
81
90
  }
82
91
  }
83
92
  }
84
- import_diagnostics.logger.info(`[dedupeBundles] Deduplicated down to ${Object.keys(updatedBundleMetadata.bundles).length} bundles`);
93
+ import_diagnostics.logger.info({
94
+ label: `dedupeBundles`,
95
+ message: `Deduplicated down to ${Object.keys(updatedBundleMetadata.bundles).length} bundles`
96
+ });
85
97
  await import_fs_extra.default.writeJSON(bundleMetadataFilePath, updatedBundleMetadata, {spaces: 2});
86
98
  deleteEmptyFolders(siteRoot);
87
99
  }
@@ -99,7 +111,10 @@ function groupBundlesByLocales(siteBundles) {
99
111
  const parts = specifier.split("|");
100
112
  const firstPart = parts[0];
101
113
  const secondPart = parts.length > 1 ? parts[1] : DEFAULT_KEY;
102
- import_diagnostics.logger.debug(`[dedupeBundles] ${specifier} -> groupedBundles[${firstPart}][${secondPart}]`);
114
+ import_diagnostics.logger.debug({
115
+ label: `dedupeBundles`,
116
+ message: `${specifier} -> groupedBundles[${firstPart}][${secondPart}]`
117
+ });
103
118
  if (!groupedBundles[firstPart]) {
104
119
  groupedBundles[firstPart] = {};
105
120
  }
@@ -109,13 +124,13 @@ function groupBundlesByLocales(siteBundles) {
109
124
  }
110
125
  function deleteEmptyFolders(directory) {
111
126
  if (!import_fs_extra.default.existsSync(directory)) {
112
- import_diagnostics.logger.warn(`[dedupeBundles] Directory does not exist: ${directory}`);
127
+ import_diagnostics.logger.warn({label: `dedupeBundles`, message: `Directory does not exist: ${directory}`});
113
128
  return;
114
129
  }
115
130
  const files = import_fs_extra.default.readdirSync(directory);
116
131
  if (files.length === 0) {
117
132
  import_fs_extra.default.rmdirSync(directory);
118
- import_diagnostics.logger.debug(`[dedupeBundles] Deleted empty folder: ${directory}`);
133
+ import_diagnostics.logger.debug({label: `dedupeBundles`, message: `Deleted empty folder: ${directory}`});
119
134
  return;
120
135
  }
121
136
  files.forEach((file) => {
@@ -128,6 +143,6 @@ function deleteEmptyFolders(directory) {
128
143
  const updatedFiles = import_fs_extra.default.readdirSync(directory);
129
144
  if (updatedFiles.length === 0) {
130
145
  import_fs_extra.default.rmdirSync(directory);
131
- import_diagnostics.logger.debug(`[dedupeBundles] Deleted empty folder: ${directory}`);
146
+ import_diagnostics.logger.debug({label: `dedupeBundles`, message: `Deleted empty folder: ${directory}`});
132
147
  }
133
148
  }
@@ -66,7 +66,10 @@ function processHooks(hooksConfig, hooks, rootDir) {
66
66
  continue;
67
67
  }
68
68
  if (hooks[index].initConfigs) {
69
- import_diagnostics.logger.warn("Consider splitting `initConfigs` hooks to a separate file.");
69
+ import_diagnostics.logger.warn({
70
+ label: `lwr-server-build`,
71
+ message: `Consider splitting 'initConfigs' hooks to a separate file.`
72
+ });
70
73
  }
71
74
  const name = "hook" + index;
72
75
  output.imports.push(`import ${name} from '${(0, import_shared_utils.normalizeDirectory)(entry, rootDir)}';`);
@@ -69,7 +69,10 @@ 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
- import_diagnostics.logger.info(`[Server Build] successfully built the server in ${Math.round(timeDiff)} ms`);
72
+ import_diagnostics.logger.info({
73
+ label: `buildServer`,
74
+ message: `successfully built the server in ${Math.round(timeDiff)} ms`
75
+ });
73
76
  }
74
77
  function createEnvVarHeader() {
75
78
  const currentFeatureFlags = (0, import_shared_utils.getFeatureFlags)();
@@ -12,10 +12,16 @@ export async function dedupeBundles(siteRoot, i18n) {
12
12
  // Read the bundle site metadata
13
13
  const bundleMetadataFilePath = path.join(siteRoot, '/.metadata/bundle-metadata.json');
14
14
  const siteBundles = await fs.readJSON(bundleMetadataFilePath);
15
- logger.info(`[dedupeBundles] Deduplicating ${Object.keys(siteBundles.bundles).length} bundles`);
15
+ logger.info({
16
+ label: `dedupeBundles`,
17
+ message: `Deduplicating ${Object.keys(siteBundles.bundles).length} bundles`,
18
+ });
16
19
  // Group the bundles by locale
17
20
  const groupedBundles = groupBundlesByLocales(siteBundles);
18
- logger.debug(`[dedupeBundles] Found ${Object.keys(groupedBundles).length} grouped bundles`);
21
+ logger.debug({
22
+ label: `dedupeBundles`,
23
+ message: `Found ${Object.keys(groupedBundles).length} grouped bundles`,
24
+ });
19
25
  const updatedBundleMetadata = { bundles: {} };
20
26
  const updatedBundles = updatedBundleMetadata.bundles;
21
27
  for (const specifier of Object.keys(groupedBundles)) {
@@ -58,7 +64,10 @@ export async function dedupeBundles(siteRoot, i18n) {
58
64
  });
59
65
  }
60
66
  if (dedupeSource) {
61
- logger.debug(`[dedupeBundles] Remove duplicate variant ${specifier}|${variantKey}`);
67
+ logger.debug({
68
+ label: `dedupeBundles`,
69
+ message: `Remove duplicate variant ${specifier}|${variantKey}`,
70
+ });
62
71
  fs.removeSync(path.join(siteRoot, variant.path));
63
72
  }
64
73
  else {
@@ -70,7 +79,10 @@ export async function dedupeBundles(siteRoot, i18n) {
70
79
  }
71
80
  }
72
81
  }
73
- logger.info(`[dedupeBundles] Deduplicated down to ${Object.keys(updatedBundleMetadata.bundles).length} bundles`);
82
+ logger.info({
83
+ label: `dedupeBundles`,
84
+ message: `Deduplicated down to ${Object.keys(updatedBundleMetadata.bundles).length} bundles`,
85
+ });
74
86
  // Save the updated bundle metadata
75
87
  await fs.writeJSON(bundleMetadataFilePath, updatedBundleMetadata, { spaces: 2 });
76
88
  // Clean up empty folders
@@ -94,7 +106,10 @@ function groupBundlesByLocales(siteBundles) {
94
106
  // Extract the desired parts
95
107
  const firstPart = parts[0];
96
108
  const secondPart = parts.length > 1 ? parts[1] : DEFAULT_KEY;
97
- logger.debug(`[dedupeBundles] ${specifier} -> groupedBundles[${firstPart}][${secondPart}]`);
109
+ logger.debug({
110
+ label: `dedupeBundles`,
111
+ message: `${specifier} -> groupedBundles[${firstPart}][${secondPart}]`,
112
+ });
98
113
  if (!groupedBundles[firstPart]) {
99
114
  groupedBundles[firstPart] = {};
100
115
  }
@@ -104,13 +119,13 @@ function groupBundlesByLocales(siteBundles) {
104
119
  }
105
120
  function deleteEmptyFolders(directory) {
106
121
  if (!fs.existsSync(directory)) {
107
- logger.warn(`[dedupeBundles] Directory does not exist: ${directory}`);
122
+ logger.warn({ label: `dedupeBundles`, message: `Directory does not exist: ${directory}` });
108
123
  return;
109
124
  }
110
125
  const files = fs.readdirSync(directory);
111
126
  if (files.length === 0) {
112
127
  fs.rmdirSync(directory);
113
- logger.debug(`[dedupeBundles] Deleted empty folder: ${directory}`);
128
+ logger.debug({ label: `dedupeBundles`, message: `Deleted empty folder: ${directory}` });
114
129
  return;
115
130
  }
116
131
  files.forEach((file) => {
@@ -124,7 +139,7 @@ function deleteEmptyFolders(directory) {
124
139
  const updatedFiles = fs.readdirSync(directory);
125
140
  if (updatedFiles.length === 0) {
126
141
  fs.rmdirSync(directory);
127
- logger.debug(`[dedupeBundles] Deleted empty folder: ${directory}`);
142
+ logger.debug({ label: `dedupeBundles`, message: `Deleted empty folder: ${directory}` });
128
143
  }
129
144
  }
130
145
  //# sourceMappingURL=dedupe-bundles.js.map
@@ -38,7 +38,10 @@ function processHooks(hooksConfig, hooks, rootDir) {
38
38
  continue;
39
39
  }
40
40
  if (hooks[index].initConfigs) {
41
- logger.warn('Consider splitting `initConfigs` hooks to a separate file.');
41
+ logger.warn({
42
+ label: `lwr-server-build`,
43
+ message: `Consider splitting 'initConfigs' hooks to a separate file.`,
44
+ });
42
45
  }
43
46
  const name = 'hook' + index;
44
47
  output.imports.push(`import ${name} from '${normalizeDirectory(entry, rootDir)}';`);
@@ -56,7 +56,10 @@ export async function buildServer(configArg, options) {
56
56
  await build({ outputDir, normalizedOutputDir, minify: !!options?.minify }, configArg);
57
57
  const endTime = performance.now();
58
58
  const timeDiff = endTime - startTime;
59
- logger.info(`[Server Build] successfully built the server in ${Math.round(timeDiff)} ms`);
59
+ logger.info({
60
+ label: `buildServer`,
61
+ message: `successfully built the server in ${Math.round(timeDiff)} ms`,
62
+ });
60
63
  }
61
64
  /**
62
65
  * Build in important environment variables set during build
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.11.4",
7
+ "version": "0.11.5",
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.11.4",
36
- "@lwrjs/core": "0.11.4",
37
- "@lwrjs/diagnostics": "0.11.4",
38
- "@lwrjs/shared-utils": "0.11.4",
35
+ "@lwrjs/config": "0.11.5",
36
+ "@lwrjs/core": "0.11.5",
37
+ "@lwrjs/diagnostics": "0.11.5",
38
+ "@lwrjs/shared-utils": "0.11.5",
39
39
  "esbuild": "^0.17.4",
40
40
  "fs-extra": "^11.1.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@lwrjs/types": "0.11.4",
43
+ "@lwrjs/types": "0.11.5",
44
44
  "mock-fs": "^5.2.0"
45
45
  },
46
46
  "peerDependencies": {
@@ -49,5 +49,5 @@
49
49
  "engines": {
50
50
  "node": ">=16.0.0"
51
51
  },
52
- "gitHead": "5528cfc12174d4800ff42db1691d14c5d194f7d6"
52
+ "gitHead": "b1a54889dd55baed1bf61ceb497d251958415595"
53
53
  }