diff --git a/config/paths.js b/config/paths.js index b0f94588adb..d3fc01a29c5 100644 --- a/config/paths.js +++ b/config/paths.js @@ -12,6 +12,11 @@ var path = require('path'); +function resolve(relativePath) { + return path.resolve(__dirname, relativePath); +} + +// Dead code on eject: start // True when used as a dependency, false after ejecting var isInNodeModules = ( 'node_modules' === @@ -23,10 +28,6 @@ var isInCreateReactAppSource = ( process.argv.some(arg => arg.indexOf('--debug-template') > -1) ); -function resolve(relativePath) { - return path.resolve(__dirname, relativePath); -} - if (isInCreateReactAppSource) { // create-react-app development: we're in ./config/ module.exports = { @@ -52,6 +53,7 @@ if (isInCreateReactAppSource) { }; } else { // after eject: we're in ./config/ +// Dead code on eject: end module.exports = { appBuild: resolve('../build'), appHtml: resolve('../index.html'), @@ -61,4 +63,6 @@ if (isInCreateReactAppSource) { appNodeModules: resolve('../node_modules'), ownNodeModules: resolve('../node_modules') }; +// Dead code on eject: start } +// Dead code on eject: end diff --git a/scripts/eject.js b/scripts/eject.js index b3d7b4ae60c..066689d0800 100644 --- a/scripts/eject.js +++ b/scripts/eject.js @@ -80,6 +80,8 @@ prompt('Are you sure you want to eject? This action is permanent. [y/N]', functi .replace(/^\/\*\*(\*(?!\/)|[^*])*\*\//, '') // Remove license header from AppleScript .replace(/^--.*\n/gm, '') + // Remove dead code on eject + .replace(/\/\/ Dead code on eject: start([\s\S]*?)\/\/ Dead code on eject: end/g, '') .trim() + '\n'; fs.writeFileSync(path.join(appPath, file), content); }); diff --git a/scripts/start.js b/scripts/start.js index 81bed9f098e..25627ab02be 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -17,9 +17,10 @@ var config = require('../config/webpack.config.dev'); var execSync = require('child_process').execSync; var opn = require('opn'); -// TODO: hide this behind a flag and eliminate dead code on eject. +// hide this behind a flag and eliminate dead code on eject. // This shouldn't be exposed to the user. var handleCompile; +// Dead code on eject: start var isSmokeTest = process.argv.some(arg => arg.indexOf('--smoke-test') > -1); if (isSmokeTest) { handleCompile = function (err, stats) { @@ -30,6 +31,7 @@ if (isSmokeTest) { } }; } +// Dead code on eject: end var friendlySyntaxErrorLabel = 'Syntax error:';