edge-functions 2.2.0-stage.3 → 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,36 @@
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
+
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)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * app routes filter in next static build ([bb9cbd3](https://github.com/aziontech/vulcan/commit/bb9cbd3f0789ad6b0ba0fccb549223f4e5647a7b))
33
+
1
34
  ## [2.2.0-stage.3](https://github.com/aziontech/vulcan/compare/v2.2.0-stage.2...v2.2.0-stage.3) (2023-12-13)
2
35
 
3
36
 
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
 
@@ -80,7 +80,7 @@ export default function myWorker(event: FetchEvent): Response {
80
80
  },
81
81
  Angular: async (projectName, version = FrameworksDefaultVersions.Angular) => {
82
82
  await exec(
83
- `npx @angular/cli@${version} new ${projectName}`,
83
+ `npx --yes @angular/cli@${version} new ${projectName}`,
84
84
  'Angular',
85
85
  false,
86
86
  true,
@@ -88,18 +88,23 @@ export default function myWorker(event: FetchEvent): Response {
88
88
  },
89
89
  Astro: async (projectName, version = FrameworksDefaultVersions.Astro) => {
90
90
  await exec(
91
- `npx create-astro@${version} ${projectName}`,
91
+ `npx --yes create-astro@${version} ${projectName}`,
92
92
  'Astro',
93
93
  false,
94
94
  true,
95
95
  );
96
96
  },
97
97
  Hexo: async (projectName, version = FrameworksDefaultVersions.Hexo) => {
98
- await exec(`npx hexo@${version} init ${projectName}`, 'Hexo', false, true);
98
+ await exec(
99
+ `npx --yes hexo@${version} init ${projectName}`,
100
+ 'Hexo',
101
+ false,
102
+ true,
103
+ );
99
104
  },
100
105
  Next: async (projectName, version = FrameworksDefaultVersions.Next) => {
101
106
  await exec(
102
- `npx create-next-app@${version} ${projectName} && cd ${projectName} && npm i next@${version}`,
107
+ `npx --yes create-next-app@${version} ${projectName} && cd ${projectName} && npm i next@${version}`,
103
108
  'Next',
104
109
  false,
105
110
  true,
@@ -107,7 +112,7 @@ export default function myWorker(event: FetchEvent): Response {
107
112
  },
108
113
  React: async (projectName, version = FrameworksDefaultVersions.React) => {
109
114
  await exec(
110
- `npx create-react-app@${version} ${projectName}`,
115
+ `npx --yes create-react-app@${version} ${projectName}`,
111
116
  'React',
112
117
  false,
113
118
  true,
@@ -115,7 +120,7 @@ export default function myWorker(event: FetchEvent): Response {
115
120
  },
116
121
  Vue: async (projectName, version = FrameworksDefaultVersions.Vue) => {
117
122
  await exec(
118
- `npx @vue/cli@${version} create ${projectName}`,
123
+ `npx --yes @vue/cli@${version} create ${projectName}`,
119
124
  'Vue',
120
125
  false,
121
126
  true,
@@ -123,7 +128,7 @@ export default function myWorker(event: FetchEvent): Response {
123
128
  },
124
129
  Vite: async (projectName, version = FrameworksDefaultVersions.Vite) => {
125
130
  await exec(
126
- `npx create-vue@${version} ${projectName}`,
131
+ `npx --yes create-vue@${version} ${projectName}`,
127
132
  'Vue/Vite',
128
133
  false,
129
134
  true,
@@ -120,11 +120,12 @@ async function fixAppDirRoutes() {
120
120
  return;
121
121
  }
122
122
 
123
- const appPaths = Object.values(appPathRoutesManifest);
123
+ const appPagesPaths = Object.keys(appPathRoutesManifest)
124
+ .filter((pathKey) => pathKey.match(/page/))
125
+ .map((key) => appPathRoutesManifest[key]);
124
126
 
125
- const pathsToCopy = appPaths.filter(
126
- (path) =>
127
- !dynamicRoutes.includes(path) && path !== '/' && path !== '/favicon.ico',
127
+ const pathsToCopy = appPagesPaths.filter(
128
+ (path) => !dynamicRoutes.includes(path) && path !== '/',
128
129
  );
129
130
 
130
131
  // fix _next calls in client (static routes in app dir format)
@@ -14,9 +14,11 @@ describe('getPresetsList utils', () => {
14
14
  'typescript',
15
15
  'angular',
16
16
  'astro',
17
+ 'emscripten',
17
18
  'hexo',
18
19
  'next',
19
20
  'react',
21
+ 'rustwasm',
20
22
  'vue',
21
23
  ];
22
24
 
@@ -77,10 +79,12 @@ describe('getPresetsList utils', () => {
77
79
  'Typescript (Compute)',
78
80
  'Angular (Deliver)',
79
81
  'Astro (Deliver)',
82
+ 'Emscripten (Compute)',
80
83
  'Hexo (Deliver)',
81
84
  'Next (Compute)',
82
85
  'Next (Deliver)',
83
86
  'React (Deliver)',
87
+ 'Rustwasm (Compute)',
84
88
  'Vue (Deliver)',
85
89
  ];
86
90
  const beautifiedResults = presets.getBeautify();
@@ -94,9 +98,11 @@ describe('getPresetsList utils', () => {
94
98
  'typescript',
95
99
  'angular',
96
100
  'astro',
101
+ 'emscripten',
97
102
  'hexo',
98
103
  'next',
99
104
  'react',
105
+ 'rustwasm',
100
106
  'vue',
101
107
  ];
102
108
  const expectedOutput = [
@@ -105,9 +111,11 @@ describe('getPresetsList utils', () => {
105
111
  ['Compute'],
106
112
  ['Deliver'],
107
113
  ['Deliver'],
114
+ ['Compute'],
108
115
  ['Deliver'],
109
116
  ['Compute', 'Deliver'],
110
117
  ['Deliver'],
118
+ ['Compute'],
111
119
  ['Deliver'],
112
120
  ];
113
121
 
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.3",
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": {
@@ -15,7 +15,7 @@
15
15
  "lint": "eslint .",
16
16
  "lint:fix": "eslint --fix .",
17
17
  "format": "prettier --write .",
18
- "test": "jest --clearCache && jest -c jest.config.unit.js lib/",
18
+ "test": "jest --clearCache && jest lib/",
19
19
  "test:watch": "jest lib/ --watch",
20
20
  "test:coverage": "jest --clearCache && jest lib/ --coverage",
21
21
  "format:check": "prettier . --check",
@@ -23,7 +23,7 @@
23
23
  "e2e:start": "tests/scripts/start-e2e-env.sh",
24
24
  "e2e:stop": "tests/scripts/stop-e2e-env.sh",
25
25
  "e2e:destroy": "tests/scripts/destroy-e2e-env.sh",
26
- "test:e2e": "yarn e2e:start && jest -c jest.config.e2e.js --maxWorkers 1 tests/e2e/ && yarn e2e:stop",
26
+ "test:e2e": "yarn e2e:start && jest --maxWorkers 1 tests/e2e/ && yarn e2e:stop",
27
27
  "prepare": "husky install"
28
28
  },
29
29
  "author": "aziontech",
@@ -38,15 +38,14 @@
38
38
  ],
39
39
  "license": "MIT",
40
40
  "dependencies": {
41
- "@angular/cli": "^16.2.0",
42
- "@babel/generator": "^7.23.0",
43
- "@babel/parser": "^7.23.0",
44
- "@babel/traverse": "^7.23.0",
45
- "@babel/types": "^7.23.0",
41
+ "@babel/generator": "^7.23.5",
42
+ "@babel/parser": "^7.23.5",
43
+ "@babel/traverse": "^7.23.5",
44
+ "@babel/types": "^7.23.5",
46
45
  "@edge-runtime/node-utils": "^2.1.1",
47
46
  "@edge-runtime/primitives": "^3.0.4",
48
- "@fastly/http-compute-js": "^1.0.0",
49
- "@vue/cli": "^5.0.8",
47
+ "@fastly/http-compute-js": "^1.1.2",
48
+ "accepts": "^1.3.8",
50
49
  "assert": "^2.0.0",
51
50
  "bottleneck": "^2.19.5",
52
51
  "browserify-zlib": "^0.2.0",
@@ -55,10 +54,6 @@
55
54
  "chokidar": "^3.5.3",
56
55
  "commander": "^10.0.1",
57
56
  "console-browserify": "^1.2.0",
58
- "create-astro": "^3.2.2",
59
- "create-next-app": "^13.4.19",
60
- "create-react-app": "^5.0.1",
61
- "create-vue": "^3.7.3",
62
57
  "crypto-browserify": "^3.12.0",
63
58
  "deepmerge": "^4.3.1",
64
59
  "edge-runtime": "^2.4.5",
@@ -67,7 +62,6 @@
67
62
  "events": "^3.3.0",
68
63
  "fast-glob": "^3.3.1",
69
64
  "form-data": "^4.0.0",
70
- "hexo": "^7.0.0-rc2",
71
65
  "https-browserify": "^1.0.0",
72
66
  "inquirer": "^9.2.7",
73
67
  "install": "^0.13.0",
@@ -75,14 +69,12 @@
75
69
  "lodash.merge": "^4.6.2",
76
70
  "log-update": "^5.0.1",
77
71
  "mime-types": "^2.1.35",
78
- "npm": "^9.8.0",
79
72
  "os-browserify": "^0.3.0",
80
73
  "path-browserify": "^1.0.1",
81
74
  "pkg-dir": "^7.0.0",
82
75
  "process": "^0.11.10",
83
76
  "querystring-es3": "^0.2.1",
84
77
  "readable-stream": "^4.4.2",
85
- "rollup-plugin-node-polyfills": "^0.2.1",
86
78
  "semantic-release": "^21.0.7",
87
79
  "semver": "^7.5.2",
88
80
  "signale": "^1.4.0",
@@ -99,8 +91,6 @@
99
91
  "webpack-merge": "^5.9.0"
100
92
  },
101
93
  "devDependencies": {
102
- "@babel/core": "^7.22.5",
103
- "@babel/preset-env": "^7.22.5",
104
94
  "@commitlint/cli": "^18.4.1",
105
95
  "@commitlint/config-conventional": "^18.4.0",
106
96
  "@jest/globals": "^29.5.0",
@@ -111,8 +101,6 @@
111
101
  "@semantic-release/release-notes-generator": "^11.0.4",
112
102
  "@swc/core": "^1.3.96",
113
103
  "@swc/jest": "^0.2.29",
114
- "babel-jest": "^29.5.0",
115
- "babel-plugin-transform-import-meta": "^2.2.0",
116
104
  "clean-jsdoc-theme": "^4.2.9",
117
105
  "conventional-changelog-conventionalcommits": "^4.6.0",
118
106
  "eslint": "^8.49.0",
@@ -133,9 +121,6 @@
133
121
  "supertest": "^6.3.3",
134
122
  "tmp": "^0.2.1"
135
123
  },
136
- "resolutions": {
137
- "@babel/types": "7.22.17"
138
- },
139
124
  "imports": {
140
125
  "#root/*": "./",
141
126
  "#lib/*": "./lib",
@@ -1,8 +0,0 @@
1
- export default {
2
- transform: {
3
- '^.+\\.(js|jsx)?$': 'babel-jest',
4
- },
5
- testPathIgnorePatterns: ['/node_modules/', '/examples/'],
6
- testEnvironment: 'node',
7
- globalSetup: '<rootDir>/jest.global.setup.js',
8
- };
@@ -1,7 +0,0 @@
1
- export default {
2
- transform: {
3
- '^.+\\.(t|j)s?$': '@swc/jest',
4
- },
5
- testPathIgnorePatterns: ['/node_modules/', '/examples/'],
6
- testEnvironment: 'node',
7
- };