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 lodash deps #13057
Remove lodash deps #13057
Changes from all commits
0cad852
8a999b1
6bff19c
140441c
952092c
e060ed4
aa897f8
0639927
9333918
c34d89c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,11 @@ import { | |
import sourceMap from "source-map"; | ||
import { codeFrameColumns } from "@babel/code-frame"; | ||
import * as helpers from "./helpers"; | ||
import merge from "lodash/merge"; | ||
import assert from "assert"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import vm from "vm"; | ||
import QuickLRU from "quick-lru"; | ||
// @ts-ignore | ||
import escapeRegExp from "./escape-regexp.cjs"; | ||
import { fileURLToPath } from "url"; | ||
|
||
import { createRequire } from "module"; | ||
|
@@ -202,19 +199,17 @@ function run(task) { | |
|
||
// todo(flow->ts) add proper return type (added any, because empty object is inferred) | ||
function getOpts(self): any { | ||
const newOpts = merge( | ||
{ | ||
ast: true, | ||
cwd: path.dirname(self.loc), | ||
filename: self.loc, | ||
filenameRelative: self.filename, | ||
sourceFileName: self.filename, | ||
sourceType: "script", | ||
babelrc: false, | ||
inputSourceMap: task.inputSourceMap || undefined, | ||
}, | ||
opts, | ||
); | ||
const newOpts = { | ||
ast: true, | ||
cwd: path.dirname(self.loc), | ||
filename: self.loc, | ||
filenameRelative: self.filename, | ||
sourceFileName: self.filename, | ||
sourceType: "script", | ||
babelrc: false, | ||
inputSourceMap: task.inputSourceMap || undefined, | ||
...opts, | ||
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. It doesn't seem like we'd need to deep merge any of the options above so should be equivalent (or are all primitives) |
||
}; | ||
|
||
return resolveOptionPluginOrPreset(newOpts, optionsDir); | ||
} | ||
|
@@ -345,6 +340,10 @@ function validateFile(actualCode, expectedLoc, expectedCode) { | |
} | ||
} | ||
|
||
function escapeRegExp(string) { | ||
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&"); | ||
} | ||
|
||
function normalizeOutput(code, normalizePathSeparator?) { | ||
const projectRoot = path.resolve( | ||
path.dirname(fileURLToPath(import.meta.url)), | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import loClone from "lodash/clone"; | ||
import { NODE_FIELDS, BUILDER_KEYS } from "../definitions"; | ||
import validate from "../validators/validate"; | ||
import type * as t from ".."; | ||
|
@@ -23,7 +22,9 @@ export default function builder<T extends t.Node>( | |
|
||
let arg; | ||
if (i < countArgs) arg = args[i]; | ||
if (arg === undefined) arg = loClone(field.default); | ||
if (arg === undefined) { | ||
arg = Array.isArray(field.default) ? [] : field.default; | ||
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. 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. We should throw if we see a non-empty array or an object, so that we don't accidentally break this assumption in the future. 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. ah right, https://lodash.com/docs/#clone seems complicated, maybe we need to check what we do allow instead then given it could be anything? so string/boolean/null/[] 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, we can just throw if 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. |
||
} | ||
|
||
node[key] = arg; | ||
i++; | ||
|
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.
Changed this merge too (the only thing replaced is args, which is always set in our tests given it's babel-cli)