edge-functions 2.2.0-stage.4 → 2.2.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/CHANGELOG.md CHANGED
@@ -1,3 +1,29 @@
1
+ ## [2.2.0](https://github.com/aziontech/vulcan/compare/v2.1.0...v2.2.0) (2023-12-14)
2
+
3
+
4
+ ### Features
5
+
6
+ * add routes priority validation in manifest ([662338c](https://github.com/aziontech/vulcan/commit/662338c2f567b6fbd3ae9aa7434170b2dbe86ce8))
7
+ * esbuild bundler improvements and changes ([5e668c4](https://github.com/aziontech/vulcan/commit/5e668c4c8c725de37102b776708a5641980842f4))
8
+ * generate manifest for presets (deliver or compute) ([83ab369](https://github.com/aziontech/vulcan/commit/83ab36941e1f0d38a932f97ef0b6507abc813090))
9
+ * generateManifest for next.js (compute) ([ea97252](https://github.com/aziontech/vulcan/commit/ea97252caf2ee3ceff51635c5136aa3df02cbb0e))
10
+ * generateManifest for next.js (compute) ([38f69a5](https://github.com/aziontech/vulcan/commit/38f69a58b746d8e11b838fda82c661ad12f04253))
11
+ * improvements bundlers ([d546697](https://github.com/aziontech/vulcan/commit/d546697154b61124b947fff347b494dc474b7c36))
12
+ * initial code for organizing polyfill plugins ([2212272](https://github.com/aziontech/vulcan/commit/22122729bbdf0155357142c7fcbebd612d0509e3))
13
+ * preset for emscripten ([8ada412](https://github.com/aziontech/vulcan/commit/8ada4128b2637bcb694c5bc120dc8bc92757b701))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * app routes filter in next static build ([bb9cbd3](https://github.com/aziontech/vulcan/commit/bb9cbd3f0789ad6b0ba0fccb549223f4e5647a7b))
19
+ * esbuild plugin initial options ([8c84baa](https://github.com/aziontech/vulcan/commit/8c84baa117ed84a67202284d34abb05857083ec2))
20
+ * generate manifest in wasm presets ([38e996f](https://github.com/aziontech/vulcan/commit/38e996fa07cb9769482e318741671acf4500c5bf))
21
+ * handle error when not using app dir format in next static build ([edae5c1](https://github.com/aziontech/vulcan/commit/edae5c1a13f25efaf61922d602ccfc8b71531b50))
22
+ * loop in fs polyfill when readdirSync and path / ([4c1e2d0](https://github.com/aziontech/vulcan/commit/4c1e2d0195eaf04bf86ce4995ac41c9e2de5c596))
23
+ * loop in fs polyfill when readdirSync and path / ([#197](https://github.com/aziontech/vulcan/issues/197)) ([bd56c75](https://github.com/aziontech/vulcan/commit/bd56c75d8e48dd8af7792710aa51f68d7f737521))
24
+ * prevent reference sharing in config ([98b8caa](https://github.com/aziontech/vulcan/commit/98b8caa526e554401aeec2afed2dd126b29994f0))
25
+ * set correct prebuild to app dir cases in next static ([d43c2d5](https://github.com/aziontech/vulcan/commit/d43c2d561fee9d6b68818fd6cbf66ceb685ab2bc))
26
+
1
27
  ## [2.2.0-stage.4](https://github.com/aziontech/vulcan/compare/v2.2.0-stage.3...v2.2.0-stage.4) (2023-12-13)
2
28
 
3
29
 
package/README.md CHANGED
@@ -149,7 +149,7 @@ Allows you to extend the capabilities of the chosen bundler (either `webpack` or
149
149
 
150
150
  ### Example Configuration
151
151
 
152
- For a Vue-based project:
152
+ For a Next/Faststore-based project:
153
153
 
154
154
  ```javascript
155
155
  module.exports = {
@@ -158,7 +158,7 @@ module.exports = {
158
158
  useNodePolyfills: true,
159
159
  useOwnWorker: false,
160
160
  preset: {
161
- name: 'vue',
161
+ name: 'next',
162
162
  mode: 'compute',
163
163
  },
164
164
  memoryFS: {
@@ -173,17 +173,19 @@ module.exports = {
173
173
 
174
174
  **Note:** Adapting `vulcan.config.js` to your setup allows a personalized development experience, catering to the specific needs of your JavaScript applications and frameworks.
175
175
 
176
- ## Wasm Notes
177
-
178
- To use wasm presets you need to install the necessary tools to build your code:
179
-
180
- - emscripten: [download](https://emscripten.org/docs/getting_started/downloads.html);
181
- - rustwasm: [wasm-bindgen-cli](https://crates.io/crates/wasm-bindgen-cli)
182
-
183
176
  ## Docs
184
177
 
185
178
  - [Overview](docs/overview.md)
186
179
  - [Presets](docs/presets.md)
180
+ - [Rust/Wasm example](examples/rust-wasm-yew-ssr/)
181
+ - [Emscripten/Wasm example](examples/emscripten-wasm/)
182
+
183
+ ## Wasm Notes
184
+
185
+ To use wasm presets you need to install the necessary tools to build your code:
186
+
187
+ - Emscripten: [emsdk](https://emscripten.org/docs/getting_started/downloads.html);
188
+ - Rust/Wasm: [wasm-bindgen-cli](https://crates.io/crates/wasm-bindgen-cli)
187
189
 
188
190
  ## Contributing
189
191
 
package/docs/presets.md CHANGED
@@ -59,37 +59,47 @@ https://github.com/aziontech/vulcan/assets/12740219/abb1b2cc-5f74-473d-b731-c0b7
59
59
 
60
60
  - **Deliver**: This mode should be used when you intend to use the worker only for routing requests and delivering static files that will be computed on the client side.
61
61
 
62
- 2. ## **Create the following files in your preset's folder:**
62
+ ## 2. **Create the following files in your preset's folder:**
63
63
 
64
- ## handler.js
64
+ ## handler.js
65
65
 
66
- This file contains the code that is executed within the worker in the edge function. Essentially, it is the code that runs directly on the edge. In the context of the `deliver` mode, this may simply act as a router. However, in cases where computation is needed, it can be designed to perform more complex tasks. Remember, the capabilities of your handler.js are dependent on your use case and the mode of operation you've chosen for your preset.
66
+ This file contains the code that is executed within the worker in the edge function. Essentially, it is the code that runs directly on the edge. In the context of the `deliver` mode, this may simply act as a router. However, in cases where computation is needed, it can be designed to perform more complex tasks. Remember, the capabilities of your handler.js are dependent on your use case and the mode of operation you've chosen for your preset.
67
67
 
68
- #### For the cases involving static (deliver) frameworks, here's what you can do:
68
+ #### For the cases involving static (deliver) frameworks, here's what you can do:
69
69
 
70
- - For Single Page Application (SPA) types:
71
- Consider copying the preset handler similar to Vue. This utilizes the `mountSPA` hook which sets up the routing for your SPA effectively.
72
- - For Static Site Generator (SSG) projects:
73
- If you have a project that generates multiple HTML files, take a look at how the Next.js project handles this. They use the `mountSSG` hook, which sets up static routing for all the generated HTML pages.
70
+ - For Single Page Application (SPA) types:
71
+ Consider copying the preset handler similar to Vue. This utilizes the `mountSPA` hook which sets up the routing for your SPA effectively.
72
+ - For Static Site Generator (SSG) projects:
73
+ If you have a project that generates multiple HTML files, take a look at how the Next.js project handles this. They use the `mountSSG` hook, which sets up static routing for all the generated HTML pages.
74
74
 
75
- **Note**: Remember, these are just examples and can serve as a starting point for your own custom preset. Adjust and extend them as necessary to fit your project's specific needs.
75
+ **Note**: Remember, these are just examples and can serve as a starting point for your own custom preset. Adjust and extend them as necessary to fit your project's specific needs.
76
76
 
77
- ## config.js
77
+ ## config.js
78
78
 
79
- This file serves as an extension to the edge build. It enables the inclusion of polyfills, plugins, or any other procedures that relate to the build process executed on the edge. Although it is editable, we strongly advise against making changes to this file unless absolutely necessary. It's designed to ensure optimal operation, and modifications should be undertaken with careful consideration.
79
+ This file serves as an extension to the edge build. It enables the inclusion of polyfills, plugins, or any other procedures that relate to the build process executed on the edge. Although it is editable, we strongly advise against making changes to this file unless absolutely necessary. It's designed to ensure optimal operation, and modifications should be undertaken with careful consideration.
80
80
 
81
- ## prebuild.js
81
+ ## prebuild.js
82
82
 
83
- In this file, you should adapt the native build process of your framework or library. Usually, in the case of _deliver_ presets, this file will be used to ensure that the generated static artifacts are placed in the _.edge/storage/_ directory.
83
+ In this file, you should adapt the native build process of your framework or library. Usually, in the case of _deliver_ presets, this file will be used to ensure that the generated static artifacts are placed in the _.edge/storage/_ directory.
84
84
 
85
- #### React (deliver) Example:
85
+ - `Manifest class` (singleton): you should use it to ensure that the preset is compatible with the Azion deployment system and other platforms:
86
86
 
87
- ![prebuild](https://github.com/aziontech/vulcan/assets/12740219/85adc374-220b-4003-8c3e-6ec5b06a483f)
87
+ First you must set all the application's routes, if it is all static you just need to follow the other examples; point ‘/’ to the storage folder (where we store the statics). At the end you call the **Manifest.generate()** method and it should create the manifest.json file inside the build folder (.edge).
88
+
89
+ Each routing can have 1 type:
90
+
91
+ - _‘Deliver’_ means that you must deliver that static file (or entire folder) to that route.
92
+ - _‘Compute’_ means that it should become an Edge Function and be computed. In other words, when the request receives that path it must execute the determined function.
93
+
94
+ #### React (deliver) Example:
95
+
96
+ ![carbon](https://github.com/aziontech/vulcan/assets/12740219/58787d77-8a6d-41f4-83f9-398718203012)
88
97
 
89
98
  **Note**: The use of `compute` type presets is still under development and does not have many examples available. We currently support build/import resolution for pure JavaScript code (or with polyfills), as shown in the `./examples/simple-js-esm` example.
90
99
 
91
- 3. ## **Test your preset:**
92
- After setting up your preset, you can test it using Vulcan's build command. Depending on the mode of your preset, run one of the following commands in your terminal:
100
+ ## 3. **Test your preset:**
101
+
102
+ After setting up your preset, you can test it using Vulcan's build command. Depending on the mode of your preset, run one of the following commands in your terminal:
93
103
 
94
104
  https://github.com/aziontech/vulcan/assets/12740219/7033d37a-30ee-4098-8fe5-bbfca536591d
95
105
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "edge-functions",
3
3
  "type": "module",
4
- "version": "2.2.0-stage.4",
4
+ "version": "2.2.0",
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": {