@@ -27,24 +27,23 @@ const {
27
27
28
28
const { RECONCILER } = moduleTypes ;
29
29
30
+ const USE_STRICT_HEADER_REGEX = / ' u s e s t r i c t ' ; \n + / ;
31
+
30
32
function registerInternalModuleStart ( globalName ) {
31
- const path = resolve (
32
- __dirname ,
33
- '..' ,
34
- '..' ,
35
- 'packages/shared/registerInternalModuleStart.js'
36
- ) ;
37
- return String ( readFileSync ( path ) ) . trim ( ) ;
33
+ const path = resolve ( __dirname , 'wrappers' , 'registerInternalModuleBegin.js' ) ;
34
+ const file = readFileSync ( path ) ;
35
+ return String ( file ) . trim ( ) ;
38
36
}
39
37
40
38
function registerInternalModuleStop ( globalName ) {
41
- const path = resolve (
42
- __dirname ,
43
- '..' ,
44
- '..' ,
45
- 'packages/shared/registerInternalModuleStop.js'
46
- ) ;
47
- return String ( readFileSync ( path ) ) . trim ( ) ;
39
+ const path = resolve ( __dirname , 'wrappers' , 'registerInternalModuleEnd.js' ) ;
40
+ const file = readFileSync ( path ) ;
41
+
42
+ // Remove the 'use strict' directive from the footer.
43
+ // This directive is only meaningful when it is the first statement in a file or function.
44
+ return String ( file )
45
+ . replace ( USE_STRICT_HEADER_REGEX , '' )
46
+ . trim ( ) ;
48
47
}
49
48
50
49
const license = ` * Copyright (c) Facebook, Inc. and its affiliates.
@@ -359,6 +358,11 @@ function wrapBundle(
359
358
case RN_OSS_PROFILING :
360
359
case RN_FB_DEV :
361
360
case RN_FB_PROFILING :
361
+ // Remove the 'use strict' directive from source.
362
+ // The module start wrapper will add its own.
363
+ // This directive is only meaningful when it is the first statement in a file or function.
364
+ source = source . replace ( USE_STRICT_HEADER_REGEX , '' ) ;
365
+
362
366
// Certain DEV and Profiling bundles should self-register their own module boundaries with DevTools.
363
367
// This allows the Timeline to de-emphasize (dim) internal stack frames.
364
368
source = `
0 commit comments