mod-build 4.0.1-beta.8b → 4.0.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,8 @@
1
1
  ## 4.0.1
2
2
 
3
3
  - Add footAssetsConfig to additionalAssets
4
+ - Updated Handlebars HMR to compile the templates when partials are changed
5
+ - Added a `clean` task to delete directories created on build for easier testing
4
6
 
5
7
  ## 4.0.0-beta.5
6
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "4.0.1-beta.8b",
3
+ "version": "4.0.1",
4
4
  "description": "Share components for S3 sites.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -33,10 +33,21 @@ export const STATIC_COPY_TARGETS = [
33
33
  },
34
34
  ];
35
35
 
36
- export const updateConfig = async (config) => {
36
+ // eslint-disable-next-line no-unused-vars
37
+ let tempConfigExists;
38
+
39
+ const customizer = (objValue, srcValue) => {
40
+ // If the key exists in parsedConfig but not in mergedConfig, drop it from the merged result
41
+ if (srcValue === undefined) {
42
+ return undefined;
43
+ }
44
+
45
+ // Otherwise, use the default merging behavior
46
+ return merge(objValue, srcValue); // or you can return merge(objValue, srcValue) to merge nested objects
47
+ };
48
+
49
+ const checkForTempConfig = (config) => {
37
50
  const { isLocal, nodeEnv, buildPath } = defaultSettings;
38
- // eslint-disable-next-line no-unused-vars
39
- let tempConfigExists;
40
51
 
41
52
  let mergedConfig = {
42
53
  ...config,
@@ -44,33 +55,23 @@ export const updateConfig = async (config) => {
44
55
  ...{ isLocal, nodeEnv, buildPath }
45
56
  };
46
57
 
47
- const customizer = (objValue, srcValue) => {
48
- // If the key exists in parsedConfig but not in mergedConfig, drop it from the merged result
49
- if (srcValue === undefined) {
50
- return undefined;
51
- }
52
-
53
- // Otherwise, use the default merging behavior
54
- return merge(objValue, srcValue); // or you can return merge(objValue, srcValue) to merge nested objects
55
- };
56
-
57
- const checkForTempConfig = () => {
58
- return new Promise((resolve) => {
59
- tempConfigExists = fs.existsSync(`src/.tmp/config.json`);
60
-
58
+ return new Promise((resolve) => {
59
+ tempConfigExists = fs.existsSync(`src/.tmp/config.json`);
60
+ if (tempConfigExists) {
61
61
  const configData = fs.readFileSync('src/.tmp/config.json', 'utf8');
62
62
  const parsedConfig = JSON.parse(configData);
63
63
  mergedConfig = mergeWith(parsedConfig, mergedConfig, customizer);
64
+ }
65
+ resolve(mergedConfig);
66
+ });
67
+ };
64
68
 
65
- resolve();
66
- });
67
- };
69
+ export const updateConfig = async (config) => {
70
+ const mergedConfig = await checkForTempConfig(config);
68
71
 
69
72
  return {
70
73
  name: 'update-config',
71
74
  async configResolved({ configFileDependencies }) {
72
- await checkForTempConfig();
73
-
74
75
  configFileDependencies.forEach((file) => {
75
76
  if (file.endsWith('siteconfig.js') || file.endsWith('template.js')) {
76
77
  console.log('siteconfig or template changed');
@@ -93,6 +94,8 @@ export const updateConfig = async (config) => {
93
94
  }
94
95
 
95
96
  export const updateHandlebarsOnWatch = async (config) => {
97
+ const mergedConfig = await checkForTempConfig(config);
98
+
96
99
  return {
97
100
  name: 'update-handlebars-reload',
98
101
  enforce: 'pre',
@@ -105,7 +108,7 @@ export const updateHandlebarsOnWatch = async (config) => {
105
108
  }
106
109
  },
107
110
  transformIndexHtml: () => {
108
- gulpHandlebarsFileInclude(config, { maxRecursion: 500 });
111
+ gulpHandlebarsFileInclude(mergedConfig, { maxRecursion: 500 });
109
112
  }
110
113
  }
111
114
  }
package/tasks/clean.js CHANGED
@@ -7,6 +7,6 @@ foldersToDelete.forEach(async (folder) => {
7
7
  await fs.promises.rm(folder, { recursive: true });
8
8
  console.log(`Folder ${folder} deleted successfully`);
9
9
  } catch (err) {
10
- console.error(`Failed to delete folder ${folder}: ${err}`);
10
+ // fail silently
11
11
  }
12
12
  });