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

v7.9.0 (CPD-11491) - Optional removal of console.log statements #112

Merged
merged 10 commits into from
Feb 5, 2018

Conversation

xander-marjoram
Copy link
Contributor

Added a value to the config.js that can override the removal of console.log() statements that would usually happen automatically for production builds.

Had to revert Jest to 21.2.1 as it was causing problems.

@xander-marjoram xander-marjoram requested a review from a team as a code owner February 2, 2018 14:58
@ashleynolan
Copy link
Contributor

Few conflicts need resolving

@xander-marjoram xander-marjoram changed the title v7.8.0 (CPD-11491) - Optional removal of console.log statements v7.9.0 (CPD-11491) - Optional removal of console.log statements Feb 2, 2018
@fozzie-bot
Copy link

fozzie-bot commented Feb 2, 2018

Messages
📖

🔥 👏 You’re a deletion machine!

Generated by 🚫 dangerJS

@xander-marjoram
Copy link
Contributor Author

@ashleynolan Resolved

README.md Outdated

- #### `stripDebug`

Type: `boolean`
Copy link
Contributor

@DamianMullins DamianMullins Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add the default type like some of the other options do above.

README.md Outdated
@@ -443,7 +444,7 @@ Will add a content hash to the JS and CSS filenames, generating a new filename i

Type: `boolean`

Default is set to false, when set to true this will bundle a versioned css file e.g `'filename-[version].css'`.
Default is set to `false`, when set to true this will bundle a versioned css file e.g `'filename-[version].css'`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this one is also missing the default option..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my bad, I can fix this in my PR as part of the original ticket unless @xander-marjoram wants to amend it here? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinrodrigues I'll fix it here, if you haven't already 👍

config.js Outdated
@@ -45,7 +45,8 @@ const ConfigOptions = () => {
},
jsDir: 'js',
lintPaths: [''],
usePackageVersion: false
usePackageVersion: false,
stripDebug: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the relevant unit tests to config.test.js please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in latest commit 👍

@@ -134,7 +134,7 @@ gulp.task('scripts:bundle', () => {
))

// if production build, rip out our console logs
.pipe(gulpif(config.isProduction,
.pipe(gulpif(config.isProduction && config.js.stripDebug,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a silly question but why do we need to have this new option? Shouldn't we strip console logs / debuggers from production code anyway? Or is there a reason we use them in production.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a request from the OrderWeb team. They want to have production type code with debug statements for when they release to QA.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that would be worth adding is the ability to set this config variable through an environment variable. So something like gulp --stripDebug=false would set this to false (as I imagine that might be how they need to set it to be different on every release server).

Copy link
Contributor Author

@xander-marjoram xander-marjoram Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ashleynolan Should I add that in this PR?
(Verbal answer was "yes")

Fixed in latest commit.

Copy link
Contributor

@ashleynolan ashleynolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good once those comments from D-dogg have been committed 👍

@@ -71,7 +71,7 @@
"handlebars-helpers": "^0.10.0",
"helper-markdown": "^1.0.0",
"helper-md": "^0.2.2",
"jest-cli": "^22.1.4",
"jest-cli": "^21.2.1",
Copy link
Contributor

@DamianMullins DamianMullins Feb 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, one of the issues with v22.1.4 was that an error of "TypeError: environment.setup is not a function" was being thrown in some repos, there is a discussion on the Jest GitHub repo where it seems like one of the dependencies hasn't yet been updated,

expect(config.js.stripDebug).toBe(true);
});

it('strip debug can be updated', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stripDebug.

Copy link
Contributor Author

@xander-marjoram xander-marjoram Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinrodrigues Should I change the ones that say 'is production' as well then, and things like 'scss directory' rather than 'scssDir'?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. There's a mixture of descriptions in this file, usually I add the 'thing' I'm talking about or testing as "methodName" `` (with backticks) so it's clear what we're actually referring too in the test itself, I've also found it helps to find that reference quicker when a test fails. :)

Copy link
Contributor

@DamianMullins DamianMullins Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep things consistent with these names? All of the existing tests use full, space separated words. I don't mind which one we go with as long as they are consistent 🇸🇱

It's probably one to come back to at some point though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've chosen to use the variable names as they are found in the config, but with backticks to make it clearer.

expect(config.js.usePackageVersion).toBe(false);
});

it('usePackageVersion can be updated', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No backticks around usePackageVersion here.

@kevinrodrigues kevinrodrigues merged commit dd7984a into master Feb 5, 2018
@kevinrodrigues kevinrodrigues deleted the CPD-11491 branch February 5, 2018 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants