edge-functions 4.2.1-stage.2 → 4.2.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 +16 -0
- package/README.md +5 -2
- package/lib/build/bundlers/esbuild/esbuild.config.js +37 -2
- package/lib/build/bundlers/webpack/webpack.config.js +50 -1
- package/lib/build/dispatcher/dispatcher.js +11 -3
- package/lib/commands/dev.commands.js +10 -1
- package/lib/env/server.env.js +3 -2
- package/lib/main.js +7 -2
- package/lib/presets/next/postbuild.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
### [4.2.1](https://github.com/aziontech/bundler/compare/v4.2.0...v4.2.1) (2024-10-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* incorrect file extension in build command ([#404](https://github.com/aziontech/bundler/issues/404)) ([70bfb14](https://github.com/aziontech/bundler/commit/70bfb1464b898ed65054e8345b9b01f680c60901))
|
|
7
|
+
* removing the need to pass the preset flag when js ([#402](https://github.com/aziontech/bundler/issues/402)) ([3f3074c](https://github.com/aziontech/bundler/commit/3f3074cee0255c75daa5420356e2cb10c97725e7))
|
|
8
|
+
* use dedicated worker for dev env ([#403](https://github.com/aziontech/bundler/issues/403)) ([96aa489](https://github.com/aziontech/bundler/commit/96aa4899c15012906f6b9d023a4661062240d3cd))
|
|
9
|
+
|
|
10
|
+
### [4.2.1-stage.3](https://github.com/aziontech/bundler/compare/v4.2.1-stage.2...v4.2.1-stage.3) (2024-10-23)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* use dedicated worker for dev env ([#403](https://github.com/aziontech/bundler/issues/403)) ([96aa489](https://github.com/aziontech/bundler/commit/96aa4899c15012906f6b9d023a4661062240d3cd))
|
|
16
|
+
|
|
1
17
|
### [4.2.1-stage.2](https://github.com/aziontech/bundler/compare/v4.2.1-stage.1...v4.2.1-stage.2) (2024-10-23)
|
|
2
18
|
|
|
3
19
|
|
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ E2E tests run daily in the [Vulcan Examples](https://github.com/aziontech/vulcan
|
|
|
11
11
|
Table:
|
|
12
12
|
| Test | Status |
|
|
13
13
|
| ------------------------------------ | ------ |
|
|
14
|
+
| Next 14 2 15 Middleware | ✅ |
|
|
14
15
|
| Next 13 5 6 I18n | ✅ |
|
|
15
16
|
| Next 12 3 4 I18n | ✅ |
|
|
16
17
|
| Hexo Static | ✅ |
|
|
@@ -22,7 +23,7 @@ Table:
|
|
|
22
23
|
| Next Static | ✅ |
|
|
23
24
|
| Gatsby Static | ✅ |
|
|
24
25
|
| Next Node Pages 12 3 1 Fs | ✅ |
|
|
25
|
-
| Vue Vite Static |
|
|
26
|
+
| Vue Vite Static | ⚠️ |
|
|
26
27
|
| Next 12 Static | ✅ |
|
|
27
28
|
| Astro Static | ✅ |
|
|
28
29
|
| Simple Js Env Vars | ✅ |
|
|
@@ -32,6 +33,7 @@ Table:
|
|
|
32
33
|
| Simple Js Network List | ✅ |
|
|
33
34
|
| Svelte Static | ✅ |
|
|
34
35
|
| Vitepress Static | ✅ |
|
|
36
|
+
| Nuxt Static | ✅ |
|
|
35
37
|
| Docusaurus Static | ✅ |
|
|
36
38
|
| Simple Js Firewall Event | ✅ |
|
|
37
39
|
| Simple Js Network List With Firewall | ✅ |
|
|
@@ -41,7 +43,8 @@ Table:
|
|
|
41
43
|
| Simple Ts Esm | ✅ |
|
|
42
44
|
| Simple Js Esm | ✅ |
|
|
43
45
|
|
|
44
|
-
Last test run date: 10/
|
|
46
|
+
Last test run date: 10/28/24 03:41:17 AM
|
|
47
|
+
|
|
45
48
|
## Quick Installation
|
|
46
49
|
|
|
47
50
|
For those who just want to use Azion Bundler in their project without contributing to the development, you can install it directly from npm.
|
|
@@ -7,9 +7,41 @@ const outputPath = isWindows
|
|
|
7
7
|
? fileURLToPath(new URL(`file:///${join(projectRoot, '.edge')}`))
|
|
8
8
|
: join(projectRoot, '.edge');
|
|
9
9
|
|
|
10
|
+
const isDev = !globalThis.vulcan?.buildProd;
|
|
11
|
+
|
|
12
|
+
const azionCliBanner = `
|
|
13
|
+
/**
|
|
14
|
+
* Built with Azion CLI
|
|
15
|
+
* For more information, visit: https://www.azion.com/en/documentation/products/cli/
|
|
16
|
+
*/
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const devBannerComment = `
|
|
20
|
+
/**
|
|
21
|
+
* WARNING: DEVELOPMENT BUILD
|
|
22
|
+
*
|
|
23
|
+
* This file is a development build and contains additional injected code
|
|
24
|
+
* to facilitate the development and debugging process.
|
|
25
|
+
*
|
|
26
|
+
* IMPORTANT NOTICES:
|
|
27
|
+
* - DO NOT use this build in a production environment.
|
|
28
|
+
* - The injected code may cause unexpected behaviors in production.
|
|
29
|
+
* - Performance of this build is not optimized for production use.
|
|
30
|
+
* - This build may include sensitive debugging information.
|
|
31
|
+
*
|
|
32
|
+
* To generate an optimized and secure production build use 'azion build'.
|
|
33
|
+
*
|
|
34
|
+
* If you are seeing this message in a production environment, stop immediately
|
|
35
|
+
* and replace this file with a proper production build.
|
|
36
|
+
*
|
|
37
|
+
* For any issues or questions, please refer to the documentation or contact
|
|
38
|
+
* the development team.
|
|
39
|
+
*/
|
|
40
|
+
`;
|
|
41
|
+
|
|
10
42
|
export default {
|
|
11
43
|
bundle: true,
|
|
12
|
-
minify:
|
|
44
|
+
minify: !isDev,
|
|
13
45
|
target: 'es2022',
|
|
14
46
|
format: 'esm',
|
|
15
47
|
platform: 'browser',
|
|
@@ -17,5 +49,8 @@ export default {
|
|
|
17
49
|
loader: {
|
|
18
50
|
'.js': 'jsx',
|
|
19
51
|
},
|
|
20
|
-
outfile: join(outputPath, 'worker.js'),
|
|
52
|
+
outfile: join(outputPath, isDev ? 'worker.dev.js' : 'worker.js'),
|
|
53
|
+
banner: {
|
|
54
|
+
js: isDev ? azionCliBanner + devBannerComment : azionCliBanner,
|
|
55
|
+
},
|
|
21
56
|
};
|
|
@@ -4,6 +4,8 @@ import { fileURLToPath } from 'url';
|
|
|
4
4
|
import { createRequire } from 'module';
|
|
5
5
|
import fs from 'fs';
|
|
6
6
|
|
|
7
|
+
const isDev = !globalThis.vulcan?.buildProd;
|
|
8
|
+
|
|
7
9
|
const require = createRequire(import.meta.url);
|
|
8
10
|
|
|
9
11
|
const projectRoot = process.cwd();
|
|
@@ -50,13 +52,43 @@ const defineLoaderTypescriptRules = () => {
|
|
|
50
52
|
return { module: {} };
|
|
51
53
|
};
|
|
52
54
|
|
|
55
|
+
const azionCliBanner = `
|
|
56
|
+
/**
|
|
57
|
+
* Built with Azion CLI
|
|
58
|
+
* For more information, visit: https://www.azion.com/en/documentation/products/cli/
|
|
59
|
+
*/
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
const devBannerComment = `
|
|
63
|
+
/**
|
|
64
|
+
* WARNING: DEVELOPMENT BUILD
|
|
65
|
+
*
|
|
66
|
+
* This file is a development build and contains additional injected code
|
|
67
|
+
* to facilitate the development and debugging process.
|
|
68
|
+
*
|
|
69
|
+
* IMPORTANT NOTICES:
|
|
70
|
+
* - DO NOT use this build in a production environment.
|
|
71
|
+
* - The injected code may cause unexpected behaviors in production.
|
|
72
|
+
* - Performance of this build is not optimized for production use.
|
|
73
|
+
* - This build may include sensitive debugging information.
|
|
74
|
+
*
|
|
75
|
+
* To generate an optimized and secure production build use 'azion build'.
|
|
76
|
+
*
|
|
77
|
+
* If you are seeing this message in a production environment, stop immediately
|
|
78
|
+
* and replace this file with a proper production build.
|
|
79
|
+
*
|
|
80
|
+
* For any issues or questions, please refer to the documentation or contact
|
|
81
|
+
* the development team.
|
|
82
|
+
*/
|
|
83
|
+
`;
|
|
84
|
+
|
|
53
85
|
export default {
|
|
54
86
|
experiments: {
|
|
55
87
|
outputModule: true,
|
|
56
88
|
},
|
|
57
89
|
output: {
|
|
58
90
|
path: outputPath,
|
|
59
|
-
filename: 'worker.js',
|
|
91
|
+
filename: isDev ? 'worker.dev.js' : 'worker.js',
|
|
60
92
|
globalObject: 'globalThis',
|
|
61
93
|
},
|
|
62
94
|
resolve: {
|
|
@@ -72,5 +104,22 @@ export default {
|
|
|
72
104
|
new webpack.optimize.LimitChunkCountPlugin({
|
|
73
105
|
maxChunks: 1,
|
|
74
106
|
}),
|
|
107
|
+
new webpack.BannerPlugin({
|
|
108
|
+
banner: azionCliBanner,
|
|
109
|
+
raw: true,
|
|
110
|
+
entryOnly: true,
|
|
111
|
+
}),
|
|
112
|
+
...(isDev
|
|
113
|
+
? [
|
|
114
|
+
new webpack.BannerPlugin({
|
|
115
|
+
banner: devBannerComment,
|
|
116
|
+
raw: true,
|
|
117
|
+
entryOnly: true,
|
|
118
|
+
}),
|
|
119
|
+
]
|
|
120
|
+
: []),
|
|
75
121
|
],
|
|
122
|
+
optimization: {
|
|
123
|
+
minimize: !isDev,
|
|
124
|
+
},
|
|
76
125
|
};
|
|
@@ -304,6 +304,9 @@ class Dispatcher {
|
|
|
304
304
|
const tempBuilderEntryPath = join(currentDir, tempEntryFile);
|
|
305
305
|
|
|
306
306
|
buildConfig.entry = tempBuilderEntryPath;
|
|
307
|
+
buildConfig.output = globalThis.vulcan?.buildProd
|
|
308
|
+
? '.edge/worker.js'
|
|
309
|
+
: '.edge/worker.dev.js';
|
|
307
310
|
|
|
308
311
|
return buildConfig;
|
|
309
312
|
}
|
|
@@ -520,14 +523,19 @@ class Dispatcher {
|
|
|
520
523
|
|
|
521
524
|
// fs temp solution for hybrid implementation (polyfill + runtime)
|
|
522
525
|
if (this.polyfills) {
|
|
523
|
-
const
|
|
524
|
-
const
|
|
526
|
+
const edgeDir = join(process.cwd(), '.edge');
|
|
527
|
+
const outPath = globalThis.vulcan.buildProd
|
|
528
|
+
? 'worker.js'
|
|
529
|
+
: 'worker.dev.js';
|
|
530
|
+
const workerPath = join(edgeDir, outPath);
|
|
531
|
+
|
|
532
|
+
const content = readFileSync(workerPath, 'utf-8');
|
|
525
533
|
let codeToAdd = '';
|
|
526
534
|
if (globalThis.vulcan.buildProd) {
|
|
527
535
|
codeToAdd = 'import SRC_NODE_FS from "node:fs";\n';
|
|
528
536
|
}
|
|
529
537
|
const newContent = `${codeToAdd}${content}`;
|
|
530
|
-
writeFileSync(
|
|
538
|
+
writeFileSync(workerPath, newContent);
|
|
531
539
|
}
|
|
532
540
|
}
|
|
533
541
|
// manifest
|
|
@@ -22,7 +22,16 @@ import { Commands } from '#namespaces';
|
|
|
22
22
|
async function devCommand(entry, { firewall, port }) {
|
|
23
23
|
const parsedPort = parseInt(port, 10);
|
|
24
24
|
const { server } = await import('#env');
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
const edgeDir = join(process.cwd(), '.edge');
|
|
27
|
+
const devWorkerPath = join(edgeDir, 'worker.dev.js');
|
|
28
|
+
|
|
29
|
+
let entryPoint = entry;
|
|
30
|
+
|
|
31
|
+
if (!entryPoint) {
|
|
32
|
+
entryPoint = devWorkerPath;
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
server(entryPoint, firewall, parsedPort);
|
|
27
36
|
}
|
|
28
37
|
|
package/lib/env/server.env.js
CHANGED
|
@@ -131,7 +131,8 @@ async function manageServer(workerPath, port, isFirewall) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
} catch (error) {
|
|
134
|
-
|
|
134
|
+
feedback.server.error(error);
|
|
135
|
+
console.log(error);
|
|
135
136
|
process.exit(1);
|
|
136
137
|
} finally {
|
|
137
138
|
isChangeHandlerRunning = false;
|
|
@@ -184,7 +185,7 @@ async function startServer(workerPath, isFirewall, port) {
|
|
|
184
185
|
);
|
|
185
186
|
process.exit(1);
|
|
186
187
|
}
|
|
187
|
-
await manageServer(workerPath, port, isFirewall);
|
|
188
|
+
await manageServer(workerPath, port, isFirewall);
|
|
188
189
|
|
|
189
190
|
const watcher = chokidar.watch('./', {
|
|
190
191
|
persistent: true,
|
package/lib/main.js
CHANGED
|
@@ -199,7 +199,10 @@ function startVulcanProgram() {
|
|
|
199
199
|
program
|
|
200
200
|
.command('dev')
|
|
201
201
|
.description('Start local environment')
|
|
202
|
-
.
|
|
202
|
+
.argument(
|
|
203
|
+
'[entry]',
|
|
204
|
+
'Specify the entry file (default: .edge/worker.dev.js)',
|
|
205
|
+
)
|
|
203
206
|
.option('-p, --port <port>', 'Specify the port', '3333')
|
|
204
207
|
.option(
|
|
205
208
|
'--firewall',
|
|
@@ -207,8 +210,10 @@ function startVulcanProgram() {
|
|
|
207
210
|
false,
|
|
208
211
|
)
|
|
209
212
|
.action(async (entry, options) => {
|
|
213
|
+
globalThis.vulcan.buildProd = false;
|
|
210
214
|
const { devCommand } = await import('#commands');
|
|
211
|
-
|
|
215
|
+
const convertedOptions = convertOptions(options);
|
|
216
|
+
await devCommand(entry, convertedOptions);
|
|
212
217
|
});
|
|
213
218
|
|
|
214
219
|
program
|
|
@@ -15,7 +15,7 @@ async function postbuild(buildConfig) {
|
|
|
15
15
|
// TODO: This hack is not good. We should replace this with something less brittle ASAP
|
|
16
16
|
// https://github.com/vercel/next.js/blob/2e7dfca362931be99e34eccec36074ab4a46ffba/packages/next/src/server/web/adapter.ts#L276-L282
|
|
17
17
|
{
|
|
18
|
-
file:
|
|
18
|
+
file: buildConfig.output,
|
|
19
19
|
pattern:
|
|
20
20
|
/Object\.defineProperty\(\s*globalThis\s*,\s*"__import_unsupported"[\s\S]*?,\s*configurable\s*:\s*[^}]*\}\)/gm,
|
|
21
21
|
replacement: 'true',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-functions",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.2.1
|
|
4
|
+
"version": "4.2.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": {
|