diff --git a/test/cycle/namespace/immutable/c.js b/test/cycle/namespace/immutable/c.js deleted file mode 100644 index 7dcaea4a1..000000000 --- a/test/cycle/namespace/immutable/c.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict" - -exports.a = "a" diff --git a/test/cycle/namespace/immutable/a.mjs b/test/cycle/namespace/immutable/cjs/a.mjs similarity index 100% rename from test/cycle/namespace/immutable/a.mjs rename to test/cycle/namespace/immutable/cjs/a.mjs diff --git a/test/cycle/namespace/immutable/b.mjs b/test/cycle/namespace/immutable/cjs/b.mjs similarity index 82% rename from test/cycle/namespace/immutable/b.mjs rename to test/cycle/namespace/immutable/cjs/b.mjs index 96d0dbe94..3d2ce8726 100644 --- a/test/cycle/namespace/immutable/b.mjs +++ b/test/cycle/namespace/immutable/cjs/b.mjs @@ -6,6 +6,6 @@ const ns = getNS() assert.strictEqual(inspect(ns), "[Module] { default: }") assert.strictEqual(Reflect.isExtensible(ns), true) -assert.strictEqual(Reflect.defineProperty(ns, "b", { value: "b" }), false) +assert.strictEqual(Reflect.defineProperty(ns, "ADDED", { value: 1 }), false) assert.strictEqual(inspect(ns), "[Module] { default: }") assert.strictEqual(Reflect.preventExtensions(ns), false) diff --git a/test/cycle/namespace/immutable/cjs/c.js b/test/cycle/namespace/immutable/cjs/c.js new file mode 100644 index 000000000..737655b6d --- /dev/null +++ b/test/cycle/namespace/immutable/cjs/c.js @@ -0,0 +1,3 @@ +"use strict" + +exports.c = "c" diff --git a/test/cycle/namespace/immutable/re-export/a.mjs b/test/cycle/namespace/immutable/re-export/a.mjs new file mode 100644 index 000000000..67540e38d --- /dev/null +++ b/test/cycle/namespace/immutable/re-export/a.mjs @@ -0,0 +1,6 @@ +import "./b.mjs" +import * as ns from "./c.mjs" + +export function getNS() { + return ns +} diff --git a/test/cycle/namespace/immutable/re-export/b.mjs b/test/cycle/namespace/immutable/re-export/b.mjs new file mode 100644 index 000000000..fadb788d8 --- /dev/null +++ b/test/cycle/namespace/immutable/re-export/b.mjs @@ -0,0 +1,11 @@ +import assert from "assert" +import { inspect } from "util" +import { getNS } from "./a.mjs" + +const ns = getNS() + +assert.strictEqual(inspect(ns), "[Module] {}") +assert.strictEqual(Reflect.isExtensible(ns), true) +assert.strictEqual(Reflect.defineProperty(ns, "ADDED", { value: 1 }), false) +assert.strictEqual(inspect(ns), "[Module] {}") +assert.strictEqual(Reflect.preventExtensions(ns), false) diff --git a/test/cycle/namespace/immutable/re-export/c.mjs b/test/cycle/namespace/immutable/re-export/c.mjs new file mode 100644 index 000000000..7f7583ebe --- /dev/null +++ b/test/cycle/namespace/immutable/re-export/c.mjs @@ -0,0 +1,3 @@ +export * from "./d.js" +export * from "./e.mjs" +export * from "./f.js" diff --git a/test/cycle/namespace/immutable/re-export/d.js b/test/cycle/namespace/immutable/re-export/d.js new file mode 100644 index 000000000..4388ac106 --- /dev/null +++ b/test/cycle/namespace/immutable/re-export/d.js @@ -0,0 +1,3 @@ +"use strict" + +exports.d = "d" diff --git a/test/cycle/namespace/immutable/re-export/e.mjs b/test/cycle/namespace/immutable/re-export/e.mjs new file mode 100644 index 000000000..ec19d1ab8 --- /dev/null +++ b/test/cycle/namespace/immutable/re-export/e.mjs @@ -0,0 +1 @@ +export const e = "e" diff --git a/test/cycle/namespace/immutable/re-export/f.js b/test/cycle/namespace/immutable/re-export/f.js new file mode 100644 index 000000000..e5c5330e8 --- /dev/null +++ b/test/cycle/namespace/immutable/re-export/f.js @@ -0,0 +1,3 @@ +"use strict" + +exports.f = "f" diff --git a/test/cycle/namespace/mutable/c.js b/test/cycle/namespace/mutable/c.js deleted file mode 100644 index 7dcaea4a1..000000000 --- a/test/cycle/namespace/mutable/c.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict" - -exports.a = "a" diff --git a/test/cycle/namespace/mutable/a.js b/test/cycle/namespace/mutable/cjs/a.js similarity index 100% rename from test/cycle/namespace/mutable/a.js rename to test/cycle/namespace/mutable/cjs/a.js diff --git a/test/cycle/namespace/mutable/b.js b/test/cycle/namespace/mutable/cjs/b.js similarity index 80% rename from test/cycle/namespace/mutable/b.js rename to test/cycle/namespace/mutable/cjs/b.js index 317f44591..612ba4dce 100644 --- a/test/cycle/namespace/mutable/b.js +++ b/test/cycle/namespace/mutable/cjs/b.js @@ -6,6 +6,6 @@ const ns = getNS() assert.strictEqual(inspect(ns), "[Module] {}") assert.strictEqual(Reflect.isExtensible(ns), true) -assert.strictEqual(Reflect.defineProperty(ns, "b", { value: "b" }), false) +assert.strictEqual(Reflect.defineProperty(ns, "ADDED", { value: 1 }), false) assert.strictEqual(inspect(ns), "[Module] {}") assert.strictEqual(Reflect.preventExtensions(ns), false) diff --git a/test/cycle/namespace/mutable/cjs/c.js b/test/cycle/namespace/mutable/cjs/c.js new file mode 100644 index 000000000..737655b6d --- /dev/null +++ b/test/cycle/namespace/mutable/cjs/c.js @@ -0,0 +1,3 @@ +"use strict" + +exports.c = "c" diff --git a/test/cycle/namespace/mutable/re-export/a.js b/test/cycle/namespace/mutable/re-export/a.js new file mode 100644 index 000000000..2a1ba1d7f --- /dev/null +++ b/test/cycle/namespace/mutable/re-export/a.js @@ -0,0 +1,6 @@ +import "./b.js" +import * as ns from "./c.js" + +export function getNS() { + return ns +} diff --git a/test/cycle/namespace/mutable/re-export/b.js b/test/cycle/namespace/mutable/re-export/b.js new file mode 100644 index 000000000..612ba4dce --- /dev/null +++ b/test/cycle/namespace/mutable/re-export/b.js @@ -0,0 +1,11 @@ +import assert from "assert" +import { inspect } from "util" +import { getNS } from "./a.js" + +const ns = getNS() + +assert.strictEqual(inspect(ns), "[Module] {}") +assert.strictEqual(Reflect.isExtensible(ns), true) +assert.strictEqual(Reflect.defineProperty(ns, "ADDED", { value: 1 }), false) +assert.strictEqual(inspect(ns), "[Module] {}") +assert.strictEqual(Reflect.preventExtensions(ns), false) diff --git a/test/cycle/namespace/mutable/re-export/c.js b/test/cycle/namespace/mutable/re-export/c.js new file mode 100644 index 000000000..56e763767 --- /dev/null +++ b/test/cycle/namespace/mutable/re-export/c.js @@ -0,0 +1,3 @@ +export * from "./d.js" +export * from "./e.js" +export * from "./f.js" diff --git a/test/cycle/namespace/mutable/re-export/d.js b/test/cycle/namespace/mutable/re-export/d.js new file mode 100644 index 000000000..4388ac106 --- /dev/null +++ b/test/cycle/namespace/mutable/re-export/d.js @@ -0,0 +1,3 @@ +"use strict" + +exports.d = "d" diff --git a/test/cycle/namespace/mutable/re-export/e.js b/test/cycle/namespace/mutable/re-export/e.js new file mode 100644 index 000000000..ec19d1ab8 --- /dev/null +++ b/test/cycle/namespace/mutable/re-export/e.js @@ -0,0 +1 @@ +export const e = "e" diff --git a/test/cycle/namespace/mutable/re-export/f.js b/test/cycle/namespace/mutable/re-export/f.js new file mode 100644 index 000000000..e5c5330e8 --- /dev/null +++ b/test/cycle/namespace/mutable/re-export/f.js @@ -0,0 +1,3 @@ +"use strict" + +exports.f = "f" diff --git a/test/misc-tests.js b/test/misc-tests.js index bca21959e..778831034 100644 --- a/test/misc-tests.js +++ b/test/misc-tests.js @@ -1083,8 +1083,17 @@ describe("miscellaneous tests", () => { it("should support namespace objects of cyclical CJS modules", () => Promise .all([ - "./cycle/namespace/immutable/a.mjs", - "./cycle/namespace/mutable/a.js" + "./cycle/namespace/immutable/cjs/a.mjs", + "./cycle/namespace/mutable/cjs/a.js" + ] + .map((request) => import(request))) + ) + + it("should defer finalization of ESM namespace objects containing re-exports of CJS modules", () => + Promise + .all([ + "./cycle/namespace/immutable/re-export/a.mjs", + "./cycle/namespace/mutable/re-export/a.js" ] .map((request) => import(request))) )