mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
added __DEV__ flag behind a footer/header
This commit is contained in:
+10
-16
@@ -15,8 +15,6 @@ const {
|
||||
mkdirSync,
|
||||
unlinkSync,
|
||||
existsSync,
|
||||
readFileSync,
|
||||
writeFileSync,
|
||||
} = require('fs');
|
||||
const rimraf = require('rimraf');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
@@ -77,12 +75,20 @@ function getBanner(bundleType, hastName) {
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule ${hastName}
|
||||
*/`
|
||||
*/${bundleType === FB_DEV ? `\n\n'use strict';\n\nif (__DEV__) {\n` : ''}
|
||||
`
|
||||
);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function getFooter(bundleType) {
|
||||
if (bundleType === FB_DEV) {
|
||||
return '\n}\n';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function updateBabelConfig(babelOpts, bundleType) {
|
||||
let newOpts;
|
||||
|
||||
@@ -131,6 +137,7 @@ function updateBundleConfig(config, filename, format, bundleType, hastName) {
|
||||
return Object.assign({}, config, {
|
||||
banner: getBanner(bundleType, hastName),
|
||||
dest,
|
||||
footer: getFooter(bundleType),
|
||||
format,
|
||||
interop: false,
|
||||
});
|
||||
@@ -270,17 +277,6 @@ function copyNodePackageTemplate(packageName) {
|
||||
}
|
||||
}
|
||||
|
||||
function wrapFileContents(bundleType, filename) {
|
||||
if (bundleType === FB_DEV) {
|
||||
const filepath = resolve(`./build/${facebookWWW}/${filename}`);
|
||||
console.log(filepath);
|
||||
const contents = readFileSync(filepath, 'utf8');
|
||||
const wrappedContent = `if (__DEV__) {\n${contents}\n}\n`;
|
||||
writeFileSync(filepath, wrappedContent, 'utf8');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
function copyBundleIntoNodePackage(packageName, filename, bundleType) {
|
||||
const packageDirectory = resolve(`./build/packages/${packageName}`);
|
||||
|
||||
@@ -392,8 +388,6 @@ function createBundle({
|
||||
updateBundleConfig(config, filename, format, bundleType, hasteName)
|
||||
)).then(() => (
|
||||
createNodePackage(bundleType, name, filename)
|
||||
)).then(() => (
|
||||
wrapFileContents(bundleType, filename)
|
||||
)).catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
|
||||
Reference in New Issue
Block a user