edge-functions 4.0.0 → 4.0.1-stage.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,3 +1,10 @@
1
+ ### [4.0.1-stage.1](https://github.com/aziontech/bundler/compare/v4.0.0...v4.0.1-stage.1) (2024-09-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * merge azion.config user with preset azion.config ([#386](https://github.com/aziontech/bundler/issues/386)) ([8b1054b](https://github.com/aziontech/bundler/commit/8b1054b4610c1e9a72fdb165ed7c785c8b15bddf))
7
+
1
8
  ## [4.0.0](https://github.com/aziontech/bundler/compare/v3.3.0...v4.0.0) (2024-09-25)
2
9
 
3
10
 
@@ -1,4 +1,5 @@
1
1
  import { join } from 'path';
2
+ import lodash from 'lodash';
2
3
  import { readFileSync, existsSync, writeFileSync, rmSync } from 'fs';
3
4
  import { Esbuild, Webpack } from '#bundlers';
4
5
  import {
@@ -526,25 +527,47 @@ class Dispatcher {
526
527
  }
527
528
  }
528
529
  // manifest
530
+ // azion.config.js preset
531
+ const presetAzionConfigPath = join(
532
+ this.vulcanLibPath,
533
+ 'presets',
534
+ this.preset.name,
535
+ 'azion.config.js',
536
+ );
537
+ const presetConfigModule = await vulcan.loadAzionConfig(
538
+ presetAzionConfigPath,
539
+ );
540
+ // azion.config.js project user
529
541
  const azionConfigPath = await vulcan.getAzionConfigPath();
530
- let configModule = await vulcan.loadAzionConfig(azionConfigPath);
542
+ const azionConfigModule = await vulcan.loadAzionConfig(azionConfigPath);
531
543
 
532
- if (!configModule) {
533
- const presetAzionConfigPath = join(
534
- this.vulcanLibPath,
535
- 'presets',
536
- this.preset.name,
537
- 'azion.config.js',
538
- );
539
- configModule = await vulcan.loadAzionConfig(presetAzionConfigPath);
544
+ if (!presetConfigModule) {
545
+ throw new Error(Messages.errors.azion_config_not_found);
546
+ }
540
547
 
541
- if (configModule) {
542
- await vulcan.createAzionConfigFile(isCommonJS(), configModule);
548
+ // merge azion.config.js user with preset azion.config.js
549
+ const customizer = (objValue, srcValue) => {
550
+ if (Array.isArray(objValue)) {
551
+ const map = new Map();
552
+ objValue.concat(srcValue).forEach((item) => {
553
+ if (item && item.name) {
554
+ map.set(item.name, item);
555
+ }
556
+ });
557
+ return Array.from(map.values());
543
558
  }
544
- }
559
+ return undefined;
560
+ };
561
+ // priority to user config
562
+ const configModule = lodash.mergeWith(
563
+ {},
564
+ presetConfigModule,
565
+ azionConfigModule,
566
+ customizer,
567
+ );
545
568
 
546
569
  if (!configModule) {
547
- throw new Error(Messages.errors.azion_config_not_found);
570
+ await vulcan.createAzionConfigFile(isCommonJS(), configModule);
548
571
  }
549
572
 
550
573
  const outputPath = join(process.cwd(), '.edge');
@@ -6,7 +6,7 @@ Build messages object.
6
6
  */
7
7
  const build = {
8
8
  success: {
9
- prebuild_succeeded: 'Preb-uild succeeded!',
9
+ prebuild_succeeded: 'Pre-build succeeded!',
10
10
  vulcan_build_succeeded: 'Build completed!',
11
11
  manifest_succeeded: 'Azion Manifest generated successfully!',
12
12
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "edge-functions",
3
3
  "type": "module",
4
- "version": "4.0.0",
4
+ "version": "4.0.1-stage.1",
5
5
  "description": "Tool to launch and build JavaScript/Frameworks. This tool automates polyfills for Edge Computing and assists in creating Workers, notably for the Azion platform.",
6
6
  "main": "lib/main.js",
7
7
  "bin": {