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

chore: remove lodash from direct dependencies #1834

Merged
merged 4 commits into from Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions packages/generators/package.json
Expand Up @@ -13,7 +13,6 @@
"@webpack-cli/package-utils": "^1.0.1-rc.0",
"@webpack-cli/utils": "^1.0.1-rc.0",
"@webpack-cli/webpack-scaffold": "^1.0.1-rc.0",
"lodash": "4.17.19",
"colorette": "^1.2.1",
"log-symbols": "3.0.0",
"mkdirp": "1.0.3",
Expand All @@ -23,7 +22,6 @@
"webpack-cli": "3.x.x || 4.x.x"
},
"devDependencies": {
"@types/lodash": "4.14.149",
"@types/mkdirp": "1.0.0",
"@types/yeoman-assert": "^3.1.1",
"@types/yeoman-generator": "3.1.4",
Expand Down
5 changes: 2 additions & 3 deletions packages/generators/src/loader-generator.ts
@@ -1,7 +1,6 @@
import _ from 'lodash';
import path from 'path';
import addonGenerator from './addon-generator';

import { toKebabCase } from './utils/helpers';
/**
* Formats a string into webpack loader format
* (eg: 'style-loader', 'raw-loader')
Expand All @@ -10,7 +9,7 @@ import addonGenerator from './addon-generator';
* @returns {string} The formatted string
*/
export function makeLoaderName(name: string): string {
name = _.kebabCase(name);
name = toKebabCase(name);
if (!/loader$/.test(name)) {
name += '-loader';
}
Expand Down
7 changes: 3 additions & 4 deletions packages/generators/src/plugin-generator.ts
@@ -1,7 +1,6 @@
import _ from 'lodash';
import path from 'path';
import addonGenerator from './addon-generator';

import { toKebabCase, toUpperCamelCase } from './utils/helpers';
/**
* A yeoman generator class for creating a webpack
* plugin project. It adds some starter plugin code
Expand All @@ -14,7 +13,7 @@ const PluginGenerator = addonGenerator(
[
{
default: 'my-webpack-plugin',
filter: _.kebabCase,
filter: toKebabCase,
message: 'Plugin name',
name: 'name',
type: 'input',
Expand All @@ -31,7 +30,7 @@ const PluginGenerator = addonGenerator(
'examples/simple/src/static-esm-module.js.tpl',
],
['src/_index.js.tpl', 'examples/simple/_webpack.config.js.tpl'],
(gen): object => ({ name: _.upperFirst(_.camelCase(gen.props.name)) }),
(gen): object => ({ name: toUpperCamelCase(gen.props.name) }),
);

export default PluginGenerator;
22 changes: 22 additions & 0 deletions packages/generators/src/utils/helpers.ts
@@ -0,0 +1,22 @@
const regex = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g;

/**
* Convert str to kebab-case
* @param str input string
* @returns output string
*/
export function toKebabCase(str: string): string {
return str.match(regex).join('-').toLowerCase();
}

/**
* Convert str to UpperCamelCase
* @param str import string
* @returns {string} output string
*/
export function toUpperCamelCase(str: string): string {
return str
.match(regex)
.map((x) => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase())
.join('');
}
1 change: 0 additions & 1 deletion packages/migrate/__testfixtures__/failing.js
@@ -1,6 +1,5 @@
const webpack = require('webpack');
const nodeEnvironment = process.env.NODE_ENV;
const _ = require("lodash");

const config = {
entry: {
Expand Down
2 changes: 0 additions & 2 deletions packages/migrate/package.json
Expand Up @@ -15,7 +15,6 @@
"inquirer": "7.1.0",
"jscodeshift": "0.7.0",
"listr": "0.14.3",
"lodash": "4.17.19",
"p-each-series": "2.1.0",
"p-lazy": "3.0.0"
},
Expand All @@ -27,7 +26,6 @@
"@types/diff": "4.0.2",
"@types/inquirer": "6.5.0",
"@types/listr": "0.14.2",
"@types/lodash": "^4.14.149",
"webpack": "4.x.x"
},
"files": [
Expand Down
@@ -1,5 +1,3 @@
import isEmpty = require('lodash/isEmpty');

import { createOrUpdatePluginByName, findPluginsByName, safeTraverse } from '@webpack-cli/utils';

import { JSCodeshift, Node } from '../types/NodePath';
Expand All @@ -9,6 +7,8 @@ interface LoaderOptions {
minimize?: boolean;
}

const isEmpty = (obj: LoaderOptions): boolean => Object.keys(obj).length === 0;

/**
*
* Transform which adds context information for old loaders by injecting a `LoaderOptionsPlugin`
Expand Down
7 changes: 1 addition & 6 deletions yarn.lock
Expand Up @@ -2575,11 +2575,6 @@
"@types/node" "*"
rxjs "^6.5.1"

"@types/lodash@4.14.149", "@types/lodash@^4.14.149":
version "4.14.149"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.149.tgz#1342d63d948c6062838fbf961012f74d4e638440"
integrity sha512-ijGqzZt/b7BfzcK9vTrS6MFljQRPn5BFWOx8oE0GYxribu6uV+aA9zZuXI1zc/etK9E8nrgdoF2+LgUw7+9tJQ==

"@types/minimatch@*", "@types/minimatch@^3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
Expand Down Expand Up @@ -8488,7 +8483,7 @@ lodash@4.17.15:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==

lodash@4.17.19, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.2.1:
lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.2.1:
rishabh3112 marked this conversation as resolved.
Show resolved Hide resolved
version "4.17.19"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b"
integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==
Expand Down