@netlify/edge-bundler 10.1.3 → 11.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.
|
@@ -12,6 +12,7 @@ import type { ModuleGraphJson } from '../vendor/module_graph/module_graph.js';
|
|
|
12
12
|
export type FormatFunction = (name: string) => string;
|
|
13
13
|
interface StartServerOptions {
|
|
14
14
|
getFunctionsConfig?: boolean;
|
|
15
|
+
importMapPaths?: string[];
|
|
15
16
|
}
|
|
16
17
|
interface InspectSettings {
|
|
17
18
|
enabled: boolean;
|
|
@@ -26,7 +27,6 @@ interface ServeOptions {
|
|
|
26
27
|
distImportMapPath?: string;
|
|
27
28
|
featureFlags?: FeatureFlags;
|
|
28
29
|
inspectSettings?: InspectSettings;
|
|
29
|
-
importMapPaths?: string[];
|
|
30
30
|
onAfterDownload?: OnAfterDownloadHook;
|
|
31
31
|
onBeforeDownload?: OnBeforeDownloadHook;
|
|
32
32
|
formatExportTypeError?: FormatFunction;
|
|
@@ -37,7 +37,7 @@ interface ServeOptions {
|
|
|
37
37
|
userLogger?: LogFunction;
|
|
38
38
|
systemLogger?: LogFunction;
|
|
39
39
|
}
|
|
40
|
-
export declare const serve: ({ basePath, bootstrapURL, certificatePath, debug, distImportMapPath, inspectSettings, featureFlags, formatExportTypeError, formatImportError,
|
|
40
|
+
export declare const serve: ({ basePath, bootstrapURL, certificatePath, debug, distImportMapPath, inspectSettings, featureFlags, formatExportTypeError, formatImportError, onAfterDownload, onBeforeDownload, port, rootPath, servePath, userLogger, systemLogger, }: ServeOptions) => Promise<(functions: EdgeFunction[], env?: NodeJS.ProcessEnv, options?: StartServerOptions) => Promise<{
|
|
41
41
|
features: Record<string, boolean>;
|
|
42
42
|
functionsConfig: FunctionConfig[];
|
|
43
43
|
graph: ModuleGraphJson;
|
|
@@ -18,9 +18,10 @@ const cleanDirectory = async (directory, except) => {
|
|
|
18
18
|
const toBeDeleted = files.filter((file) => !except.includes(join(directory, file)));
|
|
19
19
|
await Promise.all(toBeDeleted.map((file) => unlink(join(directory, file))));
|
|
20
20
|
};
|
|
21
|
-
const prepareServer = ({ basePath, bootstrapURL, deno, distDirectory, distImportMapPath, flags: denoFlags, formatExportTypeError, formatImportError,
|
|
21
|
+
const prepareServer = ({ basePath, bootstrapURL, deno, distDirectory, distImportMapPath, flags: denoFlags, formatExportTypeError, formatImportError, logger, port, rootPath, }) => {
|
|
22
22
|
const processRef = {};
|
|
23
23
|
const startServer = async (functions, env = {}, options = {}) => {
|
|
24
|
+
var _a;
|
|
24
25
|
if ((processRef === null || processRef === void 0 ? void 0 : processRef.ps) !== undefined) {
|
|
25
26
|
await killProcess(processRef.ps);
|
|
26
27
|
}
|
|
@@ -38,7 +39,8 @@ const prepareServer = ({ basePath, bootstrapURL, deno, distDirectory, distImport
|
|
|
38
39
|
formatImportError,
|
|
39
40
|
});
|
|
40
41
|
const features = {};
|
|
41
|
-
const importMap =
|
|
42
|
+
const importMap = new ImportMap();
|
|
43
|
+
await importMap.addFiles((_a = options.importMapPaths) !== null && _a !== void 0 ? _a : [], logger);
|
|
42
44
|
const npmSpecifiersWithExtraneousFiles = [];
|
|
43
45
|
// we keep track of the files that are relevant to the user's code, so we can clean up leftovers from past executions later
|
|
44
46
|
const relevantFiles = [stage2Path];
|
|
@@ -138,10 +140,6 @@ formatExportTypeError,
|
|
|
138
140
|
* a function.
|
|
139
141
|
*/
|
|
140
142
|
formatImportError,
|
|
141
|
-
/**
|
|
142
|
-
* Paths to any additional import map files.
|
|
143
|
-
*/
|
|
144
|
-
importMapPaths = [],
|
|
145
143
|
/**
|
|
146
144
|
* Callback function to be triggered after the Deno CLI has been downloaded.
|
|
147
145
|
*/
|
|
@@ -205,8 +203,6 @@ systemLogger, }) => {
|
|
|
205
203
|
flags.push(inspectSettings.address ? `--inspect=${inspectSettings.address}` : '--inspect');
|
|
206
204
|
}
|
|
207
205
|
}
|
|
208
|
-
const importMap = new ImportMap();
|
|
209
|
-
await importMap.addFiles(importMapPaths, logger);
|
|
210
206
|
const server = prepareServer({
|
|
211
207
|
basePath,
|
|
212
208
|
bootstrapURL,
|
|
@@ -217,7 +213,6 @@ systemLogger, }) => {
|
|
|
217
213
|
flags,
|
|
218
214
|
formatExportTypeError,
|
|
219
215
|
formatImportError,
|
|
220
|
-
importMap,
|
|
221
216
|
logger,
|
|
222
217
|
port,
|
|
223
218
|
rootPath,
|
|
@@ -19,7 +19,6 @@ test('Starts a server and serves requests for edge functions', async () => {
|
|
|
19
19
|
const server = await serve({
|
|
20
20
|
basePath,
|
|
21
21
|
bootstrapURL: 'https://edge.netlify.com/bootstrap/index-combined.ts',
|
|
22
|
-
importMapPaths,
|
|
23
22
|
port,
|
|
24
23
|
servePath,
|
|
25
24
|
});
|
|
@@ -39,6 +38,7 @@ test('Starts a server and serves requests for edge functions', async () => {
|
|
|
39
38
|
];
|
|
40
39
|
const options = {
|
|
41
40
|
getFunctionsConfig: true,
|
|
41
|
+
importMapPaths,
|
|
42
42
|
};
|
|
43
43
|
const { features, functionsConfig, graph, success, npmSpecifiersWithExtraneousFiles } = await server(functions, {
|
|
44
44
|
very_secret_secret: 'i love netlify',
|
|
@@ -97,7 +97,6 @@ test('Serves edge functions in a monorepo setup', async () => {
|
|
|
97
97
|
const server = await serve({
|
|
98
98
|
basePath,
|
|
99
99
|
bootstrapURL: 'https://edge.netlify.com/bootstrap/index-combined.ts',
|
|
100
|
-
importMapPaths,
|
|
101
100
|
port,
|
|
102
101
|
rootPath,
|
|
103
102
|
servePath,
|
|
@@ -110,6 +109,7 @@ test('Serves edge functions in a monorepo setup', async () => {
|
|
|
110
109
|
];
|
|
111
110
|
const options = {
|
|
112
111
|
getFunctionsConfig: true,
|
|
112
|
+
importMapPaths,
|
|
113
113
|
};
|
|
114
114
|
const { features, functionsConfig, graph, success, npmSpecifiersWithExtraneousFiles } = await server(functions, {
|
|
115
115
|
very_secret_secret: 'i love netlify',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Intelligently prepare Netlify Edge Functions for deployment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.js",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"better-ajv-errors": "^1.2.0",
|
|
82
82
|
"common-path-prefix": "^3.0.0",
|
|
83
83
|
"env-paths": "^3.0.0",
|
|
84
|
-
"esbuild": "0.19.
|
|
84
|
+
"esbuild": "0.19.9",
|
|
85
85
|
"execa": "^6.0.0",
|
|
86
86
|
"find-up": "^6.3.0",
|
|
87
87
|
"get-package-name": "^2.2.0",
|