0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 15:30:56 +01:00
nodejs/test/es-module/test-loaders-hidden-from-users.js
Joyee Cheung e1fa85133f
src: implement natives binding without special casing
This patch removes special case in the internal binding loader
for natives, and implements it using the builtins internal
binding. Internally we do not actually need the natives binding,
so implement it as a legacy wrapper instead.

PR-URL: https://github.com/nodejs/node/pull/48186
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2023-06-09 15:32:55 +02:00

29 lines
627 B
JavaScript

// Flags: --expose-internals
'use strict';
require('../common');
const assert = require('assert');
assert.throws(
() => {
require('internal/bootstrap/realm');
}, {
code: 'MODULE_NOT_FOUND',
message: /Cannot find module 'internal\/bootstrap\/realm'/
}
);
assert.throws(
() => {
const source = 'module.exports = require("internal/bootstrap/realm")';
// This needs to be process.binding() to mimic what's normally available
// in the user land.
process.binding('natives').owo = source;
require('owo');
}, {
code: 'MODULE_NOT_FOUND',
message: /Cannot find module 'owo'/
}
);