mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Enable node:vfs by default. --no-experimental-vfs disables node:vfs exposure and --vfs-load. Assisted-by: pi Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: https://github.com/nodejs/node/pull/66318 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
74 lines
3.2 KiB
JavaScript
74 lines
3.2 KiB
JavaScript
// Flags: --disable-warning=ExperimentalWarning
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { spawnSyncAndAssert } = require('../common/child_process');
|
|
|
|
const experimentalBuiltins = [
|
|
['bench', '--experimental-bench', true],
|
|
['bench/reporters', '--experimental-bench', true],
|
|
['dtls', '--experimental-dtls', common.hasDtls],
|
|
['quic', '--experimental-quic', common.hasQuic],
|
|
].filter(([, , available]) => available);
|
|
|
|
for (const [id, flag] of experimentalBuiltins) {
|
|
const builtin = `node:${id}`;
|
|
|
|
spawnSyncAndAssert(process.execPath, [
|
|
'-e', `const m = require('node:module'); if (m.builtinModules.includes('${builtin}')) process.exit(1); try { require('${builtin}'); } catch (e) { if (e.code === 'ERR_UNKNOWN_BUILTIN_MODULE') process.exit(0); } process.exit(1);`,
|
|
], { status: 0 });
|
|
|
|
spawnSyncAndAssert(process.execPath, [
|
|
flag,
|
|
'-e', `const m = require('node:module'); if (!m.builtinModules.includes('${builtin}')) process.exit(1); require('${builtin}');`,
|
|
], { status: 0 });
|
|
}
|
|
|
|
const schemelessExperimentalBuiltins = [
|
|
['stream/iter', '--experimental-stream-iter'],
|
|
['zlib/iter', '--experimental-stream-iter'],
|
|
];
|
|
|
|
for (const [id, flag] of schemelessExperimentalBuiltins) {
|
|
const nodeBuiltin = `node:${id}`;
|
|
|
|
spawnSyncAndAssert(process.execPath, [
|
|
'-e', `const assert = require('node:assert'); const { builtinModules } = require('node:module'); assert(!builtinModules.includes('${id}')); assert(!builtinModules.includes('${nodeBuiltin}')); assert.throws(() => require('${id}'), { code: 'MODULE_NOT_FOUND' }); assert.throws(() => require('${nodeBuiltin}'), { code: 'ERR_UNKNOWN_BUILTIN_MODULE' });`,
|
|
], { status: 0 });
|
|
|
|
spawnSyncAndAssert(process.execPath, [
|
|
flag,
|
|
'-e', `const assert = require('node:assert'); const { builtinModules } = require('node:module'); assert(builtinModules.includes('${id}')); assert(!builtinModules.includes('${nodeBuiltin}')); require('${id}'); require('${nodeBuiltin}');`,
|
|
], { status: 0 });
|
|
}
|
|
|
|
// node:ffi is enabled by default in builds with FFI support and can be
|
|
// disabled with --no-experimental-ffi.
|
|
if (common.hasFFI) {
|
|
spawnSyncAndAssert(process.execPath, [
|
|
'--no-experimental-ffi',
|
|
'-e', `const m = require('node:module'); if (m.builtinModules.includes('node:ffi')) process.exit(1); try { require('node:ffi'); } catch (e) { if (e.code === 'ERR_UNKNOWN_BUILTIN_MODULE') process.exit(0); } process.exit(1);`,
|
|
], { status: 0 });
|
|
}
|
|
|
|
// node:vfs is enabled by default and can be disabled with
|
|
// --no-experimental-vfs.
|
|
spawnSyncAndAssert(process.execPath, [
|
|
'--no-experimental-vfs',
|
|
'-e', `const m = require('node:module'); if (m.builtinModules.includes('node:vfs')) process.exit(1); try { require('node:vfs'); } catch (e) { if (e.code === 'ERR_UNKNOWN_BUILTIN_MODULE') process.exit(0); } process.exit(1);`,
|
|
], { status: 0 });
|
|
|
|
const schemeOnlyBuiltins = ['node:test', 'node:sea', 'node:vfs'];
|
|
if (common.hasFFI) {
|
|
schemeOnlyBuiltins.push('node:ffi');
|
|
}
|
|
if (common.hasSQLite) {
|
|
schemeOnlyBuiltins.push('node:sqlite');
|
|
}
|
|
|
|
for (const id of schemeOnlyBuiltins) {
|
|
spawnSyncAndAssert(process.execPath, [
|
|
'-e', `const m = require('node:module'); if (!m.builtinModules.includes('${id}')) process.exit(1); require('${id}');`,
|
|
], { status: 0 });
|
|
}
|