@netlify/edge-bundler 9.4.1 → 10.0.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/deno/lib/common.ts +2 -2
- package/deno/lib/stage2.test.ts +58 -0
- package/deno/lib/stage2.ts +1 -1
- package/deno/vendor/deno.land/x/dir@1.5.1/data_local_dir/mod.ts +34 -0
- package/deno/vendor/deno.land/x/{eszip@v0.40.0 → eszip@v0.55.2}/eszip_wasm.generated.js +136 -179
- package/deno/vendor/deno.land/x/eszip@v0.55.2/eszip_wasm_bg.wasm +0 -0
- package/deno/vendor/deno.land/x/wasmbuild@0.15.1/cache.ts +157 -0
- package/deno/vendor/deno.land/x/wasmbuild@0.15.1/loader.ts +126 -0
- package/dist/node/bootstrap.test.d.ts +1 -0
- package/dist/node/bootstrap.test.js +26 -0
- package/dist/node/bridge.d.ts +1 -1
- package/dist/node/bridge.js +1 -1
- package/dist/node/bundler.d.ts +2 -1
- package/dist/node/bundler.js +4 -5
- package/dist/node/bundler.test.js +51 -48
- package/dist/node/deno_config.d.ts +5 -0
- package/dist/node/deno_config.js +40 -0
- package/dist/node/deno_config.test.d.ts +1 -0
- package/dist/node/deno_config.test.js +37 -0
- package/dist/node/feature_flags.d.ts +2 -8
- package/dist/node/feature_flags.js +1 -4
- package/dist/node/formats/eszip.d.ts +1 -1
- package/dist/node/formats/eszip.js +2 -2
- package/dist/node/formats/javascript.js +1 -2
- package/dist/node/index.d.ts +1 -0
- package/dist/node/manifest.d.ts +6 -2
- package/dist/node/manifest.js +24 -20
- package/dist/node/manifest.test.js +46 -35
- package/dist/node/npm_dependencies.d.ts +3 -1
- package/dist/node/npm_dependencies.js +15 -10
- package/dist/node/npm_import_error.d.ts +2 -2
- package/dist/node/npm_import_error.js +5 -9
- package/dist/node/server/server.d.ts +2 -6
- package/dist/node/server/server.js +110 -16
- package/dist/node/server/server.test.js +50 -3
- package/dist/node/serving.test.d.ts +1 -0
- package/dist/node/serving.test.js +31 -0
- package/dist/node/utils/fs.d.ts +5 -0
- package/dist/node/utils/fs.js +12 -0
- package/dist/test/util.js +1 -1
- package/package.json +2 -2
- package/deno/vendor/deno.land/x/eszip@v0.40.0/eszip_wasm_bg.wasm +0 -0
- /package/deno/vendor/deno.land/x/{eszip@v0.40.0 → eszip@v0.55.2}/loader.ts +0 -0
- /package/deno/vendor/deno.land/x/{eszip@v0.40.0 → eszip@v0.55.2}/mod.ts +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile } from 'fs/promises';
|
|
2
2
|
import { join } from 'path';
|
|
3
|
+
import process from 'process';
|
|
3
4
|
import getPort from 'get-port';
|
|
4
5
|
import fetch from 'node-fetch';
|
|
5
6
|
import { v4 as uuidv4 } from 'uuid';
|
|
@@ -21,9 +22,6 @@ test('Starts a server and serves requests for edge functions', async () => {
|
|
|
21
22
|
importMapPaths,
|
|
22
23
|
port,
|
|
23
24
|
servePath,
|
|
24
|
-
featureFlags: {
|
|
25
|
-
edge_functions_npm_modules: true,
|
|
26
|
-
},
|
|
27
25
|
});
|
|
28
26
|
const functions = [
|
|
29
27
|
{
|
|
@@ -89,3 +87,52 @@ test('Starts a server and serves requests for edge functions', async () => {
|
|
|
89
87
|
const identidadeBarrelFile = await readFile(join(servePath, 'bundled-pt-committee__identidade.js'), 'utf-8');
|
|
90
88
|
expect(identidadeBarrelFile).toContain(`/// <reference types="${join('..', '..', 'node_modules', '@types', 'pt-committee__identidade', 'index.d.ts')}" />`);
|
|
91
89
|
});
|
|
90
|
+
test('Serves edge functions in a monorepo setup', async () => {
|
|
91
|
+
const rootPath = join(fixturesDir, 'monorepo_npm_module');
|
|
92
|
+
const basePath = join(rootPath, 'packages', 'frontend');
|
|
93
|
+
const paths = {
|
|
94
|
+
user: join(basePath, 'functions'),
|
|
95
|
+
};
|
|
96
|
+
const port = await getPort();
|
|
97
|
+
const importMapPaths = [join(basePath, 'import_map.json')];
|
|
98
|
+
const servePath = join(basePath, '.netlify', 'edge-functions-serve');
|
|
99
|
+
const server = await serve({
|
|
100
|
+
basePath,
|
|
101
|
+
bootstrapURL: 'https://edge.netlify.com/bootstrap/index-combined.ts',
|
|
102
|
+
importMapPaths,
|
|
103
|
+
port,
|
|
104
|
+
rootPath,
|
|
105
|
+
servePath,
|
|
106
|
+
});
|
|
107
|
+
const functions = [
|
|
108
|
+
{
|
|
109
|
+
name: 'func1',
|
|
110
|
+
path: join(paths.user, 'func1.ts'),
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
const options = {
|
|
114
|
+
getFunctionsConfig: true,
|
|
115
|
+
};
|
|
116
|
+
const { features, functionsConfig, graph, success, npmSpecifiersWithExtraneousFiles } = await server(functions, {
|
|
117
|
+
very_secret_secret: 'i love netlify',
|
|
118
|
+
}, options);
|
|
119
|
+
expect(features).toEqual({ npmModules: true });
|
|
120
|
+
expect(success).toBe(true);
|
|
121
|
+
expect(functionsConfig).toEqual([{ path: '/func1' }]);
|
|
122
|
+
expect(npmSpecifiersWithExtraneousFiles).toEqual(['child-1']);
|
|
123
|
+
for (const key in functions) {
|
|
124
|
+
const graphEntry = graph === null || graph === void 0 ? void 0 : graph.modules.some(
|
|
125
|
+
// @ts-expect-error TODO: Module graph is currently not typed
|
|
126
|
+
({ kind, mediaType, local }) => kind === 'esm' && mediaType === 'TypeScript' && local === functions[key].path);
|
|
127
|
+
expect(graphEntry).toBe(true);
|
|
128
|
+
}
|
|
129
|
+
const response1 = await fetch(`http://0.0.0.0:${port}/func1`, {
|
|
130
|
+
headers: {
|
|
131
|
+
'x-nf-edge-functions': 'func1',
|
|
132
|
+
'x-ef-passthrough': 'passthrough',
|
|
133
|
+
'X-NF-Request-ID': uuidv4(),
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
expect(response1.status).toBe(200);
|
|
137
|
+
expect(await response1.text()).toBe(`<parent-1><child-1>JavaScript</child-1></parent-1>, <parent-2><child-2><grandchild-1>APIs<cwd>${process.cwd()}</cwd></grandchild-1></child-2></parent-2>, <parent-3><child-2><grandchild-1>Markup<cwd>${process.cwd()}</cwd></grandchild-1></child-2></parent-3>`);
|
|
138
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import getPort from 'get-port';
|
|
3
|
+
import fetch from 'node-fetch';
|
|
4
|
+
import { test, expect } from 'vitest';
|
|
5
|
+
import { fixturesDir } from '../test/util.js';
|
|
6
|
+
import { serve } from './index.js';
|
|
7
|
+
test('bundler serving functionality', async () => {
|
|
8
|
+
const port = await getPort();
|
|
9
|
+
const server = await serve({
|
|
10
|
+
port,
|
|
11
|
+
});
|
|
12
|
+
const { success } = await server([
|
|
13
|
+
{
|
|
14
|
+
name: 'echo_env',
|
|
15
|
+
path: join(fixturesDir, 'serve_test', 'echo_env.ts'),
|
|
16
|
+
},
|
|
17
|
+
], {
|
|
18
|
+
very_secret_secret: 'i love netlify',
|
|
19
|
+
});
|
|
20
|
+
expect(success).toBe(true);
|
|
21
|
+
const response = await fetch(`http://0.0.0.0:${port}/foo`, {
|
|
22
|
+
headers: {
|
|
23
|
+
'x-deno-functions': 'echo_env',
|
|
24
|
+
'x-deno-pass': 'passthrough',
|
|
25
|
+
'X-NF-Request-ID': 'foo',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
expect(response.status).toBe(200);
|
|
29
|
+
const body = (await response.json());
|
|
30
|
+
expect(body.very_secret_secret).toBe('i love netlify');
|
|
31
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
/**
|
|
3
|
+
* Returns all the directories obtained by traversing `inner` and its parents
|
|
4
|
+
* all the way to `outer`, inclusive.
|
|
5
|
+
*/
|
|
6
|
+
export const pathsBetween = (inner, outer, paths = []) => {
|
|
7
|
+
const parent = path.dirname(inner);
|
|
8
|
+
if (inner === outer || inner === parent) {
|
|
9
|
+
return [...paths, outer];
|
|
10
|
+
}
|
|
11
|
+
return [inner, ...pathsBetween(parent, outer)];
|
|
12
|
+
};
|
package/dist/test/util.js
CHANGED
|
@@ -55,7 +55,7 @@ const runESZIP = async (eszipPath, vendorDirectory) => {
|
|
|
55
55
|
const extractCommand = execa('deno', [
|
|
56
56
|
'run',
|
|
57
57
|
'--allow-all',
|
|
58
|
-
'https://deno.land/x/eszip@v0.
|
|
58
|
+
'https://deno.land/x/eszip@v0.55.2/eszip.ts',
|
|
59
59
|
'x',
|
|
60
60
|
eszipPath,
|
|
61
61
|
tmpDir.path,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Intelligently prepare Netlify Edge Functions for deployment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.js",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"better-ajv-errors": "^1.2.0",
|
|
81
81
|
"common-path-prefix": "^3.0.0",
|
|
82
82
|
"env-paths": "^3.0.0",
|
|
83
|
-
"esbuild": "0.19.
|
|
83
|
+
"esbuild": "0.19.5",
|
|
84
84
|
"execa": "^6.0.0",
|
|
85
85
|
"find-up": "^6.3.0",
|
|
86
86
|
"get-package-name": "^2.2.0",
|
|
Binary file
|
|
File without changes
|
|
File without changes
|