-
Notifications
You must be signed in to change notification settings - Fork 11
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
Conversation
Few conflicts need resolving |
Generated by 🚫 dangerJS |
@ashleynolan Resolved |
5a8e090
to
429d924
Compare
README.md
Outdated
|
||
- #### `stripDebug` | ||
|
||
Type: `boolean` |
There was a problem hiding this comment.
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'`. |
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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? :)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this 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", |
There was a problem hiding this comment.
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,
test/config.test.js
Outdated
expect(config.js.stripDebug).toBe(true); | ||
}); | ||
|
||
it('strip debug can be updated', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stripDebug
.
There was a problem hiding this comment.
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'?
There was a problem hiding this comment.
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. :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
test/config.test.js
Outdated
expect(config.js.usePackageVersion).toBe(false); | ||
}); | ||
|
||
it('usePackageVersion can be updated', () => { |
There was a problem hiding this comment.
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.
f681170
to
87e65e9
Compare
…n the config object
feb83d5
to
49aa7e4
Compare
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.