@netlify/edge-bundler 0.12.0 → 1.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/deno/bundle.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { writeStage2 } from 'https://625d32be1b90870009edfc99--edge-bootstrap.netlify.app/bundler/mod.ts'
1
+ import { writeStage2 } from 'https://628282fb528ce20008ed7664--edge-bootstrap.netlify.app/bundler/mod.ts'
2
2
 
3
3
  const [payload] = Deno.args
4
4
  const { basePath, destPath, functions } = JSON.parse(payload)
@@ -5,7 +5,7 @@ import { pathToFileURL } from 'url';
5
5
  import del from 'del';
6
6
  import { wrapBundleError } from '../bundle_error.js';
7
7
  import { getFileHash } from '../utils/sha256.js';
8
- const BOOTSTRAP_LATEST = 'https://625d32be1b90870009edfc99--edge-bootstrap.netlify.app/bootstrap/index-combined.ts';
8
+ const BOOTSTRAP_LATEST = 'https://628282fb528ce20008ed7664--edge-bootstrap.netlify.app/bootstrap/index-combined.ts';
9
9
  const bundle = async (options) => {
10
10
  try {
11
11
  return await bundleJS(options);
package/dist/manifest.js CHANGED
@@ -9,7 +9,7 @@ const generateManifest = ({ bundles = [], declarations = [], functions }) => {
9
9
  if (func === undefined) {
10
10
  return;
11
11
  }
12
- const pattern = 'pattern' in declaration ? new RegExp(declaration.pattern) : globToRegExp(declaration.path);
12
+ const pattern = getRegularExpression(declaration);
13
13
  const serializablePattern = pattern.source.replace(/\\\//g, '/');
14
14
  return {
15
15
  function: func.name,
@@ -27,6 +27,19 @@ const generateManifest = ({ bundles = [], declarations = [], functions }) => {
27
27
  };
28
28
  return manifest;
29
29
  };
30
+ const getRegularExpression = (declaration) => {
31
+ if ('pattern' in declaration) {
32
+ return new RegExp(declaration.pattern);
33
+ }
34
+ // We use the global flag so that `globToRegExp` will not wrap the expression
35
+ // with `^` and `$`. We'll do that ourselves.
36
+ const regularExpression = globToRegExp(declaration.path, { flags: 'g' });
37
+ // Wrapping the expression source with `^` and `$`. Also, adding an optional
38
+ // trailing slash, so that a declaration of `path: "/foo"` matches requests
39
+ // for both `/foo` and `/foo/`.
40
+ const normalizedSource = `^${regularExpression.source}\\/?$`;
41
+ return new RegExp(normalizedSource);
42
+ };
30
43
  const writeManifest = ({ bundles, declarations = [], distDirectory, functions }) => {
31
44
  const manifest = generateManifest({ bundles, declarations, functions });
32
45
  const manifestPath = join(distDirectory, 'manifest.json');
@@ -2,9 +2,16 @@ import { LifecycleHook } from '../bridge.js';
2
2
  import type { EdgeFunction } from '../edge_function.js';
3
3
  import { ImportMapFile } from '../import_map.js';
4
4
  declare type FormatFunction = (name: string) => string;
5
+ interface InspectSettings {
6
+ enabled: boolean;
7
+ pause: boolean;
8
+ address?: string;
9
+ }
5
10
  interface ServeOptions {
11
+ certificatePath?: string;
6
12
  debug?: boolean;
7
13
  distImportMapPath?: string;
14
+ inspectSettings?: InspectSettings;
8
15
  importMaps?: ImportMapFile[];
9
16
  onAfterDownload?: LifecycleHook;
10
17
  onBeforeDownload?: LifecycleHook;
@@ -12,7 +19,7 @@ interface ServeOptions {
12
19
  formatImportError?: FormatFunction;
13
20
  port: number;
14
21
  }
15
- declare const serve: ({ debug, distImportMapPath, formatExportTypeError, formatImportError, importMaps, onAfterDownload, onBeforeDownload, port, }: ServeOptions) => Promise<(newFunctions: EdgeFunction[]) => Promise<{
22
+ declare const serve: ({ certificatePath, debug, distImportMapPath, inspectSettings, formatExportTypeError, formatImportError, importMaps, onAfterDownload, onBeforeDownload, port, }: ServeOptions) => Promise<(newFunctions: EdgeFunction[]) => Promise<{
16
23
  graph: any;
17
24
  success: boolean;
18
25
  }>>;
@@ -3,7 +3,7 @@ import { DenoBridge } from '../bridge.js';
3
3
  import { generateStage2 } from '../formats/javascript.js';
4
4
  import { ImportMap } from '../import_map.js';
5
5
  import { killProcess, waitForServer } from './util.js';
6
- const prepareServer = ({ deno, distDirectory, flags, formatExportTypeError, formatImportError, port, }) => {
6
+ const prepareServer = ({ deno, distDirectory, flags: denoFlags, formatExportTypeError, formatImportError, port, }) => {
7
7
  const processRef = {};
8
8
  const startIsolate = async (newFunctions) => {
9
9
  if ((processRef === null || processRef === void 0 ? void 0 : processRef.ps) !== undefined) {
@@ -29,7 +29,8 @@ const prepareServer = ({ deno, distDirectory, flags, formatExportTypeError, form
29
29
  catch {
30
30
  // no-op
31
31
  }
32
- await deno.runInBackground(['run', ...flags, stage2Path, port.toString()], true, processRef);
32
+ const bootstrapFlags = ['--port', port.toString()];
33
+ await deno.runInBackground(['run', ...denoFlags, stage2Path, ...bootstrapFlags], true, processRef);
33
34
  const success = await waitForServer(port, processRef.ps);
34
35
  return {
35
36
  graph,
@@ -38,7 +39,8 @@ const prepareServer = ({ deno, distDirectory, flags, formatExportTypeError, form
38
39
  };
39
40
  return startIsolate;
40
41
  };
41
- const serve = async ({ debug, distImportMapPath, formatExportTypeError, formatImportError, importMaps, onAfterDownload, onBeforeDownload, port, }) => {
42
+ // eslint-disable-next-line complexity, max-statements
43
+ const serve = async ({ certificatePath, debug, distImportMapPath, inspectSettings, formatExportTypeError, formatImportError, importMaps, onAfterDownload, onBeforeDownload, port, }) => {
42
44
  const deno = new DenoBridge({
43
45
  debug,
44
46
  onAfterDownload,
@@ -53,13 +55,31 @@ const serve = async ({ debug, distImportMapPath, formatExportTypeError, formatIm
53
55
  // if any.
54
56
  const importMap = new ImportMap(importMaps);
55
57
  const flags = ['--allow-all', '--unstable', `--import-map=${importMap.toDataURL()}`];
58
+ if (certificatePath) {
59
+ flags.push(`--cert=${certificatePath}`);
60
+ }
56
61
  if (debug) {
57
62
  flags.push('--log-level=debug');
58
63
  }
59
64
  else {
60
65
  flags.push('--quiet');
61
66
  }
62
- const server = await prepareServer({ deno, distDirectory, flags, formatExportTypeError, formatImportError, port });
67
+ if (inspectSettings && inspectSettings.enabled) {
68
+ if (inspectSettings.pause) {
69
+ flags.push(inspectSettings.address ? `--inspect-brk=${inspectSettings.address}` : '--inspect-brk');
70
+ }
71
+ else {
72
+ flags.push(inspectSettings.address ? `--inspect=${inspectSettings.address}` : '--inspect');
73
+ }
74
+ }
75
+ const server = await prepareServer({
76
+ deno,
77
+ distDirectory,
78
+ flags,
79
+ formatExportTypeError,
80
+ formatImportError,
81
+ port,
82
+ });
63
83
  if (distImportMapPath) {
64
84
  await importMap.writeToFile(distImportMapPath);
65
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "0.12.0",
3
+ "version": "1.2.0",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -48,9 +48,9 @@
48
48
  },
49
49
  "keywords": [],
50
50
  "license": "MIT",
51
- "repository": "netlify-labs/edge-bundler",
51
+ "repository": "netlify/edge-bundler",
52
52
  "bugs": {
53
- "url": "https://github.com/netlify-labs/edge-bundler/issues"
53
+ "url": "https://github.com/netlify/edge-bundler/issues"
54
54
  },
55
55
  "author": "Netlify Inc.",
56
56
  "directories": {
@@ -66,10 +66,12 @@
66
66
  "@types/semver": "^7.3.9",
67
67
  "@types/sinon": "^10.0.8",
68
68
  "@types/uuid": "^8.3.4",
69
+ "archiver": "^5.3.1",
69
70
  "ava": "^4.0.1",
70
71
  "husky": "^7.0.4",
72
+ "nock": "^13.2.4",
71
73
  "nyc": "^15.0.0",
72
- "sinon": "^12.0.1",
74
+ "sinon": "^13.0.0",
73
75
  "ts-node": "^10.4.0",
74
76
  "typescript": "^4.5.4"
75
77
  },