mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Fix module-boundary wrappers (#22688)
This commit is contained in:
+18
-14
@@ -27,24 +27,23 @@ const {
|
||||
|
||||
const {RECONCILER} = moduleTypes;
|
||||
|
||||
const USE_STRICT_HEADER_REGEX = /'use strict';\n+/;
|
||||
|
||||
function registerInternalModuleStart(globalName) {
|
||||
const path = resolve(
|
||||
__dirname,
|
||||
'..',
|
||||
'..',
|
||||
'packages/shared/registerInternalModuleStart.js'
|
||||
);
|
||||
return String(readFileSync(path)).trim();
|
||||
const path = resolve(__dirname, 'wrappers', 'registerInternalModuleBegin.js');
|
||||
const file = readFileSync(path);
|
||||
return String(file).trim();
|
||||
}
|
||||
|
||||
function registerInternalModuleStop(globalName) {
|
||||
const path = resolve(
|
||||
__dirname,
|
||||
'..',
|
||||
'..',
|
||||
'packages/shared/registerInternalModuleStop.js'
|
||||
);
|
||||
return String(readFileSync(path)).trim();
|
||||
const path = resolve(__dirname, 'wrappers', 'registerInternalModuleEnd.js');
|
||||
const file = readFileSync(path);
|
||||
|
||||
// Remove the 'use strict' directive from the footer.
|
||||
// This directive is only meaningful when it is the first statement in a file or function.
|
||||
return String(file)
|
||||
.replace(USE_STRICT_HEADER_REGEX, '')
|
||||
.trim();
|
||||
}
|
||||
|
||||
const license = ` * Copyright (c) Facebook, Inc. and its affiliates.
|
||||
@@ -359,6 +358,11 @@ function wrapBundle(
|
||||
case RN_OSS_PROFILING:
|
||||
case RN_FB_DEV:
|
||||
case RN_FB_PROFILING:
|
||||
// Remove the 'use strict' directive from source.
|
||||
// The module start wrapper will add its own.
|
||||
// This directive is only meaningful when it is the first statement in a file or function.
|
||||
source = source.replace(USE_STRICT_HEADER_REGEX, '');
|
||||
|
||||
// Certain DEV and Profiling bundles should self-register their own module boundaries with DevTools.
|
||||
// This allows the Timeline to de-emphasize (dim) internal stack frames.
|
||||
source = `
|
||||
|
||||
+1
-9
@@ -1,14 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
||||
|
||||
// Don't require this file directly; it's embedded by Rollup during build.
|
||||
|
||||
if (
|
||||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
||||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
||||
+1
-9
@@ -1,14 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
||||
|
||||
// Don't require this file directly; it's embedded by Rollup during build.
|
||||
|
||||
if (
|
||||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
||||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
||||
Reference in New Issue
Block a user