edge-functions 4.2.1 → 4.3.0-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.
Files changed (41) hide show
  1. package/.gitmodules +1 -1
  2. package/CHANGELOG.md +23 -0
  3. package/Dockerfile +1 -1
  4. package/README.md +10 -5
  5. package/docs/nodejs-apis.md +58 -0
  6. package/lib/build/bundlers/webpack/plugins/babel-custom/babel-custom-loader.plugins.js +40 -0
  7. package/lib/build/bundlers/webpack/plugins/babel-custom/index.js +3 -0
  8. package/lib/build/bundlers/webpack/webpack.bundlers.js +6 -0
  9. package/lib/build/dispatcher/dispatcher.js +1 -1
  10. package/lib/commands/build.commands.js +3 -1
  11. package/lib/env/vulcan.env.js +9 -11
  12. package/lib/presets/angular/azion.config.js +7 -49
  13. package/lib/presets/astro/azion.config.js +8 -54
  14. package/lib/presets/docusaurus/azion.config.js +8 -54
  15. package/lib/presets/eleventy/azion.config.js +8 -54
  16. package/lib/presets/emscripten/azion.config.js +8 -21
  17. package/lib/presets/gatsby/azion.config.js +10 -54
  18. package/lib/presets/hexo/azion.config.js +10 -54
  19. package/lib/presets/html/azion.config.js +10 -28
  20. package/lib/presets/hugo/azion.config.js +10 -54
  21. package/lib/presets/javascript/azion.config.js +10 -21
  22. package/lib/presets/jekyll/azion.config.js +10 -54
  23. package/lib/presets/next/azion.config.js +10 -51
  24. package/lib/presets/nuxt/azion.config.js +9 -56
  25. package/lib/presets/react/azion.config.js +8 -47
  26. package/lib/presets/rustwasm/azion.config.js +10 -21
  27. package/lib/presets/stencil/azion.config.js +51 -0
  28. package/lib/presets/stencil/config.js +10 -0
  29. package/lib/presets/stencil/handler.js +17 -0
  30. package/lib/presets/stencil/prebuild.js +21 -0
  31. package/lib/presets/svelte/azion.config.js +10 -56
  32. package/lib/presets/typescript/azion.config.js +10 -21
  33. package/lib/presets/vitepress/azion.config.js +10 -54
  34. package/lib/presets/vue/azion.config.js +9 -47
  35. package/lib/presets/vuepress/azion.config.js +49 -0
  36. package/lib/presets/vuepress/config.js +10 -0
  37. package/lib/presets/vuepress/handler.js +17 -0
  38. package/lib/presets/vuepress/prebuild.js +39 -0
  39. package/lib/utils/presets/presets.utils.test.js +2 -0
  40. package/package.json +7 -2
  41. package/tasks/process-reports-nodejs-apis.js +100 -0
package/.gitmodules CHANGED
@@ -1,3 +1,3 @@
1
1
  [submodule "examples"]
2
2
  path = examples
