Skip to content

Commit 35f39dd

Browse files
test: wildcard re-export.
1 parent cd4a6d2 commit 35f39dd

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

test/fixtures/exportAll.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './values.mjs'

test/module.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ describe('@knighted/module', () => {
139139
assert.ok(/type: module/.test(conditional!.message))
140140
})
141141

142+
it('lowers export star reexports to cjs', async t => {
143+
const fixturePath = join(fixtures, 'exportAll.mjs')
144+
const outFile = join(fixtures, 'exportAll.cjs')
145+
146+
t.after(() => rm(outFile, { force: true }))
147+
148+
const result = await transform(fixturePath, { target: 'commonjs' })
149+
await writeFile(outFile, result)
150+
151+
const requireFromHere = createRequire(import.meta.url)
152+
const mod = requireFromHere(outFile)
153+
154+
assert.equal(mod.foo, 'bar')
155+
assert.equal(mod.esmodule, true)
156+
assert.equal(Object.prototype.hasOwnProperty.call(mod, 'default'), false)
157+
})
158+
142159
it('transforms __filename', async t => {
143160
const result = await transform(join(fixtures, '__filename.cjs'), {
144161
target: 'module',

0 commit comments

Comments
 (0)