diff options
author | Darshan Sen <raisinten@gmail.com> | 2023-05-04 20:02:35 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 14:32:35 +0000 |
commit | c868aad15a49d4ea20a06e47eb9cdafc0c218fb4 (patch) | |
tree | 539429e72173581b53e5baf8425bf3940f640218 /test | |
parent | b7def8ef5bfc5b098c0426ecbdc4fead5bdbb29c (diff) | |
download | node-new-c868aad15a49d4ea20a06e47eb9cdafc0c218fb4.tar.gz |
sea: allow requiring core modules with the "node:" prefix
Previously, the `require()` function exposed to the embedded SEA code
was calling the internal `require()` function if the module name
belonged to the list of public core modules but the internal `require()`
function does not support loading modules with the "node:" prefix, so
this change forwards the calls to another `require()` function that
supports this.
Fixes: https://github.com/nodejs/single-executable/issues/69
Signed-off-by: Darshan Sen <raisinten@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/47779
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixtures/sea.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/fixtures/sea.js b/test/fixtures/sea.js index efdc32708b..2cd82c709e 100644 --- a/test/fixtures/sea.js +++ b/test/fixtures/sea.js @@ -9,8 +9,23 @@ expectWarning('ExperimentalWarning', 'Single executable application is an experimental feature and ' + 'might change at any time'); +// Should be possible to require core modules that optionally require the +// "node:" scheme. const { deepStrictEqual, strictEqual, throws } = require('assert'); -const { dirname } = require('path'); +const { dirname } = require('node:path'); + +// Should be possible to require a core module that requires using the "node:" +// scheme. +{ + const { test } = require('node:test'); + strictEqual(typeof test, 'function'); +} + +// Should not be possible to require a core module without the "node:" scheme if +// it requires using the "node:" scheme. +throws(() => require('test'), { + code: 'ERR_UNKNOWN_BUILTIN_MODULE', +}); deepStrictEqual(process.argv, [process.execPath, process.execPath, '-a', '--b=c', 'd']); |