3
- url = https://github.com/aziontech/vulcan-examples
3
+ url = https://github.com/aziontech/bundler-examples
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## [4.3.0-stage.1](https://github.com/aziontech/bundler/compare/v4.2.2-stage.1...v4.3.0-stage.1) (2024-12-13)
2
+
3
+
4
+ ### Features
5
+
6
+ * add Babel custom loader plugin and update webpack configuration ([ef6e8d4](https://github.com/aziontech/bundler/commit/ef6e8d4815aa3601796e136d4337fe6ca738133f))
7
+ * add Babel custom loader plugin and update webpack configuration ([#415](https://github.com/aziontech/bundler/issues/415)) ([8e7b06e](https://github.com/aziontech/bundler/commit/8e7b06e79a0d45e49ec23e37dba69eb8bfa10b7b))
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * duplicate error message ([45f6402](https://github.com/aziontech/bundler/commit/45f6402a0c88f197f165158a78ead03e7d47b082))
13
+ * handle both ES Modules and CommonJS imports ([9b551d5](https://github.com/aziontech/bundler/commit/9b551d5a908cbb9f06f7b1bae6a234b5fa648fa5))
14
+ * import azion.config.js (presets) ([#416](https://github.com/aziontech/bundler/issues/416)) ([e3428e6](https://github.com/aziontech/bundler/commit/e3428e6f2f29ce9e960f684e69486fa2072f5f09))
15
+ * message error scope ([08439b5](https://github.com/aziontech/bundler/commit/08439b5f0a920e3632ec974b723486285a8fec41))
16
+
17
+ ### [4.2.2-stage.1](https://github.com/aziontech/bundler/compare/v4.2.1...v4.2.2-stage.1) (2024-11-11)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * improve entry file selection logic in buildCommand ([18fee09](https://github.com/aziontech/bundler/commit/18fee090ccad28a0312d2401187b5fa21e2ad407))
23
+
1
24
  ### [4.2.1](https://github.com/aziontech/bundler/compare/v4.2.0...v4.2.1) (2024-10-28)
2
25
 
3
26
 
package/Dockerfile CHANGED
@@ -10,4 +10,4 @@ RUN apk add ruby-dev
10
10
 
11
11
  RUN gem install jekyll bundler
12
12
 
13
- COPY . /vulcan
13
+ COPY . /bundler
package/README.md CHANGED
@@ -6,7 +6,7 @@ One of the key highlights of Azion Bundler is its ability to establish an intuit
6
6
 
7
7
  ## Supported
8
8
 
9
- E2E tests run daily in the [Vulcan Examples](https://github.com/aziontech/vulcan-examples/tree/main/examples) to ensure that the presets and frameworks continue to work correctly.
9
+ E2E tests run daily in the [Bundler Examples](https://github.com/aziontech/bundler-examples/tree/main/examples) to ensure that the presets and frameworks continue to work correctly.
10
10
 
11
11
  Table:
12
12
  | Test | Status |
@@ -23,7 +23,7 @@ Table:
23
23
  | Next Static | ✅ |
24
24
  | Gatsby Static | ✅ |
25
25
  | Next Node Pages 12 3 1 Fs | ✅ |
26
- | Vue Vite Static | ⚠️ |
26
+ | Vue Vite Static | |
27
27
  | Next 12 Static | ✅ |
28
28
  | Astro Static | ✅ |
29
29
  | Simple Js Env Vars | ✅ |
@@ -40,11 +40,10 @@ Table:
40
40
  | Jekyll Static | ✅ |
41
41
  | Simple Js Esm Worker | ✅ |
42
42
  | Simple Js Esm Node | ✅ |
43
- | Simple Ts Esm | |
43
+ | Simple Ts Esm | ⚠️ |
44
44
  | Simple Js Esm | ✅ |
45
45
 
46
- Last test run date: 10/28/24 03:41:17 AM
47
-
46
+ Last test run date: 10/30/24 03:38:51 AM
48
47
  ## Quick Installation
49
48
 
50
49
  For those who just want to use Azion Bundler in their project without contributing to the development, you can install it directly from npm.
@@ -228,6 +227,12 @@ To use wasm presets you need to install the necessary tools to build your code:
228
227
  - Emscripten: [emsdk](https://emscripten.org/docs/getting_started/downloads.html);
229
228
  - Rust/Wasm: [wasm-bindgen-cli](https://crates.io/crates/wasm-bindgen-cli)
230
229
 
230
+ ## Node.js Support and Report
231
+
232
+ The compatibility between Azion Runtime and Node.js is an ongoing task, but a set of Node Runtime APIs are listed and compatible with Azion Runtime.
233
+
234
+ - [Node.js APIs support](docs/nodejs-apis.md)
235
+
231
236
  ## Contributing
232
237
 
233
238
  Check the [Contributing doc](CONTRIBUTING.md).
@@ -0,0 +1,58 @@
1
+ ### Node.js APIs
2
+
3
+ Azion Bundler provides a set of APIs to help you build and test your Node.js projects. The following sections detail the available APIs and how to use them.
4
+
5
+ #### Example usage
6
+
7
+ See more: [Buffer Example](https://github.com/aziontech/bundler-examples/tree/main/examples/runtime-apis/nodejs/buffer)
8
+
9
+ ```javascript
10
+ import { Buffer } from "node:buffer";
11
+
12
+ const main = async (event) => {
13
+ const helloBuffer = Buffer.from("Hello Edge!", "utf8");
14
+ console.log(helloBuffer.toString("hex"));
15
+ // 48656c6c6f204564676521
16
+ console.log(helloBuffer.toString("base64"));
17
+ // SGVsbG8gRWRnZSE=
18
+
19
+ helloBuffer.write("World", 6, 5, "utf8");
20
+ console.log(helloBuffer.toString());
21
+ // Hello World!
22
+ return new Response(helloBuffer.toString(), { status: 200 });
23
+ };
24
+
25
+ export default main;
26
+
27
+ ```
28
+
29
+ #### Support report
30
+
31
+ Tests run daily in the [Bundler Examples](https://github.com/aziontech/bundler-examples/tree/main/examples/runtime-apis/nodejs).
32
+
33
+ Table:
34
+ | Test | Status |
35
+ | -------------- | ------ |
36
+ | Timers | ✅ |
37
+ | Http | ✅ |
38
+ | Async Hooks | ✅ |
39
+ | String Decoder | ✅ |
40
+ | Url | ✅ |
41
+ | Crypto | ✅ |
42
+ | Process | ✅ |
43
+ | Util | ✅ |
44
+ | Vm | ✅ |
45
+ | Zlib | ✅ |
46
+ | Os | ✅ |
47
+ | Buffer | ✅ |
48
+ | Module | ✅ |
49
+ | Stream | ✅ |
50
+ | Fs | ✅ |
51
+ | Events | ✅ |
52
+ | Path | ✅ |
53
+
54
+ Last test run date: 10/30/24 11:16:36 AM
55
+ #### Docs support
56
+
57
+ See support for the Node.js APIs in the [https://www.azion.com/en/documentation/products/azion-edge-runtime/compatibility/node/](https://www.azion.com/en/documentation/products/azion-edge-runtime/compatibility/node/)
58
+
@@ -0,0 +1,40 @@
1
+ /* eslint-disable no-param-reassign,class-methods-use-this */
2
+ import { createRequire } from 'module';
3
+
4
+ const require = createRequire(import.meta.url);
5
+
6
+ class BabelCustomLoaderPlugin {
7
+ constructor(preset, presetsAllowed) {
8
+ this.preset = preset || '';
9
+ this.presetsAllowed = presetsAllowed || [];
10
+ }
11
+
12
+ apply(compiler) {
13
+ const rules = compiler.options.module.rules || [];
14
+
15
+ if (this.presetsAllowed.includes(this.preset)) {
16
+ rules.push({
17
+ test: /\.func.m?js$/,
18
+ exclude: /node_modules/,
19
+ use: {
20
+ loader: require.resolve('babel-loader'),
21
+ options: {
22
+ compact: false,
23
+ plugins: [
24
+ [
25
+ require.resolve(
26
+ '@babel/plugin-proposal-optional-chaining-assign',
27
+ ),
28
+ { version: '2023-07' },
29
+ ],
30
+ ],
31
+ },
32
+ },
33
+ });
34
+
35
+ compiler.options.module.rules = rules;
36
+ }
37
+ }
38
+ }
39
+
40
+ export default BabelCustomLoaderPlugin;
@@ -0,0 +1,3 @@
1
+ import BabelCustomLoaderPlugin from './babel-custom-loader.plugins.js';
2
+
3
+ export default BabelCustomLoaderPlugin;
@@ -10,6 +10,7 @@ import AzionWebpackConfig from './webpack.config.js';
10
10
  import BaseBundlers from '../base.bundlers.js';
11
11
  import NodePolyfillPlugin from './plugins/node-polyfills/index.js';
12
12
  import AzionPolyfillPlugin from './plugins/azion-polyfills/index.js';
13
+ import BabelCustomLoaderPlugin from './plugins/babel-custom/babel-custom-loader.plugins.js';
13
14
 
14
15
  class Webpack extends BaseBundlers {
15
16
  // eslint-disable-next-line no-useless-constructor
@@ -101,6 +102,11 @@ class Webpack extends BaseBundlers {
101
102
  new AzionPolyfillPlugin(globalThis.vulcan.buildProd),
102
103
  );
103
104
 
105
+ // add custom plugins
106
+ updatedConfig.plugins.push(
107
+ new BabelCustomLoaderPlugin(this.builderConfig.preset.name, ['next']),
108
+ );
109
+
104
110
  return updatedConfig;
105
111
  }
106
112
  }
@@ -554,7 +554,7 @@ class Dispatcher {
554
554
  const azionConfigModule = await vulcan.loadAzionConfig(azionConfigPath);
555
555
 
556
556
  if (!presetConfigModule) {
557
- throw new Error(Messages.errors.azion_config_not_found);
557
+ process.exit(1);
558
558
  }
559
559
 
560
560
  // merge azion.config.js user with preset azion.config.js
@@ -81,7 +81,9 @@ async function buildCommand(
81
81
  customConfigurationModule?.entry,
82
82
  entry,
83
83
  vulcanVariables?.entry,
84
- (await checkingProjectTypeJS()) ? './main.js' : './main.ts',
84
+ (await checkingProjectTypeJS()) === 'javascript'
85
+ ? './main.js'
86
+ : './main.ts',
85
87
  ),
86
88
  builder: getConfigValue(
87
89
  customConfigurationModule?.builder,
@@ -37,7 +37,7 @@ async function createVulcanEnv(variables, scope = 'global') {
37
37
  await fsPromises.mkdir(basePath, { recursive: true });
38
38
  } catch (error) {
39
39
  debug.error(error);
40
- feedback.error(Messages.errors.folder_creation_failed(vulcanEnvPath));
40
+ feedback.build.error(Messages.errors.folder_creation_failed(vulcanEnvPath));
41
41
  throw error;
42
42
  }
43
43
 
@@ -47,7 +47,7 @@ async function createVulcanEnv(variables, scope = 'global') {
47
47
  } catch (error) {
48
48
  if (error.code !== 'ENOENT') {
49
49
  debug.error(error);
50
- feedback.error(Messages.errors.file_doesnt_exist(vulcanEnvPath));
50
+ feedback.build.error(Messages.errors.file_doesnt_exist(vulcanEnvPath));
51
51
  throw error;
52
52
  }
53
53
  }
@@ -67,7 +67,7 @@ async function createVulcanEnv(variables, scope = 'global') {
67
67
  await fsPromises.writeFile(vulcanEnvPath, envData);
68
68
  } catch (error) {
69
69
  debug.error(error);
70
- feedback.error(Messages.errors.write_file_failed(vulcanEnvPath));
70
+ feedback.build.error(Messages.errors.write_file_failed(vulcanEnvPath));
71
71
  throw error;
72
72
  }
73
73
  }
@@ -124,7 +124,6 @@ async function readVulcanEnv(scope = 'local') {
124
124
  return null;
125
125
  }
126
126
  debug.error(error);
127
- feedback.error(Messages.errors.file_doesnt_exist(vulcanEnvPath));
128
127
  throw error;
129
128
  }
130
129
  }
@@ -139,11 +138,11 @@ function handleDependencyError(error, configPath) {
139
138
  if (error.code === 'ERR_MODULE_NOT_FOUND') {
140
139
  const missingPackage = error.message.match(/'([^']+)'/)?.[1];
141
140
  if (missingPackage) {
142
- feedback.error(
141
+ feedback.build.error(
143
142
  `Missing dependency: ${missingPackage}. Please install it using 'npm install ${missingPackage}' or 'yarn add ${missingPackage}'.`,
144
143
  );
145
144
  } else {
146
- feedback.error(
145
+ feedback.build.error(
147
146
  `A required dependency is missing. Please ensure all dependencies are installed.`,
148
147
  );
149
148
  }
@@ -220,10 +219,11 @@ async function loadAzionConfig(configPath) {
220
219
  configModule = await import(configPath);
221
220
  } catch (error) {
222
221
  if (error.code === 'ERR_REQUIRE_ESM') {
223
- throw error;
222
+ // eslint-disable-next-line import/no-dynamic-require
223
+ configModule = require(configPath); // Fallback to require for CommonJS
224
+ } else {
225
+ throw error; // Re-throw other errors
224
226
  }
225
- // eslint-disable-next-line import/no-dynamic-require
226
- configModule = require(configPath);
227
227
  }
228
228
  break;
229
229
  default:
@@ -236,8 +236,6 @@ async function loadAzionConfig(configPath) {
236
236
  handleDependencyError(error, configPath);
237
237
  return null;
238
238
  }
239
- debug.error(error);
240
- feedback.error(Messages.errors.file_doesnt_exist(configPath));
241
239
  throw error;
242
240
  }
243
241
  }
@@ -1,52 +1,10 @@
1
- import { defineConfig } from 'azion';
1
+ /**
2
+ * NOTE: We are gradually migrating all configurations to the Azion library
3
+ * through the azion/presets package (@https://github.com/aziontech/lib/tree/main/packages/presets).
4
+ * This helps standardize our setup and maintain consistency across projects.
5
+ */
2
6
 
3
- const config = defineConfig({
4
- build: {
5
- preset: {
6
- name: 'angular',
7
- },
8
- },
9
- origin: [
10
- {
11
- name: 'origin-storage-default',
12
- type: 'object_storage',
13
- },
14
- ],
15
- rules: {
16
- request: [
17
- {
18
- name: 'Set Storage Origin for All Requests',
19
- match: '^\\/',
20
- behavior: {
21
- setOrigin: {
22
- name: 'origin-storage-default',
23
- type: 'object_storage',
24
- },
25
- },
26
- },
27
-
28
- {
29
- name: 'Deliver Static Assets',
30
- match:
31
- '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$',
32
- behavior: {
33
- setOrigin: {
34
- name: 'origin-storage-default',
35
- type: 'object_storage',
36
- },
37
- deliver: true,
38
- },
39
- },
40
-
41
- {
42
- name: 'Redirect to index.html',
43
- match: '^\\/',
44
- behavior: {
45
- rewrite: `/index.html`,
46
- },
47
- },
48
- ],
49
- },
50
- });
7
+ import { Angular } from 'azion/presets';
51
8
 
9
+ const { config } = Angular;
52
10
  export default config;
@@ -1,57 +1,11 @@
1
- import { defineConfig } from 'azion';
1
+ /**
2
+ * NOTE: We are gradually migrating all configurations to the Azion library
3
+ * through the azion/presets package (@https://github.com/aziontech/lib/tree/main/packages/presets).
4
+ * This helps standardize our setup and maintain consistency across projects.
5
+ */
2
6
 
3
- const config = defineConfig({
4
- build: {
5
- preset: {
6
- name: 'astro',
7
- },
8
- },
9
- origin: [
10
- {
11
- name: 'origin-storage-default',
12
- type: 'object_storage',
13
- },
14
- ],
15
- rules: {
16
- request: [
17
- {
18
- name: 'Set Storage Origin for All Requests',
19
- match: '^\\/',
20
- behavior: {
21
- setOrigin: {
22
- name: 'origin-storage-default',
23
- type: 'object_storage',
24
- },
25
- },
26
- },
27
- {
28
- name: 'Deliver Static Assets',
29
- match:
30
- '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$',
31
- behavior: {
32
- setOrigin: {
33
- name: 'origin-storage-default',
34
- type: 'object_storage',
35
- },
36
- deliver: true,
37
- },
38
- },
39
- {
40
- name: 'Redirect to index.html',
41
- match: '.*/$',
42
- behavior: {
43
- rewrite: '${uri}index.html',
44
- },
45
- },
46
- {
47
- name: 'Redirect to index.html for Subpaths',
48
- match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*',
49
- behavior: {
50
- rewrite: '${uri}/index.html',
51
- },
52
- },
53
- ],
54
- },
55
- });
7
+ import { Astro } from 'azion/presets';
8
+
9
+ const { config } = Astro;
56
10
 
57
11
  export default config;
@@ -1,57 +1,11 @@
1
- import { defineConfig } from 'azion';
1
+ /**
2
+ * NOTE: We are gradually migrating all configurations to the Azion library
3
+ * through the azion/presets package (@https://github.com/aziontech/lib/tree/main/packages/presets).
4
+ * This helps standardize our setup and maintain consistency across projects.
5
+ */
2
6
 
3
- const config = defineConfig({
4
- build: {
5
- preset: {
6
- name: 'docusaurus',
7
- },
8
- },
9
- origin: [
10
- {
11
- name: 'origin-storage-default',
12
- type: 'object_storage',
13
- },
14
- ],
15
- rules: {
16
- request: [
17
- {
18
- name: 'Set Storage Origin for All Requests',
19
- match: '^\\/',
20
- behavior: {
21
- setOrigin: {
22
- name: 'origin-storage-default',
23
- type: 'object_storage',
24
- },
25
- },
26
- },
27
- {
28
- name: 'Deliver Static Assets',
29
- match:
30
- '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$',
31
- behavior: {
32
- setOrigin: {
33
- name: 'origin-storage-default',
34
- type: 'object_storage',
35
- },
36
- deliver: true,
37
- },
38
- },
39
- {
40
- name: 'Redirect to index.html',
41
- match: '.*/$',
42
- behavior: {
43
- rewrite: '${uri}index.html',
44
- },
45
- },
46
- {
47
- name: 'Redirect to index.html for Subpaths',
48
- match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*',
49
- behavior: {
50
- rewrite: '${uri}/index.html',
51
- },
52
- },
53
- ],
54
- },
55
- });
7
+ import { Docusaurus } from 'azion/presets';
8
+
9
+ const { config } = Docusaurus;
56
10
 
57
11
  export default config;
@@ -1,57 +1,11 @@
1
- import { defineConfig } from 'azion';
1
+ /**
2
+ * NOTE: We are gradually migrating all configurations to the Azion library
3
+ * through the azion/presets package (@https://github.com/aziontech/lib/tree/main/packages/presets).
4
+ * This helps standardize our setup and maintain consistency across projects.
5
+ */
2
6
 
3
- const config = defineConfig({
4
- build: {
5
- preset: {
6
- name: 'eleventy',
7
- },
8
- },
9
- origin: [
10
- {
11
- name: 'origin-storage-default',
12
- type: 'object_storage',
13
- },
14
- ],
15
- rules: {
16
- request: [
17
- {
18
- name: 'Set Storage Origin for All Requests',
19
- match: '^\\/',
20
- behavior: {
21
- setOrigin: {
22
- name: 'origin-storage-default',
23
- type: 'object_storage',
24
- },
25
- },
26
- },
27
- {
28
- name: 'Deliver Static Assets',
29
- match:
30
- '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$',
31
- behavior: {
32
- setOrigin: {
33
- name: 'origin-storage-default',
34
- type: 'object_storage',
35
- },
36
- deliver: true,
37
- },
38
- },
39
- {
40
- name: 'Redirect to index.html',
41
- match: '.*/$',
42
- behavior: {
43
- rewrite: '${uri}index.html',
44
- },
45
- },
46
- {
47
- name: 'Redirect to index.html for Subpaths',
48
- match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*',
49
- behavior: {
50
- rewrite: '${uri}/index.html',
51
- },
52
- },
53
- ],
54
- },
55
- });
7
+ import { Eleventy } from 'azion/presets';
8
+
9
+ const { config } = Eleventy;
56
10
 
57
11
  export default config;
@@ -1,24 +1,11 @@
1
- import { defineConfig } from 'azion';
1
+ /**
2
+ * NOTE: We are gradually migrating all configurations to the Azion library
3
+ * through the azion/presets package (@https://github.com/aziontech/lib/tree/main/packages/presets).
4
+ * This helps standardize our setup and maintain consistency across projects.
5
+ */
2
6
 
3
- const config = defineConfig({
4
- build: {
5
- preset: {
6
- name: 'emscripten',
7
- },
8
- },
9
- rules: {
10
- request: [
11
- {
12
- name: 'Execute Edge Function',
13
- match: '^\\/',
14
- behavior: {
15
- runFunction: {
16
- path: '.edge/worker.js',
17
- },
18
- },
19
- },
20
- ],
21
- },
22
- });
7
+ import { Emscripten } from 'azion/presets';
8
+
9
+ const { config } = Emscripten;
23
10
 
24
11
  export default config;
@@ -1,55 +1,11 @@
1
- import { defineConfig } from 'azion';
1
+ /**
2
+ * NOTE: We are gradually migrating all configurations to the Azion library
3
+ * through the azion/presets package (@https://github.com/aziontech/lib/tree/main/packages/presets).
4
+ * This helps standardize our setup and maintain consistency across projects.
5
+ */
2
6
 
3
- export default defineConfig({
4
- build: {
5
- preset: {
6
- name: 'gatsby',
7
- },
8
- },
9
- origin: [
10
- {
11
- name: 'origin-storage-default',
12
- type: 'object_storage',
13
- },
14
- ],
15
- rules: {
16
- request: [
17
- {
18
- name: 'Set Storage Origin for All Requests',
19
- match: '^\\/',
20
- behavior: {
21
- setOrigin: {
22
- name: 'origin-storage-default',
23
- type: 'object_storage',
24
- },
25
- },
26
- },
27
- {
28
- name: 'Deliver Static Assets',
29
- match:
30
- '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$',
31
- behavior: {
32
- setOrigin: {
33
- name: 'origin-storage-default',
34
- type: 'object_storage',
35
- },
36
- deliver: true,
37
- },
38
- },
39
- {
40
- name: 'Redirect to index.html',
41
- match: '.*/$',
42
- behavior: {
43
- rewrite: '${uri}index.html',
44
- },
45
- },
46
- {
47
- name: 'Redirect to index.html for Subpaths',
48
- match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*',
49
- behavior: {
50
- rewrite: '${uri}/index.html',
51
- },
52
- },
53
- ],
54
- },
55
- });
7
+ import { Gatsby } from 'azion/presets';
8
+
9
+ const { config } = Gatsby;
10
+
11
+ export default config;