diff --git a/code/addons/actions/package.json b/code/addons/actions/package.json index 70cce5c7b435..0987bed056ac 100644 --- a/code/addons/actions/package.json +++ b/code/addons/actions/package.json @@ -95,7 +95,7 @@ "uuid-browser": "^3.1.0" }, "devDependencies": { - "@types/lodash": "^4.14.167", + "@types/lodash-es": "^4.17.6", "typescript": "~4.9.3" }, "peerDependencies": { diff --git a/code/frameworks/angular/src/builders/build-storybook/schema.json b/code/frameworks/angular/src/builders/build-storybook/schema.json index 43c55428d1dd..4c3ca7ed4aaf 100644 --- a/code/frameworks/angular/src/builders/build-storybook/schema.json +++ b/code/frameworks/angular/src/builders/build-storybook/schema.json @@ -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 }, @@ -110,9 +104,7 @@ } }, "additionalProperties": false, - "required": [ - "input" - ] + "required": ["input"] }, { "type": "string", @@ -121,4 +113,4 @@ ] } } -} \ No newline at end of file +} diff --git a/code/frameworks/angular/src/builders/start-storybook/schema.json b/code/frameworks/angular/src/builders/start-storybook/schema.json index e81e0579b8dc..334222b26a06 100644 --- a/code/frameworks/angular/src/builders/start-storybook/schema.json +++ b/code/frameworks/angular/src/builders/start-storybook/schema.json @@ -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" } @@ -129,9 +126,7 @@ } }, "additionalProperties": false, - "required": [ - "input" - ] + "required": ["input"] }, { "type": "string", @@ -140,4 +135,4 @@ ] } } -} \ No newline at end of file +} diff --git a/code/jest.config.base.js b/code/jest.config.base.js index f340b21e4994..a0cb59cc5dd2 100644 --- a/code/jest.config.base.js +++ b/code/jest.config.base.js @@ -21,26 +21,27 @@ const skipOnWindows = [ const modulesToTransform = [ '@angular', + '@lit', + '@mdx-js', 'ccount', - 'rxjs', - 'nanoid', - 'uuid', + 'character-entities', + 'decode-named-character-reference', + 'estree', 'lit-html', 'lit', - '@lit', - '@mdx-js', - 'remark', - 'unified', - 'vfile', - 'vfile-message', + 'lodash-es', 'mdast', 'micromark', + 'nanoid', + 'remark', + 'rxjs', + 'stringify-entities', + 'unified', 'unist', - 'estree', - 'decode-named-character-reference', - 'character-entities', + 'uuid', + 'vfile-message', + 'vfile', 'zwitch', - 'stringify-entities', ]; /** @type { import('jest').Config } */ diff --git a/code/lib/builder-vite/src/optimizeDeps.ts b/code/lib/builder-vite/src/optimizeDeps.ts index 10cac8bb55e9..e555c2e8d8fa 100644 --- a/code/lib/builder-vite/src/optimizeDeps.ts +++ b/code/lib/builder-vite/src/optimizeDeps.ts @@ -42,6 +42,7 @@ const INCLUDE_CANDIDATES = [ 'isobject', 'jest-mock', 'loader-utils', + 'lodash-es', 'lodash/cloneDeep', 'lodash/isFunction', 'lodash/isPlainObject', diff --git a/code/lib/codemod/src/lib/utils.ts b/code/lib/codemod/src/lib/utils.ts index 529c87efe731..3ab4b52c74cb 100644 --- a/code/lib/codemod/src/lib/utils.ts +++ b/code/lib/codemod/src/lib/utils.ts @@ -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)); diff --git a/code/lib/core-server/package.json b/code/lib/core-server/package.json index 3007c9c8bdb0..560d2e52c987 100644 --- a/code/lib/core-server/package.json +++ b/code/lib/core-server/package.json @@ -97,6 +97,7 @@ "ws": "^8.2.3" }, "devDependencies": { + "@storybook/preview-api": "7.0.0-beta.48", "@types/compression": "^1.7.0", "@types/ip": "^1.1.0", "@types/serve-favicon": "^2.5.2", diff --git a/code/lib/manager-api/package.json b/code/lib/manager-api/package.json index 011cd3540310..7b6b38a3445f 100644 --- a/code/lib/manager-api/package.json +++ b/code/lib/manager-api/package.json @@ -51,7 +51,7 @@ "@storybook/theming": "7.0.0-beta.55", "@storybook/types": "7.0.0-beta.55", "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", @@ -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", diff --git a/code/lib/manager-api/src/index.tsx b/code/lib/manager-api/src/index.tsx index eebb9d765ff9..8fd3dc71d3c6 100644 --- a/code/lib/manager-api/src/index.tsx +++ b/code/lib/manager-api/src/index.tsx @@ -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, diff --git a/code/lib/manager-api/src/lib/merge.ts b/code/lib/manager-api/src/lib/merge.ts index 8ad0c203d7bb..738beac2fb32 100644 --- a/code/lib/manager-api/src/lib/merge.ts +++ b/code/lib/manager-api/src/lib/merge.ts @@ -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 (a: TObj, b: Partial) => mergeWith({}, a, b, (objValue: TObj, srcValue: Partial) => { 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); } }); diff --git a/code/lib/manager-api/src/lib/stories.ts b/code/lib/manager-api/src/lib/stories.ts index 3db7b6480e07..2a307fc78728 100644 --- a/code/lib/manager-api/src/lib/stories.ts +++ b/code/lib/manager-api/src/lib/stories.ts @@ -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, diff --git a/code/lib/manager-api/src/modules/layout.ts b/code/lib/manager-api/src/modules/layout.ts index e0d19a427800..14513464b71b 100644 --- a/code/lib/manager-api/src/modules/layout.ts +++ b/code/lib/manager-api/src/modules/layout.ts @@ -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'; diff --git a/code/lib/preview-api/package.json b/code/lib/preview-api/package.json index 32be9d49b08e..f6b687fc4ac2 100644 --- a/code/lib/preview-api/package.json +++ b/code/lib/preview-api/package.json @@ -74,9 +74,10 @@ "@storybook/csf": "next", "@storybook/global": "^5.0.0", "@storybook/types": "7.0.0-beta.55", + "@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", diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts index 9d475f356f5c..5224052ca1cb 100644 --- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts +++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts @@ -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, diff --git a/code/lib/preview-api/src/modules/preview-web/parseArgsParam.ts b/code/lib/preview-api/src/modules/preview-web/parseArgsParam.ts index 3212a95b3e96..3728f2548097 100644 --- a/code/lib/preview-api/src/modules/preview-web/parseArgsParam.ts +++ b/code/lib/preview-api/src/modules/preview-web/parseArgsParam.ts @@ -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 _-]*$/; diff --git a/code/lib/preview-api/src/modules/store/StoryStore.ts b/code/lib/preview-api/src/modules/store/StoryStore.ts index 9c036f700e68..e6c69b4b76a2 100644 --- a/code/lib/preview-api/src/modules/store/StoryStore.ts +++ b/code/lib/preview-api/src/modules/store/StoryStore.ts @@ -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'; diff --git a/code/lib/preview-api/src/modules/store/args.ts b/code/lib/preview-api/src/modules/store/args.ts index 4dcccb6261a8..fa3ff7e50e98 100644 --- a/code/lib/preview-api/src/modules/store/args.ts +++ b/code/lib/preview-api/src/modules/store/args.ts @@ -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'); diff --git a/code/lib/preview-api/src/modules/store/csf/normalizeInputTypes.ts b/code/lib/preview-api/src/modules/store/csf/normalizeInputTypes.ts index dbca9af300c2..7b21cbed95eb 100644 --- a/code/lib/preview-api/src/modules/store/csf/normalizeInputTypes.ts +++ b/code/lib/preview-api/src/modules/store/csf/normalizeInputTypes.ts @@ -1,4 +1,4 @@ -import mapValues from 'lodash/mapValues.js'; +import { mapValues } from 'lodash-es'; import type { ArgTypes, GlobalTypes, diff --git a/code/lib/preview-api/src/modules/store/filterArgTypes.ts b/code/lib/preview-api/src/modules/store/filterArgTypes.ts index a9deb2d11e6b..7e0abf11485a 100644 --- a/code/lib/preview-api/src/modules/store/filterArgTypes.ts +++ b/code/lib/preview-api/src/modules/store/filterArgTypes.ts @@ -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; diff --git a/code/lib/preview-api/src/modules/store/inferArgTypes.ts b/code/lib/preview-api/src/modules/store/inferArgTypes.ts index 46cd93dc9024..6af990b95b96 100644 --- a/code/lib/preview-api/src/modules/store/inferArgTypes.ts +++ b/code/lib/preview-api/src/modules/store/inferArgTypes.ts @@ -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'; diff --git a/code/lib/preview-api/src/modules/store/inferControls.ts b/code/lib/preview-api/src/modules/store/inferControls.ts index 6deffa912fd7..5849aa20a053 100644 --- a/code/lib/preview-api/src/modules/store/inferControls.ts +++ b/code/lib/preview-api/src/modules/store/inferControls.ts @@ -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'; diff --git a/code/lib/preview-api/src/modules/store/parameters.ts b/code/lib/preview-api/src/modules/store/parameters.ts index 872a0d2bd38d..5856561f9f57 100644 --- a/code/lib/preview-api/src/modules/store/parameters.ts +++ b/code/lib/preview-api/src/modules/store/parameters.ts @@ -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. diff --git a/code/lib/router/package.json b/code/lib/router/package.json index dbd93febc3fb..9803baec8233 100644 --- a/code/lib/router/package.json +++ b/code/lib/router/package.json @@ -55,7 +55,6 @@ "devDependencies": { "@storybook/global": "^5.0.0", "dequal": "^2.0.2", - "lodash": "^4.17.21", "react-router-dom": "6.0.2", "ts-dedent": "^2.0.0", "typescript": "~4.9.3" diff --git a/code/lib/router/src/utils.ts b/code/lib/router/src/utils.ts index ab5941cab4ca..a3715c4e0ca6 100644 --- a/code/lib/router/src/utils.ts +++ b/code/lib/router/src/utils.ts @@ -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'; @@ -14,6 +13,10 @@ export interface StoryData { const splitPathRegex = /\/([^/]+)\/(?:(.*)_)?([^/]+)?/; +function isPlainObject(value: any): boolean { + return Object.getPrototypeOf(value) === null || Object === value.constructor; +} + export const parsePath: (path: string | undefined) => StoryData = memoize(1000)( (path: string | undefined | null) => { const result: StoryData = { diff --git a/code/lib/store/template/stories/args.stories.ts b/code/lib/store/template/stories/args.stories.ts index e1e6eb7104f4..16f353885a3a 100644 --- a/code/lib/store/template/stories/args.stories.ts +++ b/code/lib/store/template/stories/args.stories.ts @@ -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'; import { STORY_ARGS_UPDATED, UPDATE_STORY_ARGS, RESET_STORY_ARGS } from '@storybook/core-events'; export default { diff --git a/code/lib/types/package.json b/code/lib/types/package.json index b947f1108c75..4b43e5adb37d 100644 --- a/code/lib/types/package.json +++ b/code/lib/types/package.json @@ -49,7 +49,7 @@ "file-system-cache": "^2.0.0" }, "devDependencies": { - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@types/node": "^16.0.0", "typescript": "~4.9.3" }, diff --git a/code/package.json b/code/package.json index 32b1c0af8f98..279e51a785b8 100644 --- a/code/package.json +++ b/code/package.json @@ -141,7 +141,7 @@ "@storybook/core-events": "workspace:*", "@storybook/core-server": "workspace:*", "@storybook/core-webpack": "workspace:*", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/csf-plugin": "workspace:*", "@storybook/csf-tools": "workspace:*", "@storybook/docs-tools": "workspace:*", @@ -204,7 +204,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", @@ -244,7 +244,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.31.1", diff --git a/code/renderers/react/package.json b/code/renderers/react/package.json index 2d73c033d9f0..bc1fc6bf3a8b 100644 --- a/code/renderers/react/package.json +++ b/code/renderers/react/package.json @@ -62,13 +62,14 @@ "@storybook/types": "7.0.0-beta.55", "@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", diff --git a/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts b/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts index 9ccc900a030d..62ef19bba51f 100644 --- a/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts +++ b/code/renderers/react/src/docs/lib/defaultValues/createFromRawDefaultProp.ts @@ -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, diff --git a/code/renderers/react/template/stories/js-argtypes.stories.jsx b/code/renderers/react/template/stories/js-argtypes.stories.jsx index a72d6771dbeb..2674d6f7a6e0 100644 --- a/code/renderers/react/template/stories/js-argtypes.stories.jsx +++ b/code/renderers/react/template/stories/js-argtypes.stories.jsx @@ -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'; diff --git a/code/renderers/react/template/stories/ts-argtypes.stories.tsx b/code/renderers/react/template/stories/ts-argtypes.stories.tsx index 21eb492d30e7..3d09802f2645 100644 --- a/code/renderers/react/template/stories/ts-argtypes.stories.tsx +++ b/code/renderers/react/template/stories/ts-argtypes.stories.tsx @@ -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'; diff --git a/code/stats.json b/code/stats.json index 773bb0eee9b8..1b50dd2893f3 100644 --- a/code/stats.json +++ b/code/stats.json @@ -33,25 +33,25 @@ "lib/docs-tools": 14515, "lib/instrumenter": 12426, "lib/manager-api-shim": 53, - "lib/manager-api": 50044, + "lib/manager-api": 49953, "lib/node-logger": 1073, "lib/postinstall": 1488, - "lib/preview-api": 157624, + "lib/preview-api": 157503, "lib/preview-web": 70, - "lib/preview": 345181, - "lib/router": 24451, + "lib/preview": 316729, + "lib/router": 20177, "lib/store": 64, "lib/theming": 75562, "lib/types": 318, "renderers/html": 3603, "renderers/preact": 1927, - "renderers/react": 28262, + "renderers/react": 28184, "renderers/server": 2482, "renderers/svelte": 6982, "renderers/vue": 9674, "renderers/vue3": 171794, "renderers/web-components": 7522, - "ui/blocks": 137124, + "ui/blocks": 137019, "ui/components": 2941620, - "ui/manager": 1979595 + "ui/manager": 1943637 } diff --git a/code/ui/.storybook/manager.ts b/code/ui/.storybook/manager.ts index 1ac61cf4d375..fe29e76570da 100644 --- a/code/ui/.storybook/manager.ts +++ b/code/ui/.storybook/manager.ts @@ -1,5 +1,5 @@ import { addons } from '@storybook/manager-api'; -import startCase from 'lodash/startCase.js'; +import { startCase } from 'lodash-es'; addons.setConfig({ sidebar: { diff --git a/code/ui/blocks/package.json b/code/ui/blocks/package.json index 4a8166e19695..07f63536ca01 100644 --- a/code/ui/blocks/package.json +++ b/code/ui/blocks/package.json @@ -54,10 +54,10 @@ "@storybook/preview-api": "7.0.0-beta.55", "@storybook/theming": "7.0.0-beta.55", "@storybook/types": "7.0.0-beta.55", - "@types/lodash": "^4.14.167", + "@types/lodash-es": "^4.17.6", "color-convert": "^2.0.1", "dequal": "^2.0.2", - "lodash": "^4.17.21", + "lodash-es": "^4.17.21", "markdown-to-jsx": "^7.1.8", "memoizerific": "^1.11.3", "polished": "^4.2.2", diff --git a/code/ui/blocks/src/blocks/ArgsTable.tsx b/code/ui/blocks/src/blocks/ArgsTable.tsx index acfcf0414d4d..c29cd8f75c3d 100644 --- a/code/ui/blocks/src/blocks/ArgsTable.tsx +++ b/code/ui/blocks/src/blocks/ArgsTable.tsx @@ -1,6 +1,6 @@ import type { FC } from 'react'; import React, { useContext, useEffect, useState, useCallback } from 'react'; -import mapValues from 'lodash/mapValues.js'; +import { mapValues } from 'lodash-es'; import type { ArgTypesExtractor } from '@storybook/docs-tools'; import type { PropDescriptor } from '@storybook/preview-api'; import { filterArgTypes } from '@storybook/preview-api'; diff --git a/code/ui/blocks/src/components/ArgsTable/ArgValue.tsx b/code/ui/blocks/src/components/ArgsTable/ArgValue.tsx index 131aab285a1b..0c2a6820b873 100644 --- a/code/ui/blocks/src/components/ArgsTable/ArgValue.tsx +++ b/code/ui/blocks/src/components/ArgsTable/ArgValue.tsx @@ -1,7 +1,7 @@ import type { FC } from 'react'; import React, { useState } from 'react'; import memoize from 'memoizerific'; -import uniq from 'lodash/uniq.js'; +import { uniq } from 'lodash-es'; import { styled } from '@storybook/theming'; import { WithTooltipPure, Icons, SyntaxHighlighter, codeCommon } from '@storybook/components'; import type { PropSummaryValue } from './types'; diff --git a/code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx b/code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx index c4ffeb0d8c2b..3e4e219ef8b3 100644 --- a/code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx +++ b/code/ui/blocks/src/components/ArgsTable/ArgsTable.tsx @@ -1,6 +1,6 @@ import type { FC } from 'react'; import React from 'react'; -import pickBy from 'lodash/pickBy.js'; +import { pickBy } from 'lodash-es'; import { styled } from '@storybook/theming'; import { opacify, transparentize, darken, lighten } from 'polished'; import { includeConditionalArg } from '@storybook/csf'; diff --git a/code/ui/blocks/src/controls/Color.tsx b/code/ui/blocks/src/controls/Color.tsx index b126c80e3b2d..9cc6e9644c94 100644 --- a/code/ui/blocks/src/controls/Color.tsx +++ b/code/ui/blocks/src/controls/Color.tsx @@ -2,7 +2,7 @@ import type { FC, ChangeEvent, FocusEvent } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { HexColorPicker, HslaStringColorPicker, RgbaStringColorPicker } from 'react-colorful'; import convert from 'color-convert'; -import throttle from 'lodash/throttle.js'; +import { throttle } from 'lodash-es'; import { styled } from '@storybook/theming'; import { TooltipNote, WithTooltip, Form, Icons } from '@storybook/components'; diff --git a/code/ui/blocks/src/controls/Object.tsx b/code/ui/blocks/src/controls/Object.tsx index d1dbd5525299..7f3c1ea4cc4b 100644 --- a/code/ui/blocks/src/controls/Object.tsx +++ b/code/ui/blocks/src/controls/Object.tsx @@ -1,5 +1,5 @@ import { global } from '@storybook/global'; -import cloneDeep from 'lodash/cloneDeep.js'; +import { cloneDeep } from 'lodash-es'; import type { ComponentProps, SyntheticEvent, FC, FocusEvent } from 'react'; import React, { useCallback, useMemo, useState, useEffect, useRef } from 'react'; import { styled, useTheme, type Theme } from '@storybook/theming'; diff --git a/code/ui/manager/package.json b/code/ui/manager/package.json index 688750ff6a9a..002e72347f14 100644 --- a/code/ui/manager/package.json +++ b/code/ui/manager/package.json @@ -69,12 +69,13 @@ "@storybook/theming": "7.0.0-beta.55", "@storybook/types": "7.0.0-beta.55", "@testing-library/react": "^11.2.2", + "@types/lodash-es": "^4.17.6", "@types/semver": "^7.3.4", "copy-to-clipboard": "^3.3.1", "downshift": "^6.0.15", "fs-extra": "^11.1.0", "fuse.js": "^3.6.1", - "lodash": "^4.17.21", + "lodash-es": "^4.17.21", "markdown-to-jsx": "^7.1.8", "memoizerific": "^1.11.3", "polished": "^4.2.2", diff --git a/code/ui/manager/src/components/layout/persist.ts b/code/ui/manager/src/components/layout/persist.ts index 0f5b998cc568..bec65c3d2e52 100644 --- a/code/ui/manager/src/components/layout/persist.ts +++ b/code/ui/manager/src/components/layout/persist.ts @@ -1,5 +1,5 @@ import store from 'store2'; -import debounce from 'lodash/debounce.js'; +import { debounce } from 'lodash-es'; import memoize from 'memoizerific'; export { store }; diff --git a/code/ui/manager/src/components/sidebar/useExpanded.ts b/code/ui/manager/src/components/sidebar/useExpanded.ts index 854796c317f0..c32855065b3d 100644 --- a/code/ui/manager/src/components/sidebar/useExpanded.ts +++ b/code/ui/manager/src/components/sidebar/useExpanded.ts @@ -2,7 +2,7 @@ import type { StoriesHash } from '@storybook/manager-api'; import { useStorybookApi } from '@storybook/manager-api'; import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core-events'; import { global } from '@storybook/global'; -import throttle from 'lodash/throttle.js'; +import { throttle } from 'lodash-es'; import type { Dispatch, MutableRefObject } from 'react'; import type React from 'react'; import { useCallback, useEffect, useReducer } from 'react'; diff --git a/code/ui/manager/src/components/sidebar/useLastViewed.ts b/code/ui/manager/src/components/sidebar/useLastViewed.ts index 1bc8d679883a..67aa215d9e57 100644 --- a/code/ui/manager/src/components/sidebar/useLastViewed.ts +++ b/code/ui/manager/src/components/sidebar/useLastViewed.ts @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce.js'; +import { debounce } from 'lodash-es'; import { useCallback, useEffect, useMemo, useRef } from 'react'; import store from 'store2'; diff --git a/code/yarn.lock b/code/yarn.lock index 6148cff8660e..e1f905f8f42d 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -4963,7 +4963,7 @@ __metadata: "@storybook/preview-api": 7.0.0-beta.55 "@storybook/theming": 7.0.0-beta.55 "@storybook/types": 7.0.0-beta.55 - "@types/lodash": ^4.14.167 + "@types/lodash-es": ^4.17.6 dequal: ^2.0.2 lodash: ^4.17.21 polished: ^4.2.2 @@ -5599,10 +5599,10 @@ __metadata: "@storybook/theming": 7.0.0-beta.55 "@storybook/types": 7.0.0-beta.55 "@types/color-convert": ^2.0.0 - "@types/lodash": ^4.14.167 + "@types/lodash-es": ^4.17.6 color-convert: ^2.0.1 dequal: ^2.0.2 - lodash: ^4.17.21 + lodash-es: ^4.17.21 markdown-to-jsx: ^7.1.8 memoizerific: ^1.11.3 polished: ^4.2.2 @@ -5765,6 +5765,20 @@ __metadata: languageName: unknown linkType: soft +"@storybook/channel-postmessage@npm:7.0.0-beta.48": + version: 7.0.0-beta.48 + resolution: "@storybook/channel-postmessage@npm:7.0.0-beta.48" + dependencies: + "@storybook/channels": 7.0.0-beta.48 + "@storybook/client-logger": 7.0.0-beta.48 + "@storybook/core-events": 7.0.0-beta.48 + "@storybook/global": ^5.0.0 + qs: ^6.10.0 + telejson: ^7.0.3 + checksum: a8957a3854eb522f70769980ffb08c1e2947f9191b10afc82275db459647fa9d2fd2afa831cf4acd45dca445778b8ab566a4039251a0a67bd7a4f743d0b384fd + languageName: node + linkType: hard + "@storybook/channel-websocket@7.0.0-beta.55, @storybook/channel-websocket@workspace:*, @storybook/channel-websocket@workspace:lib/channel-websocket": version: 0.0.0-use.local resolution: "@storybook/channel-websocket@workspace:lib/channel-websocket" @@ -5785,6 +5799,13 @@ __metadata: languageName: unknown linkType: soft +"@storybook/channels@npm:7.0.0-beta.48": + version: 7.0.0-beta.48 + resolution: "@storybook/channels@npm:7.0.0-beta.48" + checksum: 5c90ade9a578f6644e06c53758720e775f053bf311c78f048ec9a99cc20c00c53475a1dff8f9fba14656e656fe9d489f7d023142ef34f5328506a51fff31bd2c + languageName: node + linkType: hard + "@storybook/cli@7.0.0-beta.55, @storybook/cli@workspace:*, @storybook/cli@workspace:lib/cli": version: 0.0.0-use.local resolution: "@storybook/cli@workspace:lib/cli" @@ -5858,6 +5879,15 @@ __metadata: languageName: unknown linkType: soft +"@storybook/client-logger@npm:7.0.0-beta.48": + version: 7.0.0-beta.48 + resolution: "@storybook/client-logger@npm:7.0.0-beta.48" + dependencies: + "@storybook/global": ^5.0.0 + checksum: 6f3dbe4873e8b1801af8edd0506c61517b0f935a543ec168c2c44e59ea1f1967c6173b45276c75b6b92d3f14c650478081bba9747351aedd497f94cbd823da86 + languageName: node + linkType: hard + "@storybook/client-logger@npm:next": version: 7.0.0-beta.55 resolution: "@storybook/client-logger@npm:7.0.0-beta.55" @@ -5982,6 +6012,13 @@ __metadata: languageName: unknown linkType: soft +"@storybook/core-events@npm:7.0.0-beta.48": + version: 7.0.0-beta.48 + resolution: "@storybook/core-events@npm:7.0.0-beta.48" + checksum: e86f9ed3d536c6015caea86282955b2c0e224691c448028fc8ba8e432293cd454030298cf0beddb8b03ef9208233bcc088b099f6b7bb2fef5bd150eba31f51c2 + languageName: node + linkType: hard + "@storybook/core-server@7.0.0-beta.55, @storybook/core-server@workspace:*, @storybook/core-server@workspace:lib/core-server": version: 0.0.0-use.local resolution: "@storybook/core-server@workspace:lib/core-server" @@ -5997,7 +6034,7 @@ __metadata: "@storybook/global": ^5.0.0 "@storybook/manager": 7.0.0-beta.55 "@storybook/node-logger": 7.0.0-beta.55 - "@storybook/preview-api": 7.0.0-beta.55 + "@storybook/preview-api": 7.0.0-beta.48 "@storybook/telemetry": 7.0.0-beta.55 "@storybook/types": 7.0.0-beta.55 "@types/compression": ^1.7.0 @@ -6083,6 +6120,15 @@ __metadata: languageName: unknown linkType: soft +"@storybook/csf@npm:0.0.2--canary.62.5777911.0": + version: 0.0.2--canary.62.5777911.0 + resolution: "@storybook/csf@npm:0.0.2--canary.62.5777911.0" + dependencies: + type-fest: ^2.19.0 + checksum: 80c4ea3e09d9e93fd8cd438b3a894705bb84ffe90c7a71a01915e45c0f5ebf67a941e716a128cd95ed017181150484942ade24af84316e39d907bbc514b6d4b4 + languageName: node + linkType: hard + "@storybook/csf@npm:^0.0.1": version: 0.0.1 resolution: "@storybook/csf@npm:0.0.1" @@ -6305,11 +6351,11 @@ __metadata: "@storybook/router": 7.0.0-beta.55 "@storybook/theming": 7.0.0-beta.55 "@storybook/types": 7.0.0-beta.55 - "@types/lodash": ^4.14.167 + "@types/lodash-es": ^4.17.6 "@types/qs": ^6 dequal: ^2.0.2 flush-promises: ^1.0.2 - lodash: ^4.17.21 + lodash-es: ^4.17.21 memoizerific: ^1.11.3 qs: ^6.10.0 semver: ^7.3.7 @@ -6342,12 +6388,13 @@ __metadata: "@storybook/theming": 7.0.0-beta.55 "@storybook/types": 7.0.0-beta.55 "@testing-library/react": ^11.2.2 + "@types/lodash-es": ^4.17.6 "@types/semver": ^7.3.4 copy-to-clipboard: ^3.3.1 downshift: ^6.0.15 fs-extra: ^11.1.0 fuse.js: ^3.6.1 - lodash: ^4.17.21 + lodash-es: ^4.17.21 markdown-to-jsx: ^7.1.8 memoizerific: ^1.11.3 polished: ^4.2.2 @@ -6736,10 +6783,11 @@ __metadata: "@storybook/csf": next "@storybook/global": ^5.0.0 "@storybook/types": 7.0.0-beta.55 + "@types/lodash-es": ^4.17.6 "@types/qs": ^6.9.5 ansi-to-html: ^0.6.11 dequal: ^2.0.2 - lodash: ^4.17.21 + lodash-es: ^4.17.21 memoizerific: ^1.11.3 qs: ^6.10.0 react: ^16.14.0 @@ -6750,6 +6798,30 @@ __metadata: languageName: unknown linkType: soft +"@storybook/preview-api@npm:7.0.0-beta.48": + version: 7.0.0-beta.48 + resolution: "@storybook/preview-api@npm:7.0.0-beta.48" + dependencies: + "@storybook/channel-postmessage": 7.0.0-beta.48 + "@storybook/channels": 7.0.0-beta.48 + "@storybook/client-logger": 7.0.0-beta.48 + "@storybook/core-events": 7.0.0-beta.48 + "@storybook/csf": next + "@storybook/global": ^5.0.0 + "@storybook/types": 7.0.0-beta.48 + "@types/qs": ^6.9.5 + dequal: ^2.0.2 + lodash: ^4.17.21 + memoizerific: ^1.11.3 + qs: ^6.10.0 + slash: ^3.0.0 + synchronous-promise: ^2.0.15 + ts-dedent: ^2.0.0 + util-deprecate: ^1.0.2 + checksum: 6e72bb901d3d68ab0107f1a778eead52d740064b088527af8b0a70ae8f47ec1b9fff3cf0516391aded860e90253b8991ec461384bf2f39699a71349da344d1c9 + languageName: node + linkType: hard + "@storybook/preview-web@7.0.0-beta.55, @storybook/preview-web@workspace:*, @storybook/preview-web@workspace:lib/preview-web": version: 0.0.0-use.local resolution: "@storybook/preview-web@workspace:lib/preview-web" @@ -6879,6 +6951,7 @@ __metadata: "@storybook/types": 7.0.0-beta.55 "@types/escodegen": ^0.0.6 "@types/estree": ^0.0.51 + "@types/lodash-es": ^4.17.6 "@types/node": ^16.0.0 "@types/util-deprecate": ^1.0.0 acorn: ^7.4.1 @@ -6888,7 +6961,7 @@ __metadata: expect-type: ^0.14.2 html-tags: ^3.1.0 jest-specific-snapshot: ^7.0.0 - lodash: ^4.17.21 + lodash-es: ^4.17.21 prop-types: ^15.7.2 react-element-to-jsx-string: ^15.0.0 require-from-string: ^2.0.2 @@ -6961,7 +7034,7 @@ __metadata: "@storybook/core-events": "workspace:*" "@storybook/core-server": "workspace:*" "@storybook/core-webpack": "workspace:*" - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/csf-plugin": "workspace:*" "@storybook/csf-tools": "workspace:*" "@storybook/docs-tools": "workspace:*" @@ -7024,7 +7097,7 @@ __metadata: "@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 @@ -7064,7 +7137,7 @@ __metadata: 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.31.1 @@ -7108,7 +7181,6 @@ __metadata: "@storybook/client-logger": 7.0.0-beta.55 "@storybook/global": ^5.0.0 dequal: ^2.0.2 - lodash: ^4.17.21 memoizerific: ^1.11.3 qs: ^6.10.0 react-router-dom: 6.0.2 @@ -7313,7 +7385,7 @@ __metadata: resolution: "@storybook/types@workspace:lib/types" dependencies: "@storybook/channels": 7.0.0-beta.55 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@types/babel__core": ^7.0.0 "@types/express": ^4.7.0 "@types/node": ^16.0.0 @@ -7322,6 +7394,20 @@ __metadata: languageName: unknown linkType: soft +"@storybook/types@npm:7.0.0-beta.48": + version: 7.0.0-beta.48 + resolution: "@storybook/types@npm:7.0.0-beta.48" + dependencies: + "@babel/core": ^7.12.10 + "@storybook/channels": 7.0.0-beta.48 + "@types/babel__core": ^7.0.0 + "@types/express": ^4.7.0 + express: ^4.17.3 + file-system-cache: ^2.0.0 + checksum: eff54e2dba4b67cc53d3e7b4d04b23b5998df2f1b9c19c85234672cef30c324e469b42beed4519ae56db16bd72af94a641541cead2dca6887953987b955fcd89 + languageName: node + linkType: hard + "@storybook/vue-vite@workspace:frameworks/vue-vite": version: 0.0.0-use.local resolution: "@storybook/vue-vite@workspace:frameworks/vue-vite" @@ -8273,7 +8359,16 @@ __metadata: languageName: node linkType: hard -"@types/lodash@npm:^4.14.167": +"@types/lodash-es@npm:^4.17.6": + version: 4.17.6 + resolution: "@types/lodash-es@npm:4.17.6" + dependencies: + "@types/lodash": "*" + checksum: bf7a8b0d16e05c60aad117717771cc2a9fa2d6205f2e138c52656e889dbfb2c76d469991a990fa46989804daf2f06e075d2d8e62c7199b0d2f574a290c8c39d6 + languageName: node + linkType: hard + +"@types/lodash@npm:*": version: 4.14.191 resolution: "@types/lodash@npm:4.14.191" checksum: cca0bc3b5f1193a50a39a9c6e14892e7cf57ab81ca05985e1ccee0d732dd3b22a8d669fa87560757051c6d73f4f63a2e2248ce9a7d9c159d0d5e3f331baf6a62 diff --git a/docs/snippets/common/storybook-manager-render-label-stories.js.mdx b/docs/snippets/common/storybook-manager-render-label-stories.js.mdx index b5ea56ba10af..0fc1acc52a23 100644 --- a/docs/snippets/common/storybook-manager-render-label-stories.js.mdx +++ b/docs/snippets/common/storybook-manager-render-label-stories.js.mdx @@ -3,7 +3,7 @@ import { addons } from '@storybook/manager-api'; -import startCase from 'lodash/startCase.js'; +import { startCase } from 'lodash-es'; addons.setConfig({ sidebar: { diff --git a/scripts/package.json b/scripts/package.json index 7bae68386e92..5666b8bb2e02 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -95,6 +95,7 @@ "ejs-lint": "^2.0.0", "esbuild": "^0.16.4", "esbuild-plugin-alias": "^0.2.1", + "esbuild-plugin-lodash": "^1.2.0", "esbuild-register": "^3.4.1", "eslint": "^8.28.0", "eslint-plugin-import": "^2.26.0", diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index cc5cbdcb7207..b9bce758c8d5 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -7,6 +7,9 @@ import type { PackageJson } from 'type-fest'; import { build } from 'tsup'; import dedent from 'ts-dedent'; import slash from 'slash'; +/* @ts-expect-error (has no typings) */ +import lodashTransformer from 'esbuild-plugin-lodash'; +import esbuildAliasPlugin from 'esbuild-plugin-alias'; import { exec } from '../utils/exec'; /* TYPES */ @@ -117,11 +120,24 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { platform: platform || 'browser', external: externals, + esbuildPlugins: [ + esbuildAliasPlugin({ + lodash: 'lodash-es', + }), + lodashTransformer({ + outLodashPackage: 'lodash-es', + filter: /node_modules\/(react-resize-detector)\/.*/, + }), + ], + esbuildOptions: (c) => { /* eslint-disable no-param-reassign */ c.absWorkingDir = cwd; - c.conditions = [platform || 'browser', 'import', 'module']; + c.alias = { + lodash: 'lodash-es', + }; c.platform = platform || 'browser'; + c.conditions = [platform || 'browser', 'import', 'module']; Object.assign(c, getESBuildOptions(optimized)); /* eslint-enable no-param-reassign */ }, @@ -142,10 +158,26 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { platform: 'node', clean: !watch, external: externals, + plugins: [ + { + name: 'lodash', + async renderChunk(code) { + return { code: code.replaceAll('lodash-es', 'lodash') }; + }, + }, + ], + esbuildPlugins: [ + esbuildAliasPlugin({ + 'lodash-es': require.resolve('lodash'), + }), + ], esbuildOptions: (c) => { /* eslint-disable no-param-reassign */ c.absWorkingDir = cwd; + c.alias = { + 'lodash-es': 'lodash', + }; c.platform = 'node'; c.conditions = ['node', 'require']; Object.assign(c, getESBuildOptions(optimized)); diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 3a01b5a2c1b1..af88da18a705 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -2877,6 +2877,7 @@ __metadata: ejs-lint: ^2.0.0 esbuild: ^0.16.4 esbuild-plugin-alias: ^0.2.1 + esbuild-plugin-lodash: ^1.2.0 esbuild-register: ^3.4.1 eslint: ^8.28.0 eslint-plugin-import: ^2.26.0 @@ -6569,6 +6570,13 @@ __metadata: languageName: node linkType: hard +"esbuild-plugin-lodash@npm:^1.2.0": + version: 1.2.0 + resolution: "esbuild-plugin-lodash@npm:1.2.0" + checksum: a8ef389dd9ae98b7ecaa36cff98ea9c532614436aed011ef0f86d23bc626ac32e8c1926287c2d954c0b2164c534691397743b3f0cd9864403daa57f07240a2fe + languageName: node + linkType: hard + "esbuild-register@npm:^3.4.1": version: 3.4.2 resolution: "esbuild-register@npm:3.4.2"