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

Tech: migrate to es version of lodash (and shows dist size stats) #20910

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
7ebf449
migrate to es version of lodash
ndelangen Feb 2, 2023
85a1be4
fix lockfile
ndelangen Feb 2, 2023
ecc3966
add lodash-es to jest transform config
ndelangen Feb 2, 2023
52e6444
more lodash to es version conversion
ndelangen Feb 2, 2023
78e7c89
more lodash to lodash-es conversion
ndelangen Feb 2, 2023
8b1a543
fix linting
ndelangen Feb 2, 2023
82f4abf
fix linting
ndelangen Feb 2, 2023
41f3401
fix linting
ndelangen Feb 2, 2023
9633b01
add stats generation script
ndelangen Feb 2, 2023
8893480
adds stats
ndelangen Feb 2, 2023
24d85a4
improvement bundlesize
ndelangen Feb 2, 2023
71b8ad5
stats
ndelangen Feb 2, 2023
39eefa2
Merge branch 'norbert/stats-analysis-baseline' into norbert/stats-ana…
ndelangen Feb 2, 2023
57d63bd
cleanup
ndelangen Feb 2, 2023
35cf4f8
Merge branch 'norbert/stats-analysis-baseline' into norbert/stats-ana…
ndelangen Feb 3, 2023
ddda55b
fix ordering of exports
ndelangen Feb 3, 2023
43751a6
Merge branch 'norbert/stats-analysis-baseline' into norbert/stats-ana…
ndelangen Feb 3, 2023
7398de2
update stats
ndelangen Feb 3, 2023
abed182
Merge branch 'norbert/stats-analysis-baseline' into norbert/stats-ana…
ndelangen Feb 3, 2023
c5dd518
regen stats
ndelangen Feb 3, 2023
df6609d
use CSF version without lodash
ndelangen Feb 3, 2023
f950037
cleanup
ndelangen Feb 3, 2023
b0e1fb0
fix linting
ndelangen Feb 3, 2023
83a07a3
Merge branch 'norbert/stats-analysis-baseline' into norbert/stats-ana…
ndelangen Feb 3, 2023
e3b1d35
Merge branch 'norbert/stats-analysis-baseline' into norbert/stats-ana…
ndelangen Feb 3, 2023
812ea30
bump csf package
ndelangen Feb 3, 2023
4fd3146
remove env setup for cjs bundles
ndelangen Feb 3, 2023
ef244f8
do not load esm in cjs bundle
ndelangen Feb 3, 2023
5ef185a
add alias
ndelangen Feb 3, 2023
0c0b13b
fix lodash manually, oof
ndelangen Feb 3, 2023
e1382fb
bump lockfiles
ndelangen Feb 3, 2023
9ff5359
Merge branch 'norbert/fix-next' into norbert/stats-analysis
ndelangen Feb 3, 2023
583902f
Merge branch 'norbert/fix-next' into norbert/stats-analysis
ndelangen Feb 3, 2023
7798f6a
Merge branch 'norbert/stats-analysis-baseline' into norbert/stats-ana…
ndelangen Feb 3, 2023
b317be2
Merge branch 'norbert/stats-analysis-baseline' into norbert/stats-ana…
ndelangen Feb 4, 2023
5374ae8
Merge branch 'norbert/stats-analysis-baseline' into norbert/stats-ana…
ndelangen Feb 6, 2023
bb04939
cleanup
ndelangen Feb 7, 2023
73a592f
Merge branch 'norbert/bench-dist-stats' into norbert/stats-analysis
ndelangen Feb 15, 2023
4f7a36f
Merge branch 'norbert/bench-dist-stats' into norbert/stats-analysis
ndelangen Feb 27, 2023
df3c3d5
Merge branch 'norbert/bench-dist-stats' into norbert/stats-analysis
ndelangen Feb 28, 2023
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
16 changes: 4 additions & 12 deletions code/frameworks/angular/src/builders/build-storybook/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,13 @@
"compodocArgs": {
"type": "array",
"description": "Compodoc options : https://compodoc.app/guides/options.html. Options `-p` with tsconfig path and `-d` with workspace root is always given.",
"default": [
"-e",
"json"
],
"default": ["-e", "json"],
"items": {
"type": "string"
}
},
"webpackStatsJson": {
"type": [
"boolean",
"string"
],
"type": ["boolean", "string"],
"description": "Write Webpack Stats JSON to disk",
"default": false
},
Expand Down Expand Up @@ -110,9 +104,7 @@
}
},
"additionalProperties": false,
"required": [
"input"
]
"required": ["input"]
},
{
"type": "string",
Expand All @@ -121,4 +113,4 @@
]
}
}
}
}
11 changes: 3 additions & 8 deletions code/frameworks/angular/src/builders/start-storybook/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@
"compodocArgs": {
"type": "array",
"description": "Compodoc options : https://compodoc.app/guides/options.html. Options `-p` with tsconfig path and `-d` with workspace root is always given.",
"default": [
"-e",
"json"
],
"default": ["-e", "json"],
"items": {
"type": "string"
}
Expand Down Expand Up @@ -129,9 +126,7 @@
}
},
"additionalProperties": false,
"required": [
"input"
]
"required": ["input"]
},
{
"type": "string",
Expand All @@ -140,4 +135,4 @@
]
}
}
}
}
4 changes: 3 additions & 1 deletion code/jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ module.exports = {
'^.+\\.(t|j)sx?$': '@swc/jest',
'^.+\\.mdx$': '@storybook/addon-docs/jest-transform-mdx',
},
transformIgnorePatterns: ['/node_modules/(?!@angular|rxjs|nanoid|uuid|lit-html|@mdx-js)'],
transformIgnorePatterns: [
'/node_modules/(?!@angular|rxjs|nanoid|uuid|lit-html|@mdx-js|lodash-es)',
],
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
testPathIgnorePatterns: [
'/storybook-static/',
Expand Down
1 change: 1 addition & 0 deletions code/lib/builder-vite/src/optimizeDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const INCLUDE_CANDIDATES = [
'isobject',
'jest-mock',
'loader-utils',
'lodash-es',
'lodash/cloneDeep',
'lodash/isFunction',
'lodash/isPlainObject',
Expand Down
3 changes: 1 addition & 2 deletions code/lib/codemod/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import camelCase from 'lodash/camelCase.js';
import upperFirst from 'lodash/upperFirst.js';
import { camelCase, upperFirst } from 'lodash';

export const sanitizeName = (name: string) => {
let key = upperFirst(camelCase(name));
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"@storybook/docs-mdx": "next",
"@storybook/global": "^5.0.0",
"@storybook/node-logger": "7.0.0-beta.40",
"@storybook/preview-api": "7.0.0-beta.40",
"@storybook/telemetry": "7.0.0-beta.40",
"@storybook/types": "7.0.0-beta.40",
"@types/detect-port": "^1.3.0",
Expand Down Expand Up @@ -96,6 +95,7 @@
"ws": "^8.2.3"
},
"devDependencies": {
"@storybook/preview-api": "7.0.0-beta.40",
"@types/compression": "^1.7.0",
"@types/ip": "^1.1.0",
"@types/serve-favicon": "^2.5.2",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/core-server/src/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
StoryId,
StoryName,
} from '@storybook/types';
import { userOrAutoTitleFromSpecifier, sortStoriesV7 } from '@storybook/preview-api';
import { userOrAutoTitleFromSpecifier, sortStoriesV7 } from '@storybook/preview-api'; // eslint-disable-line import/no-extraneous-dependencies
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
import { normalizeStoryPath } from '@storybook/core-common';
import { logger } from '@storybook/node-logger';
import { getStorySortParameter, NoMetaError } from '@storybook/csf-tools';
Expand Down
4 changes: 2 additions & 2 deletions code/lib/manager-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"@storybook/theming": "7.0.0-beta.40",
"@storybook/types": "7.0.0-beta.40",
"dequal": "^2.0.2",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"memoizerific": "^1.11.3",
"semver": "^7.3.7",
"store2": "^2.14.2",
Expand All @@ -60,7 +60,7 @@
},
"devDependencies": {
"@jest/globals": "^29.3.1",
"@types/lodash": "^4.14.167",
"@types/lodash-es": "^4.17.6",
"@types/qs": "^6",
"flush-promises": "^1.0.2",
"qs": "^6.10.0",
Expand Down
2 changes: 1 addition & 1 deletion code/lib/manager-api/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, {
useMemo,
useRef,
} from 'react';
import mergeWith from 'lodash/mergeWith.js';
import { mergeWith } from 'lodash-es';
import type {
Args,
ArgTypes,
Expand Down
11 changes: 6 additions & 5 deletions code/lib/manager-api/src/lib/merge.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import mergeWith from 'lodash/mergeWith.js';
import isEqual from 'lodash/isEqual.js';
import { mergeWith, isEqual } from 'lodash-es';

import { logger } from '@storybook/client-logger';

export default <TObj = any>(a: TObj, b: Partial<TObj>) =>
mergeWith({}, a, b, (objValue: TObj, srcValue: Partial<TObj>) => {
if (Array.isArray(srcValue) && Array.isArray(objValue)) {
srcValue.forEach((s) => {
const existing = objValue.find((o) => o === s || isEqual(o, s));
srcValue.forEach((srcItem) => {
const existing = objValue.find(
(objItem) => objItem === srcItem || isEqual(objItem, srcItem)
);
if (!existing) {
objValue.push(s);
objValue.push(srcItem);
}
});

Expand Down
3 changes: 1 addition & 2 deletions code/lib/manager-api/src/lib/stories.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import memoize from 'memoizerific';
import { dedent } from 'ts-dedent';
import countBy from 'lodash/countBy.js';
import mapValues from 'lodash/mapValues.js';
import { countBy, mapValues } from 'lodash-es';
import { sanitize } from '@storybook/csf';
import type {
StoryId,
Expand Down
2 changes: 1 addition & 1 deletion code/lib/manager-api/src/modules/layout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { global } from '@storybook/global';
import pick from 'lodash/pick.js';
import { pick } from 'lodash-es';
import { dequal as deepEqual } from 'dequal';
import { create } from '@storybook/theming/create';
import { SET_CONFIG } from '@storybook/core-events';
Expand Down
3 changes: 2 additions & 1 deletion code/lib/preview-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@
"@storybook/csf": "next",
"@storybook/global": "^5.0.0",
"@storybook/types": "7.0.0-beta.40",
"@types/lodash-es": "^4.17.6",
"@types/qs": "^6.9.5",
"dequal": "^2.0.2",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"memoizerific": "^1.11.3",
"qs": "^6.10.0",
"slash": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { global } from '@storybook/global';
import merge from 'lodash/merge.js';
import { merge } from 'lodash-es';
import {
CONFIG_ERROR,
CURRENT_STORY_WAS_SET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import qs from 'qs';
import { dedent } from 'ts-dedent';
import type { Args } from '@storybook/types';
import { once } from '@storybook/client-logger';
import isPlainObject from 'lodash/isPlainObject.js';
import { isPlainObject } from 'lodash-es';

// Keep this in sync with validateArgs in router/src/utils.ts
const VALIDATION_REGEXP = /^[a-zA-Z0-9 _-]*$/;
Expand Down
3 changes: 1 addition & 2 deletions code/lib/preview-api/src/modules/store/StoryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import type {
StoryContextForLoaders,
StoryId,
} from '@storybook/types';
import mapValues from 'lodash/mapValues.js';
import pick from 'lodash/pick.js';
import { mapValues, pick } from 'lodash-es';
import { SynchronousPromise } from 'synchronous-promise';

import { HooksContext } from '../addons';
Expand Down
2 changes: 1 addition & 1 deletion code/lib/preview-api/src/modules/store/args.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dequal as deepEqual } from 'dequal';
import type { Renderer, Args, ArgTypes, InputType, SBType, StoryContext } from '@storybook/types';
import { once } from '@storybook/client-logger';
import isPlainObject from 'lodash/isPlainObject.js';
import { isPlainObject } from 'lodash-es';
import { dedent } from 'ts-dedent';

const INCOMPATIBLE = Symbol('incompatible');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mapValues from 'lodash/mapValues.js';
import { mapValues } from 'lodash-es';
import type {
ArgTypes,
GlobalTypes,
Expand Down
2 changes: 1 addition & 1 deletion code/lib/preview-api/src/modules/store/filterArgTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StrictArgTypes } from '@storybook/types';
import pickBy from 'lodash/pickBy.js';
import { pickBy } from 'lodash-es';

export type PropDescriptor = string[] | RegExp;

Expand Down
2 changes: 1 addition & 1 deletion code/lib/preview-api/src/modules/store/inferArgTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mapValues from 'lodash/mapValues.js';
import { mapValues } from 'lodash-es';
import { dedent } from 'ts-dedent';
import { logger } from '@storybook/client-logger';
import type { Renderer, SBType, ArgTypesEnhancer } from '@storybook/types';
Expand Down
2 changes: 1 addition & 1 deletion code/lib/preview-api/src/modules/store/inferControls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import mapValues from 'lodash/mapValues.js';
import { mapValues } from 'lodash-es';
import { logger } from '@storybook/client-logger';
import type { Renderer, ArgTypesEnhancer, SBEnumType, StrictInputType } from '@storybook/types';
import { filterArgTypes } from './filterArgTypes';
Expand Down
2 changes: 1 addition & 1 deletion code/lib/preview-api/src/modules/store/parameters.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Utilities for handling parameters
import type { Parameters } from '@storybook/types';
import isPlainObject from 'lodash/isPlainObject.js';
import { isPlainObject } from 'lodash-es';

/**
* Safely combine parameters recursively. Only copy objects when needed.
Expand Down
5 changes: 4 additions & 1 deletion code/lib/router/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { once } from '@storybook/client-logger';
import { dequal as deepEqual } from 'dequal';
import isPlainObject from 'lodash/isPlainObject.js';
import memoize from 'memoizerific';
import type { IStringifyOptions } from 'qs';
import qs from 'qs';
Expand All @@ -14,6 +13,10 @@ export interface StoryData {

const splitPathRegex = /\/([^/]+)\/(?:(.*)_)?([^/]+)?/;

function isPlainObject(value: any): boolean {
valentinpalkovic marked this conversation as resolved.
Show resolved Hide resolved
return Object.getPrototypeOf(value) === null || Object === value.constructor;
}

export const parsePath: (path: string | undefined) => StoryData = memoize(1000)(
(path: string | undefined | null) => {
const result: StoryData = {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/store/template/stories/args.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/types';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
import { pick } from 'lodash';
import { pick } from 'lodash-es';

export default {
component: globalThis.Components.Pre,
Expand Down
4 changes: 2 additions & 2 deletions code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"@testing-library/user-event": "^13.2.1",
"@types/express": "^4.17.11",
"@types/fs-extra": "^11.0.1",
"@types/lodash": "^4.14.167",
"@types/lodash-es": "^4.17.6",
"@types/node": "^16.0.0",
"@types/react": "^16.14.34",
"@types/react-dom": "^16.9.14",
Expand Down Expand Up @@ -239,7 +239,7 @@
"jest-watch-typeahead": "^2.2.1",
"lerna": "^6.4.0",
"lint-staged": "^10.5.4",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"node-gyp": "^8.4.0",
"nx": "^15.4.5",
"playwright": "1.30.0",
Expand Down
3 changes: 2 additions & 1 deletion code/renderers/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,14 @@
"@storybook/types": "7.0.0-beta.40",
"@types/escodegen": "^0.0.6",
"@types/estree": "^0.0.51",
"@types/lodash-es": "^4.17.6",
"@types/node": "^16.0.0",
"acorn": "^7.4.1",
"acorn-jsx": "^5.3.1",
"acorn-walk": "^7.2.0",
"escodegen": "^2.0.0",
"html-tags": "^3.1.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"prop-types": "^15.7.2",
"react-element-to-jsx-string": "^15.0.0",
"ts-dedent": "^2.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable @typescript-eslint/ban-types */
import isPlainObject from 'lodash/isPlainObject.js';
import isFunction from 'lodash/isFunction.js';
import isString from 'lodash/isString.js';
import { isPlainObject, isFunction, isString } from 'lodash-es';
import reactElementToJSXString from 'react-element-to-jsx-string';
import {
type PropDef,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import mapValues from 'lodash/mapValues.js';
import { mapValues } from 'lodash-es';
import { PureArgsTable as ArgsTable } from '@storybook/blocks';
import { inferControls } from '@storybook/preview-api';
import { ThemeProvider, themes, convert } from '@storybook/theming';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import mapValues from 'lodash/mapValues.js';
import { mapValues } from 'lodash-es';
import { PureArgsTable as ArgsTable } from '@storybook/blocks';
import type { Args, Parameters, StoryContext } from '@storybook/types';
import { inferControls } from '@storybook/preview-api';
Expand Down
14 changes: 7 additions & 7 deletions code/stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@
"lib/docs-tools": 14515,
"lib/instrumenter": 12543,
"lib/manager-api-shim": 53,
"lib/manager-api": 50044,
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
"lib/manager-api": 49953,
"lib/node-logger": 1073,
"lib/postinstall": 1488,
"lib/preview-api": 157569,
"lib/preview-api": 157448,
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
"lib/preview-web": 70,
"lib/preview": 345126,
"lib/router": 24415,
"lib/preview": 365317,
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
"lib/router": 20141,
"lib/store": 64,
"lib/theming": 75562,
"lib/types": 318,
"renderers/html": 3583,
"renderers/preact": 1927,
"renderers/react": 28236,
"renderers/react": 28158,
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
"renderers/server": 2482,
"renderers/svelte": 6952,
"renderers/vue": 9649,
"renderers/vue3": 172272,
"renderers/web-components": 7502,
"ui/blocks": 136164,
"ui/blocks": 136059,
"ui/components": 2936826,
"ui/manager": 1971665
"ui/manager": 1983971
ndelangen marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion code/ui/.storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addons } from '@storybook/manager-api';
import startCase from 'lodash/startCase.js';
import { startCase } from 'lodash-es';

addons.setConfig({
sidebar: {
Expand Down
Loading