@netlify/edge-bundler 15.0.2 → 15.0.4

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.
@@ -187,6 +187,7 @@ async function getRequiredSourceFiles(deno, entryPoints, importMap) {
187
187
  if (!module.specifier.startsWith('file://')) {
188
188
  continue;
189
189
  }
190
+ const filePath = fileURLToPath(module.specifier);
190
191
  if (module.error) {
191
192
  // A module reachable only through type-only edges (e.g. a directory specifier
192
193
  // behind `import type`) can fail to resolve as an ES module. That's safe to
@@ -200,12 +201,32 @@ async function getRequiredSourceFiles(deno, entryPoints, importMap) {
200
201
  // require in try/catch).
201
202
  continue;
202
203
  }
204
+ // Importing a directory is unsupported in Deno (ERR_UNSUPPORTED_DIR_IMPORT), yet
205
+ // the directory still surfaces here as an errored module. It's not a bundleable
206
+ // file: including it would pollute the common path prefix and, once copied, throw
207
+ // EISDIR. Skip it.
208
+ if (await isDirectory(filePath)) {
209
+ continue;
210
+ }
203
211
  }
204
- localFiles.add(fileURLToPath(module.specifier));
212
+ localFiles.add(filePath);
205
213
  }
206
214
  }
207
215
  return localFiles;
208
216
  }
217
+ /**
218
+ * Returns whether the given path exists and is a directory. Used to filter out
219
+ * directory specifiers that Deno surfaces as errored modules (directory imports
220
+ * are unsupported) so they're never treated as bundleable source files.
221
+ */
222
+ async function isDirectory(entryPath) {
223
+ try {
224
+ return (await fs.stat(entryPath)).isDirectory();
225
+ }
226
+ catch {
227
+ return false;
228
+ }
229
+ }
209
230
  // WebAssembly binary magic bytes: `\0asm` (0x00 0x61 0x73 0x6d).
210
231
  const WASM_MAGIC = Buffer.from([0x00, 0x61, 0x73, 0x6d]);
211
232
  /**
@@ -245,6 +266,12 @@ async function shouldRewrite(sourceFile) {
245
266
  * Defaults to copying the file in its current form
246
267
  */
247
268
  export async function rewriteImportAssertions(sourceFile, destPath) {
269
+ // Defensive guard: a directory has nothing to bundle, and copying/reading one
270
+ // throws EISDIR. `getRequiredSourceFiles` already filters directory specifiers
271
+ // out of the source set, so this only matters if one slips through.
272
+ if (await isDirectory(sourceFile)) {
273
+ return;
274
+ }
248
275
  if (!(await shouldRewrite(sourceFile))) {
249
276
  if (sourceFile !== destPath) {
250
277
  await fs.copyFile(sourceFile, destPath);
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "15.0.2",
3
+ "version": "15.0.4",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/node/index.js",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@import-maps/resolve": "^2.0.0",
62
- "@sveltejs/acorn-typescript": "^1.0.9",
62
+ "@sveltejs/acorn-typescript": "^1.0.11",
63
63
  "acorn": "^8.15.0",
64
64
  "ajv": "^8.11.2",
65
65
  "ajv-errors": "^3.0.0",
@@ -80,5 +80,5 @@
80
80
  "tmp-promise": "^3.0.3",
81
81
  "urlpattern-polyfill": "8.0.2"
82
82
  },
83
- "gitHead": "7895e2cf13c2eda2a9e4a6749b6e688426fc9f1c"
83
+ "gitHead": "46836e0332f78056d7faf221bfe55b7f4be1da76"
84
84
  }