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
Remove use of momentjs #1652
Remove use of momentjs #1652
Conversation
'YYYYMMDDhhmmss' | ||
); | ||
const localUTCDate = new Date(response.data.startTime); | ||
const date = getYYYYMMddHHmmssDateFormat(localUTCDate); |
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.
This is used in naming the debug log that gets downloaded when running SFDX: Get Debug Logs
@@ -135,16 +137,17 @@ export class LogFileSelector | |||
if (logInfos.length > 0) { | |||
const logItems = logInfos.map(logInfo => { | |||
const icon = '$(file-text) '; | |||
const localUTCDate = new Date(logInfo.StartTime); | |||
const localDateFormatted = localUTCDate.toLocaleDateString( |
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.
@@ -5,7 +5,10 @@ | |||
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause | |||
*/ | |||
|
|||
import * as moment from 'moment'; | |||
import { |
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.
expect(doubleDigit).to.equal('09'); | ||
}); | ||
|
||
it('Should return a the same two character string when provided a double digit number', () => { |
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.
typo in test description
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.
Changes look good! What made the momentjs module not be compatible with tree-shaking?
@AnanyaJha this thread (moment/moment#2373) goes a bit more in depth into the challenges of breaking it into smaller pieces using tools like webpack but it boils down to the way the library is structured. |
optionYYYYMMddHHmmss | ||
); | ||
|
||
const dateTimeFormatRegex = /([0-9]{2})(\/)([0-9]{2})(\/)([0-9]{4})(\,)\s([0-9])(:)([0-9]{2})(:)([0-9]{2})\s(AM|PM)/; |
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.
@lcampos This test fails locally for me because the conversion from utc to mst causes the time stamp to be 10:34 instead of 9:34. The regex needs to be updated to:
([0-9]{2})(/)([0-9]{2})(/)([0-9]{4})(,)\s([0-9]{1,2})(:)([0-9]{2})(:)([0-9]{2})\s(AM|PM)
optionHHmm | ||
); | ||
|
||
const timeFormatRegex = /([0-9])(:)([0-9]{2})\s(AM|PM)/; |
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.
If we update the last example, we should really update this one to ([0-9]{1,2})(:)([0-9]{2})\s(AM|PM). This one passes for me locally, but only because we beginning the regex at the start of the string.
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.
Thanks for pointing this out, I'll open a follow up PR to take care of these failures.
What does this PR do?
This PR replaces momentjs by using the native locale methods and other date formatting utilities. This is part of the changes needed to reduce the size of the extensions. By removing momentjs, we remove a dependency on a module that is not tree-shakeable.
What issues does this PR fix or reference?
@W-6587405@