@netlify/edge-bundler
Advanced tools
Comparing version 10.0.0 to 10.1.0
@@ -9,3 +9,3 @@ export { bundle } from './bundler.js'; | ||
export type { EdgeFunctionConfig, Manifest } from './manifest.js'; | ||
export { serve } from './server/server.js'; | ||
export { ModuleGraph, serve } from './server/server.js'; | ||
export { validateManifest, ManifestValidationError } from './validation/manifest/index.js'; |
@@ -0,1 +1,7 @@ | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { ModuleGraphJson } from '../../deno/vendor/deno.land/x/deno_graph@0.59.2/types.d.js'; | ||
import { OnAfterDownloadHook, OnBeforeDownloadHook } from '../bridge.js'; | ||
@@ -7,2 +13,3 @@ import { FunctionConfig } from '../config.js'; | ||
export type FormatFunction = (name: string) => string; | ||
export type ModuleGraph = ModuleGraphJson; | ||
interface StartServerOptions { | ||
@@ -38,3 +45,3 @@ getFunctionsConfig?: boolean; | ||
functionsConfig: FunctionConfig[]; | ||
graph: any; | ||
graph: ModuleGraphJson; | ||
npmSpecifiersWithExtraneousFiles: string[]; | ||
@@ -41,0 +48,0 @@ success: boolean; |
@@ -27,3 +27,7 @@ import { readdir, unlink } from 'fs/promises'; | ||
} | ||
let graph; | ||
let graph = { | ||
roots: [], | ||
modules: [], | ||
redirects: {}, | ||
}; | ||
const stage2Path = await generateStage2({ | ||
@@ -30,0 +34,0 @@ bootstrapURL, |
@@ -51,5 +51,3 @@ import { readFile } from 'fs/promises'; | ||
for (const key in functions) { | ||
const graphEntry = graph === null || graph === void 0 ? void 0 : graph.modules.some( | ||
// @ts-expect-error TODO: Module graph is currently not typed | ||
({ kind, mediaType, local }) => kind === 'esm' && mediaType === 'TypeScript' && local === functions[key].path); | ||
const graphEntry = graph === null || graph === void 0 ? void 0 : graph.modules.some(({ kind, mediaType, local }) => kind === 'esm' && mediaType === 'TypeScript' && local === functions[key].path); | ||
expect(graphEntry).toBe(true); | ||
@@ -125,5 +123,3 @@ } | ||
for (const key in functions) { | ||
const graphEntry = graph === null || graph === void 0 ? void 0 : graph.modules.some( | ||
// @ts-expect-error TODO: Module graph is currently not typed | ||
({ kind, mediaType, local }) => kind === 'esm' && mediaType === 'TypeScript' && local === functions[key].path); | ||
const graphEntry = graph === null || graph === void 0 ? void 0 : graph.modules.some(({ kind, mediaType, local }) => kind === 'esm' && mediaType === 'TypeScript' && local === functions[key].path); | ||
expect(graphEntry).toBe(true); | ||
@@ -130,0 +126,0 @@ } |
{ | ||
"name": "@netlify/edge-bundler", | ||
"version": "10.0.0", | ||
"version": "10.1.0", | ||
"description": "Intelligently prepare Netlify Edge Functions for deployment", | ||
@@ -37,3 +37,4 @@ "type": "module", | ||
"test:ci:deno": "deno test --allow-all deno", | ||
"test:integration": "node --experimental-modules test/integration/test.js" | ||
"test:integration": "node --experimental-modules test/integration/test.js", | ||
"vendor": "deno vendor --force --output deno/vendor https://deno.land/x/deno_graph@0.59.2/types.d.ts https://deno.land/x/eszip@v0.55.2/mod.ts https://deno.land/x/retry@v2.0.0/mod.ts https://deno.land/x/std@0.177.0/path/mod.ts" | ||
}, | ||
@@ -40,0 +41,0 @@ "config": { |
@@ -12,28 +12,38 @@ [![Build](https://github.com/netlify/edge-bundler/workflows/Build/badge.svg)](https://github.com/netlify/edge-bundler/actions) | ||
``` | ||
npm install @netlify/edge-bundler --save | ||
``` | ||
``` | ||
npm install @netlify/edge-bundler --save | ||
``` | ||
2. Import it and create a bundle from a directory of Edge Functions and a list of declarations. | ||
```js | ||
import { bundle } from '@netlify/edge-bundler' | ||
```js | ||
import { bundle } from '@netlify/edge-bundler' | ||
// List of directories to search for Edge Functions. | ||
const sourceDirectories = [ | ||
"/repo/netlify/edge-functions", | ||
"/repo/.netlify/edge-functions" | ||
] | ||
// List of directories to search for Edge Functions. | ||
const sourceDirectories = ['/repo/netlify/edge-functions', '/repo/.netlify/edge-functions'] | ||
// Directory where bundle should be placed. | ||
const distDirectory = "/repo/.netlify/edge-functions-dist" | ||
// Directory where bundle should be placed. | ||
const distDirectory = '/repo/.netlify/edge-functions-dist' | ||
// List of Edge Functions declarations. | ||
const declarations = [ | ||
{function: "user-1", path: "/blog/*"}, | ||
{function: "internal-2", path: "/"} | ||
] | ||
// List of Edge Functions declarations. | ||
const declarations = [ | ||
{ function: 'user-1', path: '/blog/*' }, | ||
{ function: 'internal-2', path: '/' }, | ||
] | ||
await bundle(sourceDirectories, distDirectory, declarations) | ||
``` | ||
await bundle(sourceDirectories, distDirectory, declarations) | ||
``` | ||
## Vendored modules | ||
To avoid pulling in additional dependencies at runtime, this package vendors some Deno modules in the `deno/vendor` | ||
directory. | ||
You can recreate this directory by running `npm run vendor`. | ||
> [!WARNING] | ||
> At the time of writing, the underlying Deno CLI command doesn't correctly pull the WASM binary required by the ESZIP | ||
> module. If you run the command to update the list of vendores modules, please ensure you're not deleting | ||
> `eszip_wasm_bg.wasm`. | ||
## Contributors | ||
@@ -40,0 +50,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3792709
9414
52
32
10
164