Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 6b958dd

Browse files
committed
Add tests for automatic module location
1 parent b1ca38f commit 6b958dd

File tree

16 files changed

+415
-2
lines changed

16 files changed

+415
-2
lines changed

packages/miniflare/src/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,16 @@ export class Miniflare {
564564

565565
this.#disposeController = new AbortController();
566566
this.#runtimeMutex = new Mutex();
567-
this.#initPromise = this.#runtimeMutex.runWith(() => this.#init());
567+
this.#initPromise = this.#runtimeMutex
568+
.runWith(() => this.#init())
569+
.catch((e) => {
570+
// If initialisation failed, attempting to `dispose()` this instance
571+
// will too. Therefore, remove from the instance registry now, so we
572+
// can still test async initialisation failures, without test failures
573+
// telling us to `dispose()` the instance.
574+
maybeInstanceRegistry?.delete(this);
575+
throw e;
576+
});
568577
}
569578

570579
#initPlugins() {
57 Bytes
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Test `ExportAllDeclaration`
2+
export * from "./blobs.mjs";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Test `ExportNamedDeclaration`
2+
export { default as text } from "./blobs/text.txt";
3+
export { default as data } from "./blobs/data.bin";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello! 🤖
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello! 👋
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import cyclic2 from "./cyclic2.mjs";
2+
3+
export const pong = "pong";
4+
5+
export function ping() {
6+
return cyclic2();
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import * as cyclic1 from "./cyclic1.mjs";
2+
3+
export default function () {
4+
return cyclic1.pong;
5+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as cyclic1 from "./cyclic1.mjs";
2+
3+
export default {
4+
async fetch() {
5+
return new Response(cyclic1.ping());
6+
}
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
const id = "./index.cjs";
2+
require(id);

0 commit comments

Comments
 (0)