@netlify/edge-bundler 13.0.0 → 13.0.2

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.
@@ -424,6 +424,28 @@ test('Loads npm modules which use package.json.exports', async () => {
424
424
  await cleanup();
425
425
  await rm(vendorDirectory.path, { force: true, recursive: true });
426
426
  });
427
+ test('Loads modules which contain cycles', async () => {
428
+ const { basePath, cleanup, distPath } = await useFixture('imports_cycle');
429
+ const sourceDirectory = join(basePath, 'functions');
430
+ const declarations = [
431
+ {
432
+ function: 'func1',
433
+ path: '/func1',
434
+ },
435
+ ];
436
+ const vendorDirectory = await tmp.dir();
437
+ await bundle([sourceDirectory], distPath, declarations, {
438
+ basePath,
439
+ vendorDirectory: vendorDirectory.path,
440
+ });
441
+ const manifestFile = await readFile(resolve(distPath, 'manifest.json'), 'utf8');
442
+ const manifest = JSON.parse(manifestFile);
443
+ const bundlePath = join(distPath, manifest.bundles[0].asset);
444
+ const { func1 } = await runESZIP(bundlePath, vendorDirectory.path);
445
+ expect(func1).toBe('magix');
446
+ await cleanup();
447
+ await rm(vendorDirectory.path, { force: true, recursive: true });
448
+ });
427
449
  test('Loads npm modules in a monorepo setup', async () => {
428
450
  const systemLogger = vi.fn();
429
451
  const { basePath: rootPath, cleanup, distPath } = await useFixture('monorepo_npm_module');
@@ -116,7 +116,7 @@ async function parseImportsForFile(file, rootPath) {
116
116
  * Parses a set of functions and returns a list of specifiers that correspond
117
117
  * to npm modules.
118
118
  */
119
- const getNPMSpecifiers = async ({ basePath, functions, importMap, environment, rootPath }) => {
119
+ const getNPMSpecifiers = async ({ basePath, functions, importMap, environment, rootPath }, alreadySeenPaths = new Set()) => {
120
120
  var _a;
121
121
  const baseURL = pathToFileURL(basePath);
122
122
  const npmSpecifiers = [];
@@ -128,12 +128,20 @@ const getNPMSpecifiers = async ({ basePath, functions, importMap, environment, r
128
128
  const specifier = i.moduleSpecifier.isConstant ? i.moduleSpecifier.value : i.moduleSpecifier.code;
129
129
  switch (i.moduleSpecifier.type) {
130
130
  case 'absolute': {
131
- npmSpecifiers.push(...(await getNPMSpecifiers({ basePath, functions: [specifier], importMap, environment, rootPath })));
131
+ if (alreadySeenPaths.has(specifier)) {
132
+ break;
133
+ }
134
+ alreadySeenPaths.add(specifier);
135
+ npmSpecifiers.push(...(await getNPMSpecifiers({ basePath, functions: [specifier], importMap, environment, rootPath }, alreadySeenPaths)));
132
136
  break;
133
137
  }
134
138
  case 'relative': {
135
139
  const filePath = path.join(path.dirname(func), specifier);
136
- npmSpecifiers.push(...(await getNPMSpecifiers({ basePath, functions: [filePath], importMap, environment, rootPath })));
140
+ if (alreadySeenPaths.has(filePath)) {
141
+ break;
142
+ }
143
+ alreadySeenPaths.add(filePath);
144
+ npmSpecifiers.push(...(await getNPMSpecifiers({ basePath, functions: [filePath], importMap, environment, rootPath }, alreadySeenPaths)));
137
145
  break;
138
146
  }
139
147
  case 'package': {
@@ -146,7 +154,11 @@ const getNPMSpecifiers = async ({ basePath, functions, importMap, environment, r
146
154
  if (matched) {
147
155
  if (resolvedImport.protocol === 'file:') {
148
156
  const newSpecifier = fileURLToPath(resolvedImport).replace(/\\/g, '/');
149
- npmSpecifiers.push(...(await getNPMSpecifiers({ basePath, functions: [newSpecifier], importMap, environment, rootPath })));
157
+ if (alreadySeenPaths.has(newSpecifier)) {
158
+ break;
159
+ }
160
+ alreadySeenPaths.add(newSpecifier);
161
+ npmSpecifiers.push(...(await getNPMSpecifiers({ basePath, functions: [newSpecifier], importMap, environment, rootPath }, alreadySeenPaths)));
150
162
  }
151
163
  }
152
164
  else if (!((_a = resolvedImport === null || resolvedImport === void 0 ? void 0 : resolvedImport.protocol) === null || _a === void 0 ? void 0 : _a.startsWith('http'))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "13.0.0",
3
+ "version": "13.0.2",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.js",
@@ -63,7 +63,7 @@
63
63
  "better-ajv-errors": "^1.2.0",
64
64
  "common-path-prefix": "^3.0.0",
65
65
  "env-paths": "^3.0.0",
66
- "esbuild": "0.21.2",
66
+ "esbuild": "0.25.2",
67
67
  "execa": "^7.0.0",
68
68
  "find-up": "^6.3.0",
69
69
  "get-package-name": "^2.2.0",
@@ -80,5 +80,5 @@
80
80
  "urlpattern-polyfill": "8.0.2",
81
81
  "uuid": "^9.0.0"
82
82
  },
83
- "gitHead": "8d10878db3be9cfefe3162fd155c76595aba045e"
83
+ "gitHead": "a425e1f3fa5c06caa41ef232aad60891c2273e06"
84
84
  }