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 remaining lodash
dependencies
#13139
Changes from all commits
8533aa3
39dcd74
62560f4
f46e3e7
2c73185
dc0b4bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
// @flow | ||
|
||
import debounce from "lodash/debounce"; | ||
import slash from "slash"; | ||
import path from "path"; | ||
import fs from "fs"; | ||
|
@@ -135,27 +134,23 @@ export default async function ({ | |
let compiledFiles = 0; | ||
let startTime = null; | ||
|
||
const logSuccess = debounce( | ||
function () { | ||
if (startTime === null) { | ||
// This should never happen, but just in case it's better | ||
// to ignore the log message rather than making @babel/cli crash. | ||
return; | ||
} | ||
const logSuccess = util.debounce(function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh great! I wasn't sure about replacing in the earlier PR because of the |
||
if (startTime === null) { | ||
// This should never happen, but just in case it's better | ||
// to ignore the log message rather than making @babel/cli crash. | ||
return; | ||
} | ||
|
||
const diff = process.hrtime(startTime); | ||
|
||
console.log( | ||
`Successfully compiled ${compiledFiles} ${ | ||
compiledFiles !== 1 ? "files" : "file" | ||
} with Babel (${diff[0] * 1e3 + Math.round(diff[1] / 1e6)}ms).`, | ||
); | ||
compiledFiles = 0; | ||
startTime = null; | ||
}, | ||
100, | ||
{ trailing: true }, | ||
); | ||
const diff = process.hrtime(startTime); | ||
|
||
console.log( | ||
`Successfully compiled ${compiledFiles} ${ | ||
compiledFiles !== 1 ? "files" : "file" | ||
} with Babel (${diff[0] * 1e3 + Math.round(diff[1] / 1e6)}ms).`, | ||
); | ||
compiledFiles = 0; | ||
startTime = null; | ||
}, 100); | ||
|
||
if (!cliOptions.skipInitialBuild) { | ||
if (cliOptions.deleteDirOnStart) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import last from "lodash/last" | ||
import last from "lo-dash/last" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just an input/output fixture, but it was annoying when grepping for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol we want to ctrl+f and find no results |
||
|
||
export default class Container { | ||
last(key) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import deepClone from "lodash/cloneDeep"; | ||
import cloneDeep from "clone-deep"; | ||
import sourceMapSupport from "source-map-support"; | ||
import * as registerCache from "./cache"; | ||
import * as babel from "@babel/core"; | ||
|
@@ -42,7 +42,7 @@ function compile(code, filename) { | |
// sourceRoot can be overwritten | ||
{ | ||
sourceRoot: path.dirname(filename) + path.sep, | ||
...deepClone(transformOpts), | ||
...cloneDeep(transformOpts), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And the reason we probably want to keep this is because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, also people can pass any JS value as plugin options. |
||
filename, | ||
}, | ||
); | ||
|
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.
clone-deep is quite bloated package. Maybe try klona?
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.
My strategy for choosing the
clone-deep
package was "Ctrl+F forclone
in ouryarn.lock
file", so thanks for suggesting an alternative 😂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.
Oh it looks like
klona
requires Node.js >= 8, so until the Babel 8 release we cannot use it.