lib: fix code cache generation

e7f710c1 broke the code cache generation since internalBinding
is now passed in through the wrapper and cannot be redeclared.
This patch fixes that.

Refs: https://github.com/nodejs/node/issues/21563
PR-URL: https://github.com/nodejs/node/pull/23855
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Joyee Cheung 2018-10-24 21:15:22 +08:00
parent b255cd48b1
commit 9c0c3f1443
No known key found for this signature in database
GPG Key ID: 92B78A53C8303B8D

View File

@ -6,8 +6,9 @@
// cannot be tampered with even with --expose-internals
const {
NativeModule, internalBinding
NativeModule
} = require('internal/bootstrap/loaders');
const { hasTracing } = process.binding('config');
function getCodeCache(id) {
const cached = NativeModule.getCached(id);
@ -42,6 +43,16 @@ const cannotUseCache = [
'internal/bootstrap/node'
].concat(depsModule);
// Skip modules that cannot be required when they are not
// built into the binary.
if (process.config.variables.v8_enable_inspector !== 1) {
cannotUseCache.push('inspector');
cannotUseCache.push('internal/util/inspector');
}
if (!hasTracing) {
cannotUseCache.push('trace_events');
}
module.exports = {
cachableBuiltins: Object.keys(NativeModule._source).filter(
(key) => !cannotUseCache.includes(key)