Skip to content
This repository was archived by the owner on May 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/fixtures/node-force-builtin/function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const stream = require('node:stream/web')

module.exports = () => {
return Boolean(stream.ReadableStream)
}
29 changes: 29 additions & 0 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2250,6 +2250,35 @@ testMany(
},
)

testMany(
'Handles built-in modules imported with the `node:` prefix',
['bundler_default', 'bundler_default_nft', 'bundler_nft', 'bundler_esbuild', 'bundler_esbuild_zisi'],
async (options, t) => {
t.plan(3)
const { tmpDir, files } = await zipFixture(t, 'node-force-builtin', {
opts: { config: { '*': { ...options } } },
})

await unzipFiles(files)

if (semver.satisfies(nodeVersion, '>=16')) {
const func = require(`${tmpDir}/function`)
t.true(func())
} else {
try {
require(`${tmpDir}/function`)
} catch (error) {
t.is(
error.message,
semver.satisfies(nodeVersion, '>10')
? 'No such built-in module: node:stream/web'
: "Cannot find module 'node:stream/web'",
)
}
}
},
)

testMany(
'Returns a `size` property with the size of each generated archive',
['bundler_default', 'bundler_esbuild', 'bundler_nft'],
Expand Down