diff --git a/test/fixtures/side-effects/core.mjs b/test/fixtures/side-effects/core.mjs new file mode 100644 index 0000000..aba49fa --- /dev/null +++ b/test/fixtures/side-effects/core.mjs @@ -0,0 +1,2 @@ +import { kind as shimsKind } from "./shims.mjs"; +export { shimsKind }; diff --git a/test/fixtures/side-effects/registry.mjs b/test/fixtures/side-effects/registry.mjs new file mode 100644 index 0000000..7509569 --- /dev/null +++ b/test/fixtures/side-effects/registry.mjs @@ -0,0 +1,9 @@ +export let kind = undefined; + +export function setShims(shims) { + if (kind) { + throw new Error(`shims already set to ${kind}`); + } + + kind = shims.kind; +} diff --git a/test/fixtures/side-effects/runtime.mjs b/test/fixtures/side-effects/runtime.mjs new file mode 100644 index 0000000..82f0866 --- /dev/null +++ b/test/fixtures/side-effects/runtime.mjs @@ -0,0 +1,5 @@ +export function getRuntime() { + return { + kind: "node", + }; +} diff --git a/test/fixtures/side-effects/shims.mjs b/test/fixtures/side-effects/shims.mjs new file mode 100644 index 0000000..415ae47 --- /dev/null +++ b/test/fixtures/side-effects/shims.mjs @@ -0,0 +1,8 @@ +import * as shims from "./registry.mjs"; +import * as auto from "./runtime.mjs"; + +if (!shims.kind) { + shims.setShims(auto.getRuntime()); +} + +export * from "./registry.mjs"; diff --git a/test/hook/side-effects.mjs b/test/hook/side-effects.mjs new file mode 100644 index 0000000..7abc0e9 --- /dev/null +++ b/test/hook/side-effects.mjs @@ -0,0 +1,4 @@ +import * as core from "../fixtures/side-effects/core.mjs"; +import { strictEqual } from "assert"; + +strictEqual(core.shimsKind, "node");