@@ -46,8 +46,8 @@ const {
46
46
SafeMap,
47
47
String,
48
48
StringPrototypeEndsWith,
49
- StringPrototypeIndexOf,
50
49
StringPrototypeLastIndexOf,
50
+ StringPrototypeIndexOf,
51
51
StringPrototypeMatch,
52
52
StringPrototypeSlice,
53
53
StringPrototypeStartsWith,
@@ -81,8 +81,9 @@ const { getOptionValue } = require('internal/options');
81
81
const enableSourceMaps = getOptionValue ( '--enable-source-maps' ) ;
82
82
const preserveSymlinks = getOptionValue ( '--preserve-symlinks' ) ;
83
83
const preserveSymlinksMain = getOptionValue ( '--preserve-symlinks-main' ) ;
84
- const manifest = getOptionValue ( '--experimental-policy' ) ?
85
- require ( 'internal/process/policy' ) . manifest :
84
+ // Do not eagerly grab .manifest, it may be in TDZ
85
+ const policy = getOptionValue ( '--experimental-policy' ) ?
86
+ require ( 'internal/process/policy' ) :
86
87
null ;
87
88
const { compileFunction } = internalBinding ( 'contextify' ) ;
88
89
@@ -1029,10 +1030,10 @@ function wrapSafe(filename, content, cjsModuleInstance) {
1029
1030
Module . prototype . _compile = function ( content , filename ) {
1030
1031
let moduleURL ;
1031
1032
let redirects ;
1032
- if ( manifest ) {
1033
+ if ( policy ?. manifest ) {
1033
1034
moduleURL = pathToFileURL ( filename ) ;
1034
- redirects = manifest . getRedirector ( moduleURL ) ;
1035
- manifest . assertIntegrity ( moduleURL , content ) ;
1035
+ redirects = policy . manifest . getDependencyMapper ( moduleURL ) ;
1036
+ policy . manifest . assertIntegrity ( moduleURL , content ) ;
1036
1037
}
1037
1038
1038
1039
maybeCacheSourceMap ( filename , content , this ) ;
@@ -1101,9 +1102,9 @@ Module._extensions['.js'] = function(module, filename) {
1101
1102
Module . _extensions [ '.json' ] = function ( module , filename ) {
1102
1103
const content = fs . readFileSync ( filename , 'utf8' ) ;
1103
1104
1104
- if ( manifest ) {
1105
+ if ( policy ?. manifest ) {
1105
1106
const moduleURL = pathToFileURL ( filename ) ;
1106
- manifest . assertIntegrity ( moduleURL , content ) ;
1107
+ policy . manifest . assertIntegrity ( moduleURL , content ) ;
1107
1108
}
1108
1109
1109
1110
try {
@@ -1117,10 +1118,10 @@ Module._extensions['.json'] = function(module, filename) {
1117
1118
1118
1119
// Native extension for .node
1119
1120
Module . _extensions [ '.node' ] = function ( module , filename ) {
1120
- if ( manifest ) {
1121
+ if ( policy ?. manifest ) {
1121
1122
const content = fs . readFileSync ( filename ) ;
1122
1123
const moduleURL = pathToFileURL ( filename ) ;
1123
- manifest . assertIntegrity ( moduleURL , content ) ;
1124
+ policy . manifest . assertIntegrity ( moduleURL , content ) ;
1124
1125
}
1125
1126
// Be aware this doesn't use `content`
1126
1127
return process . dlopen ( module , path . toNamespacedPath ( filename ) ) ;
0 commit comments