Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eliminate dev-only code on eject #53 #191 #206

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ===
Expand All @@ -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 = {
Expand All @@ -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'),
Expand All @@ -61,4 +63,6 @@ if (isInCreateReactAppSource) {
appNodeModules: resolve('../node_modules'),
ownNodeModules: resolve('../node_modules')
};
// Dead code on eject: start
}
// Dead code on eject: end
2 changes: 2 additions & 0 deletions scripts/eject.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
4 changes: 3 additions & 1 deletion scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -30,6 +31,7 @@ if (isSmokeTest) {
}
};
}
// Dead code on eject: end

var friendlySyntaxErrorLabel = 'Syntax error:';

Expand Down