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

Revert "Move everything from lodash to lodash-es" #2591

Merged
merged 2 commits into from
Dec 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ In the case of Vue: `import { ... } from '@storybook/addon-knobs/vue';`

In the case of Angular: `import { ... } from '@storybook/addon-knobs/angular';`

### Storyshots Jest configuration

Storyshots users will need to add a line to their `jest.config.js`:

```js
transformIgnorePatterns: ['/node_modules/(?!lodash-es/.*)'],
```

We are working to resolve the issue that requires this: https://github.com/storybooks/storybook/issues/2570

## From version 3.1.x to 3.2.x

**NOTE:** technically this is a breaking change, but only if you use TypeScript. Sorry people!
Expand Down
2 changes: 1 addition & 1 deletion addons/knobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"deep-equal": "^1.0.1",
"global": "^4.3.2",
"insert-css": "^2.0.0",
"lodash-es": "^4.17.4",
"lodash.debounce": "^4.0.8",
"moment": "^2.20.1",
"prop-types": "^15.6.0",
"react-color": "^2.11.4",
Expand Down
2 changes: 1 addition & 1 deletion addons/knobs/src/components/Panel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import debounce from 'lodash-es/debounce';
import debounce from 'lodash.debounce';

import PropForm from './PropForm';
import Types from './types';
Expand Down
3 changes: 1 addition & 2 deletions app/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"json-loader": "^0.5.4",
"json-stringify-safe": "^5.0.1",
"json5": "^0.5.1",
"lodash-es": "^4.17.4",
"lodash.pick": "^4.4.0",
"postcss-flexbugs-fixes": "^3.0.0",
"postcss-loader": "^2.0.5",
"prop-types": "^15.5.10",
Expand All @@ -80,7 +80,6 @@
"zone.js": "^0.8.19"
},
"devDependencies": {
"@types/lodash-es": "^4.17.0",
"babel-cli": "^6.26.0",
"babel-plugin-transform-decorators": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@
// to provide @Inputs and subscribe to @Outputs, see
// https://github.com/angular/angular/issues/15360
// For the time being, the ViewContainerRef approach works pretty well.

import has from 'lodash-es/has';
import get from 'lodash-es/get';
import set from 'lodash-es/set';
import isFunction from 'lodash-es/isFunction';
import isUndefined from 'lodash-es/isUndefined';
import isEmpty from 'lodash-es/isEmpty';
import forEach from 'lodash-es/forEach';
import invoke from 'lodash-es/invoke';

import * as _ from 'lodash';
import {
Component,
Inject,
Expand All @@ -24,20 +15,16 @@ import {
SimpleChanges,
SimpleChange
} from '@angular/core';

import { STORY } from '../app.token';
import { NgStory, ICollection } from '../types';

const _ = { has, get, set, isFunction, isUndefined, isEmpty , forEach, invoke };

@Component({
selector: 'app-root',
template: '<ng-template #target></ng-template>'
})
export class AppComponent implements AfterViewInit, OnDestroy {
@ViewChild('target', { read: ViewContainerRef })
target: ViewContainerRef;

constructor(
private cfr: ComponentFactoryResolver,
@Inject(STORY) private data: NgStory
Expand Down Expand Up @@ -103,7 +90,7 @@ export class AppComponent implements AfterViewInit, OnDestroy {
}

if (_.isFunction(props.ngModelChange)) {
_.invoke(instance, 'registerOnChange', props.ngModelChange);
_.invoke(instance, 'registerOnChange', props.ngModelChange);
}
}
}
25 changes: 22 additions & 3 deletions app/angular/src/client/preview/angular/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import {
} from '@angular/core';
import {FormsModule} from '@angular/forms'

import _debounce from 'lodash-es/debounce';

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './components/app.component';
Expand All @@ -33,7 +31,28 @@ interface IComponent extends Type<any> {
propsMetadata: any[]
}

const debounce = (func: IRenderStoryFn | IRenderErrorFn) => _debounce(func, 100);
// Taken from https://davidwalsh.name/javascript-debounce-function
// We don't want to pull underscore
const debounce = (func: IRenderStoryFn | IRenderErrorFn,
wait: number = 100,
immediate: boolean = false): () => void => {
let timeout: any;
return function () {
const context = this, args = arguments;
const later = function () {
timeout = null;
if (!immediate) {
func.apply(context, args);
}
};
const callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) {
func.apply(context, args);
}
};
};

const getComponentMetadata = (
{ component, props = {}, propsMeta = {}, moduleMetadata = {
Expand Down
2 changes: 1 addition & 1 deletion app/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"json-loader": "^0.5.7",
"json-stringify-safe": "^5.0.1",
"json5": "^0.5.1",
"lodash-es": "^4.17.4",
"lodash.flattendeep": "^4.4.0",
"markdown-loader": "^2.0.1",
"npmlog": "^4.1.2",
"postcss-flexbugs-fixes": "^3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion app/react/src/client/preview/element_check.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import flattenDeep from 'lodash-es/flattenDeep';
import flattenDeep from 'lodash.flattendeep';

// return true if the element is renderable with react fiber
export const isValidFiberElement = element =>
Expand Down
2 changes: 1 addition & 1 deletion dangerfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fail, danger } from 'danger';
import { flatten, intersection, isEmpty, includes } from 'lodash-es';
import { flatten, intersection, isEmpty, includes } from 'lodash';

const pkg = require('./package.json'); // eslint-disable-line import/newline-after-import
const prLogConfig = pkg['pr-log'];
Expand Down
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module.exports = {
'<rootDir>/examples/cra-kitchen-sink',
'<rootDir>/examples/official-storybook',
],
transformIgnorePatterns: ['/node_modules/(?!lodash-es/.*)'],
testPathIgnorePatterns: ['/node_modules/', 'addon-jest.test.js', '/cli/test/'],
collectCoverage: false,
collectCoverageFrom: [
Expand Down
4 changes: 3 additions & 1 deletion lib/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"global": "^4.3.2",
"json-stringify-safe": "^5.0.1",
"keycode": "^2.1.9",
"lodash-es": "^4.17.4",
"lodash.debounce": "^4.0.8",
"lodash.pick": "^4.4.0",
"lodash.sortby": "^4.7.0",
"podda": "^1.2.2",
"prop-types": "^15.6.0",
"qs": "^6.5.1",
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/modules/api/actions/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pick from 'lodash-es/pick';
import pick from 'lodash.pick';

export function jumpToStory(storyKinds, selectedKind, selectedStory, direction) {
const flatteredStories = [];
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/modules/shortcuts/actions/shortcuts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pick from 'lodash-es/pick';
import pick from 'lodash.pick';
import { features } from '../../../libs/key_events';
import apiActions from '../../api/actions';

Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/modules/ui/components/stories_panel/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import pick from 'lodash-es/pick';
import pick from 'lodash.pick';
import Header from './header';
import Stories from './stories_tree';
import TextFilter from './text_filter';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import debounce from 'lodash-es/debounce';
import debounce from 'lodash.debounce';
import { baseFonts } from '@storybook/components';

const defaultTextValue = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { shallow, mount } from 'enzyme';
import React from 'react';
import TextFilter from './text_filter';

jest.mock('lodash-es/debounce', () => jest.fn(fn => fn));
jest.mock('lodash.debounce', () => jest.fn(fn => fn));

describe('manager.ui.components.stories_panel.test_filter', () => {
describe('render', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/modules/ui/containers/layout.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import pick from 'lodash-es/pick';
import pick from 'lodash.pick';
import Layout from '../components/layout';
import genPoddaLoader from '../libs/gen_podda_loader';
import compose from '../../../compose';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/src/modules/ui/libs/filters.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Fuse from 'fuse.js';
import sortBy from 'lodash-es/sortBy';
import sortBy from 'lodash.sortby';

const searchOptions = {
shouldSort: false,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"chromatic": "npm --prefix examples/official-storybook run chromatic"
},
"devDependencies": {
"@types/lodash": "^4.14.91",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.1.2",
Expand Down Expand Up @@ -72,7 +73,7 @@
"jest-jasmine2": "^22.0.4",
"lerna": "^2.5.1",
"lint-staged": "^6.0.0",
"lodash-es": "^4.17.4",
"lodash": "^4.17.4",
"nodemon": "^1.14.3",
"npmlog": "^4.1.2",
"prettier": "^1.9.2",
Expand Down
14 changes: 6 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,7 @@
version "2.8.2"
resolved "https://registry.yarnpkg.com/@types/jasmine/-/jasmine-2.8.2.tgz#6ae4d8740c0da5d5a627df725b4eed71b8e36668"

"@types/lodash-es@^4.17.0":
version "4.17.0"
resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.0.tgz#ed9044d62ee36a93e0650b112701986b1c74c766"
dependencies:
"@types/lodash" "*"

"@types/lodash@*":
"@types/lodash@^4.14.91":
version "4.14.91"
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.91.tgz#794611b28056d16b5436059c6d800b39d573cd3a"

Expand Down Expand Up @@ -8438,7 +8432,7 @@ lockfile@~1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/lockfile/-/lockfile-1.0.3.tgz#2638fc39a0331e9cac1a04b71799931c9c50df79"

lodash-es@^4.17.4, lodash-es@^4.2.1:
lodash-es@^4.2.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7"

Expand Down Expand Up @@ -8517,6 +8511,10 @@ lodash.cond@^4.3.0:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5"

lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"

lodash.defaults@^4.2.0:
version "4.2.0"
resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c"
Expand Down