From 7ebf449d3e4cfc3a02fe28e682f8d5f195411f5e Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 15:21:11 +0100 Subject: [PATCH 01/26] migrate to es version of lodash --- code/lib/manager-api/package.json | 4 ++-- code/lib/manager-api/src/index.tsx | 2 +- code/lib/manager-api/src/lib/merge.ts | 11 ++++++----- code/lib/manager-api/src/lib/stories.ts | 3 +-- code/lib/manager-api/src/modules/layout.ts | 2 +- code/lib/router/src/utils.ts | 5 ++++- code/ui/blocks/package.json | 4 ++-- code/ui/blocks/src/blocks/ArgsTable.tsx | 2 +- .../src/components/ArgsTable/ArgValue.tsx | 2 +- .../src/components/ArgsTable/ArgsTable.tsx | 2 +- code/ui/blocks/src/controls/Color.tsx | 2 +- code/ui/blocks/src/controls/Object.tsx | 2 +- code/ui/manager/package.json | 3 ++- .../manager/src/components/layout/persist.ts | 2 +- .../src/components/sidebar/useExpanded.ts | 2 +- .../src/components/sidebar/useLastViewed.ts | 2 +- code/yarn.lock | 19 ++++++++++++++----- 17 files changed, 41 insertions(+), 28 deletions(-) diff --git a/code/lib/manager-api/package.json b/code/lib/manager-api/package.json index b00a58096128..20fd21b433e4 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.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", @@ -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/router/src/utils.ts b/code/lib/router/src/utils.ts index dc447668de39..d66415a1f2c7 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/ui/blocks/package.json b/code/ui/blocks/package.json index c94f239d8883..6e2f59eb193d 100644 --- a/code/ui/blocks/package.json +++ b/code/ui/blocks/package.json @@ -54,10 +54,10 @@ "@storybook/preview-api": "7.0.0-beta.40", "@storybook/theming": "7.0.0-beta.40", "@storybook/types": "7.0.0-beta.40", - "@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 c4f3e3cd4343..2b28c7c2a8df 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 b0147faff0c4..3667b5d90462 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 179b8c09e3f7..c1a383e5dda2 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 c21ca68d027f..74ef2a36aada 100644 --- a/code/ui/manager/package.json +++ b/code/ui/manager/package.json @@ -68,12 +68,13 @@ "@storybook/theming": "7.0.0-beta.40", "@storybook/types": "7.0.0-beta.40", "@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 af482d8258f9..6ec8d0309624 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5709,10 +5709,10 @@ __metadata: "@storybook/theming": 7.0.0-beta.40 "@storybook/types": 7.0.0-beta.40 "@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 @@ -6430,11 +6430,11 @@ __metadata: "@storybook/router": 7.0.0-beta.40 "@storybook/theming": 7.0.0-beta.40 "@storybook/types": 7.0.0-beta.40 - "@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 @@ -8280,7 +8280,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:*, @types/lodash@npm:^4.14.167": version: 4.14.191 resolution: "@types/lodash@npm:4.14.191" checksum: cca0bc3b5f1193a50a39a9c6e14892e7cf57ab81ca05985e1ccee0d732dd3b22a8d669fa87560757051c6d73f4f63a2e2248ce9a7d9c159d0d5e3f331baf6a62 From 85a1be441fd865c4f79626d1a2387b95517c6cdb Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 15:24:39 +0100 Subject: [PATCH 02/26] fix lockfile --- code/yarn.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/yarn.lock b/code/yarn.lock index 6ec8d0309624..688214a3bea6 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6467,12 +6467,13 @@ __metadata: "@storybook/theming": 7.0.0-beta.40 "@storybook/types": 7.0.0-beta.40 "@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 From ecc39661cd0c28d3a118870bd8c09173849f81d3 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 15:42:54 +0100 Subject: [PATCH 03/26] add lodash-es to jest transform config --- code/jest.config.base.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/jest.config.base.js b/code/jest.config.base.js index c4eca2a3330b..af8c76de13b4 100644 --- a/code/jest.config.base.js +++ b/code/jest.config.base.js @@ -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/', From 52e64445008a1f3d9c96b6d7d6ac0f582cae2ce2 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 16:20:55 +0100 Subject: [PATCH 04/26] more lodash to es version conversion --- code/lib/builder-vite/src/optimizeDeps.ts | 1 + code/lib/cli/test/default/cli.test.js | 6 ++++++ code/lib/codemod/src/lib/utils.ts | 3 +-- code/lib/core-server/package.json | 7 +++++-- code/lib/preview-api/package.json | 3 ++- .../preview-api/src/modules/preview-web/PreviewWeb.test.ts | 2 +- .../preview-api/src/modules/preview-web/parseArgsParam.ts | 2 +- code/lib/preview-api/src/modules/store/StoryStore.ts | 3 +-- code/lib/preview-api/src/modules/store/args.ts | 2 +- .../src/modules/store/csf/normalizeInputTypes.ts | 2 +- code/lib/preview-api/src/modules/store/filterArgTypes.ts | 2 +- code/lib/preview-api/src/modules/store/inferArgTypes.ts | 2 +- code/lib/preview-api/src/modules/store/inferControls.ts | 2 +- code/lib/preview-api/src/modules/store/parameters.ts | 2 +- code/lib/store/template/stories/args.stories.ts | 2 +- code/yarn.lock | 3 ++- 16 files changed, 27 insertions(+), 17 deletions(-) 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/cli/test/default/cli.test.js b/code/lib/cli/test/default/cli.test.js index b7ead3851c9e..f5a85ccaa4cf 100755 --- a/code/lib/cli/test/default/cli.test.js +++ b/code/lib/cli/test/default/cli.test.js @@ -1,3 +1,9 @@ +jest.mock('lodash-es', () => { + const x = jest.requireActual('lodash'); + + console.log({ x }); +}); + const run = require('../helpers'); describe('Default behavior', () => { 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 f88ae1b46589..dfb7ab5723c7 100644 --- a/code/lib/core-server/package.json +++ b/code/lib/core-server/package.json @@ -66,7 +66,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", @@ -100,6 +99,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", @@ -117,7 +117,10 @@ "./src/presets/babel-cache-preset.ts", "./src/presets/common-preset.ts" ], - "platform": "node" + "platform": "node", + "externals": [ + "util" + ] }, "gitHead": "9c68cc3a66e996e91ccd520d9d0adf0fa7094ad4" } diff --git a/code/lib/preview-api/package.json b/code/lib/preview-api/package.json index 07903abc14e0..4b98b0464480 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.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", 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 9f6ef15f3666..e77c43109f0a 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 7f16d6c14aed..86221b7e0009 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/store/template/stories/args.stories.ts b/code/lib/store/template/stories/args.stories.ts index 16b4e7bc0d03..f919f460e909 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'; export default { component: globalThis.Components.Pre, diff --git a/code/yarn.lock b/code/yarn.lock index 688214a3bea6..ffb5d504ec73 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6798,10 +6798,11 @@ __metadata: "@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 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 From 78e7c899c3ea718efb8261b4d614a572f07fd2cc Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 16:45:47 +0100 Subject: [PATCH 05/26] more lodash to lodash-es conversion --- code/package.json | 4 ++-- code/renderers/react/package.json | 3 ++- .../src/docs/lib/defaultValues/createFromRawDefaultProp.ts | 4 +--- .../react/template/stories/js-argtypes.stories.jsx | 2 +- .../react/template/stories/ts-argtypes.stories.tsx | 2 +- code/ui/.storybook/manager.ts | 2 +- code/yarn.lock | 7 ++++--- .../common/storybook-manager-render-label-stories.js.mdx | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/code/package.json b/code/package.json index 4460d3c45071..fe42bf31dc1d 100644 --- a/code/package.json +++ b/code/package.json @@ -198,7 +198,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", @@ -238,7 +238,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", diff --git a/code/renderers/react/package.json b/code/renderers/react/package.json index 32ee54c4728a..0abba97b0246 100644 --- a/code/renderers/react/package.json +++ b/code/renderers/react/package.json @@ -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", 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/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/yarn.lock b/code/yarn.lock index ffb5d504ec73..3c17d20d4a71 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6935,6 +6935,7 @@ __metadata: "@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 "@types/util-deprecate": ^1.0.0 acorn: ^7.4.1 @@ -6944,7 +6945,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 @@ -7077,7 +7078,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 @@ -7117,7 +7118,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.30.0 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..79b8a586d89a 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: { From 8b1a543dc7ccae96ceb8d3b5550a5e82e7413556 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 16:54:55 +0100 Subject: [PATCH 06/26] fix linting --- code/lib/core-server/src/utils/StoryIndexGenerator.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/lib/core-server/src/utils/StoryIndexGenerator.ts b/code/lib/core-server/src/utils/StoryIndexGenerator.ts index 67aedf38ec06..8846f4d3d2cd 100644 --- a/code/lib/core-server/src/utils/StoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/StoryIndexGenerator.ts @@ -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 import { normalizeStoryPath } from '@storybook/core-common'; import { logger } from '@storybook/node-logger'; import { getStorySortParameter, NoMetaError } from '@storybook/csf-tools'; From 82f4abf57a6ef059d9a96a771437411e4e96ab90 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 16:55:53 +0100 Subject: [PATCH 07/26] fix linting --- .../src/builders/build-storybook/schema.json | 16 ++++------------ .../src/builders/start-storybook/schema.json | 11 +++-------- 2 files changed, 7 insertions(+), 20 deletions(-) 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 +} From 41f3401ea8008ae0dedb7fdd25732e43b086733a Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 16:58:33 +0100 Subject: [PATCH 08/26] fix linting --- .../common/storybook-manager-render-label-stories.js.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 79b8a586d89a..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-es'; +import { startCase } from 'lodash-es'; addons.setConfig({ sidebar: { From 9633b0126c8f8ff35196fd5db41b86c96d0ec385 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 18:14:23 +0100 Subject: [PATCH 09/26] add stats generation script --- code/package.json | 1 + scripts/bench/packages-dist-sizes.ts | 32 ++++++++++++++++++++++++++++ scripts/package.json | 1 + scripts/yarn.lock | 14 +++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 scripts/bench/packages-dist-sizes.ts diff --git a/code/package.json b/code/package.json index fe42bf31dc1d..ff9ded91a2df 100644 --- a/code/package.json +++ b/code/package.json @@ -23,6 +23,7 @@ }, "scripts": { "await-serve-storybooks": "wait-on http://localhost:8001", + "bench:packages-dist-sizes": "ts-node --swc --project=../scripts/tsconfig.json ../scripts/bench/packages-dist-sizes.ts", "build": "NODE_ENV=production node ../scripts/build-package.js", "changelog": "pr-log --sloppy --cherry-pick", "changelog:next": "pr-log --sloppy --since-prerelease", diff --git a/scripts/bench/packages-dist-sizes.ts b/scripts/bench/packages-dist-sizes.ts new file mode 100644 index 000000000000..6dd6dfc60396 --- /dev/null +++ b/scripts/bench/packages-dist-sizes.ts @@ -0,0 +1,32 @@ +import glob from 'glob-promise'; +import { join, parse } from 'path'; +import { stat, writeFile } from 'fs/promises'; + +const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { + const files = await glob( + join(cwd, '@(lib|addons|frameworks|renderers|presets|ui)', '*', 'dist', '*.mjs') + ); + + const sizes = await Promise.all( + files.map(async (file) => { + const { dir } = parse(file); + const { size } = await stat(file); + return [dir.replace(`${cwd}/`, '').replace('/dist', ''), size]; + }) + ); + + const totals = sizes.reduce( + (acc, [dir, size]) => Object.assign(acc, { [dir]: size + (acc[dir] || 0) }), + {} + ); + + await writeFile(join(cwd, 'stats.json'), JSON.stringify(totals, null, 2)); +}; + +const cwd = process.cwd(); +const flags = process.argv.slice(2); + +run({ cwd, flags }).catch((e) => { + console.error(e); + process.exit(1); +}); diff --git a/scripts/package.json b/scripts/package.json index fbbb66dbbcf2..11ae743d05e6 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -107,6 +107,7 @@ "fs-extra": "^10.1.0", "github-release-from-changelog": "^2.1.1", "glob": "^7.1.6", + "glob-promise": "^4.2.0", "http-server": "^0.12.3", "husky": "^4.3.7", "jest": "^29.3.1", diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 29c32941b5ad..6af77e721a76 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -2823,6 +2823,7 @@ __metadata: fs-extra: ^10.1.0 github-release-from-changelog: ^2.1.1 glob: ^7.1.6 + glob-promise: ^4.2.0 http-server: ^0.12.3 husky: ^4.3.7 jest: ^29.3.1 @@ -3269,7 +3270,7 @@ __metadata: languageName: node linkType: hard -"@types/glob@npm:*, @types/glob@npm:^7.1.1": +"@types/glob@npm:*, @types/glob@npm:^7.1.1, @types/glob@npm:^7.1.3": version: 7.2.0 resolution: "@types/glob@npm:7.2.0" dependencies: @@ -7817,6 +7818,17 @@ __metadata: languageName: node linkType: hard +"glob-promise@npm:^4.2.0": + version: 4.2.2 + resolution: "glob-promise@npm:4.2.2" + dependencies: + "@types/glob": ^7.1.3 + peerDependencies: + glob: ^7.1.6 + checksum: 3eb01bed2901539365df6a4d27800afb8788840647d01f9bf3500b3de756597f2ff4b8c823971ace34db228c83159beca459dc42a70968d4e9c8200ed2cc96bd + languageName: node + linkType: hard + "glob@npm:7.1.4": version: 7.1.4 resolution: "glob@npm:7.1.4" From 88934800d2c066aa6d210fcd1c5ee2b8659a1763 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 18:14:39 +0100 Subject: [PATCH 10/26] adds stats --- code/stats.json | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 code/stats.json diff --git a/code/stats.json b/code/stats.json new file mode 100644 index 000000000000..f09fa33708e2 --- /dev/null +++ b/code/stats.json @@ -0,0 +1,90 @@ +{ + "addons/a11y": 22289, + "addons/actions": 8636, + "addons/backgrounds": 9370, + "addons/controls": 1821, + "addons/docs": 5276, + "addons/essentials": 927, + "addons/highlight": 1648, + "addons/interactions": 60909, + "addons/jest": 12777, + "addons/links": 3050, + "addons/measure": 14450, + "addons/outline": 10185, + "addons/storyshots-core": 6573, + "addons/storyshots-puppeteer": 6702, + "addons/storysource": 4445, + "addons/toolbars": 6214, + "addons/viewport": 8518, + "frameworks/angular": 1632, + "frameworks/ember": 757, + "frameworks/html-vite": 86, + "frameworks/html-webpack5": 771, + "frameworks/nextjs": 32891, + "frameworks/preact-vite": 327, + "frameworks/preact-webpack5": 775, + "frameworks/react-vite": 3390, + "frameworks/react-webpack5": 1395, + "frameworks/server-webpack5": 775, + "frameworks/svelte-vite": 3244, + "frameworks/svelte-webpack5": 775, + "frameworks/sveltekit": 632, + "frameworks/vue-vite": 1343, + "frameworks/vue-webpack5": 832, + "frameworks/vue3-vite": 933, + "frameworks/vue3-webpack5": 834, + "frameworks/web-components-vite": 96, + "frameworks/web-components-webpack5": 791, + "lib/addons": 510, + "lib/builder-manager": 8509, + "lib/builder-vite": 25830, + "lib/builder-webpack5": 8214, + "lib/channel-postmessage": 4379, + "lib/channel-websocket": 1148, + "lib/channels": 1889, + "lib/cli": 149027, + "lib/client-api": 69, + "lib/client-logger": 1689, + "lib/codemod": 7881, + "lib/core-client": 70, + "lib/core-common": 24643, + "lib/core-events": 3107, + "lib/core-server": 104463, + "lib/core-webpack": 4554, + "lib/csf-plugin": 693, + "lib/csf-tools": 746382, + "lib/docs-tools": 14452, + "lib/instrumenter": 12471, + "lib/manager-api-shim": 53, + "lib/manager-api": 51137, + "lib/node-logger": 1030, + "lib/postinstall": 1480, + "lib/preview-api": 161620, + "lib/preview-web": 70, + "lib/preview": 365141, + "lib/router": 22845, + "lib/source-loader": 17370, + "lib/store": 64, + "lib/telemetry": 11868, + "lib/theming": 100031, + "lib/types": 313, + "presets/html-webpack": 466, + "presets/preact-webpack": 1020, + "presets/react-webpack": 6096, + "presets/server-webpack": 2822, + "presets/svelte-webpack": 3333, + "presets/vue-webpack": 2001, + "presets/vue3-webpack": 2057, + "presets/web-components-webpack": 1180, + "renderers/html": 3570, + "renderers/preact": 1889, + "renderers/react": 28909, + "renderers/server": 2442, + "renderers/svelte": 6958, + "renderers/vue": 9676, + "renderers/vue3": 172022, + "renderers/web-components": 7767, + "ui/blocks": 143722, + "ui/components": 2916698, + "ui/manager": 2508158 +} From 24d85a4634c4af181f445caf068ad5321e6cf044 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 21:04:37 +0100 Subject: [PATCH 11/26] improvement bundlesize --- code/stats.json | 90 -------------------------- code/ui/manager/src/globals/exports.ts | 8 +-- scripts/prepare/bundle.ts | 22 +++---- 3 files changed, 14 insertions(+), 106 deletions(-) delete mode 100644 code/stats.json diff --git a/code/stats.json b/code/stats.json deleted file mode 100644 index f09fa33708e2..000000000000 --- a/code/stats.json +++ /dev/null @@ -1,90 +0,0 @@ -{ - "addons/a11y": 22289, - "addons/actions": 8636, - "addons/backgrounds": 9370, - "addons/controls": 1821, - "addons/docs": 5276, - "addons/essentials": 927, - "addons/highlight": 1648, - "addons/interactions": 60909, - "addons/jest": 12777, - "addons/links": 3050, - "addons/measure": 14450, - "addons/outline": 10185, - "addons/storyshots-core": 6573, - "addons/storyshots-puppeteer": 6702, - "addons/storysource": 4445, - "addons/toolbars": 6214, - "addons/viewport": 8518, - "frameworks/angular": 1632, - "frameworks/ember": 757, - "frameworks/html-vite": 86, - "frameworks/html-webpack5": 771, - "frameworks/nextjs": 32891, - "frameworks/preact-vite": 327, - "frameworks/preact-webpack5": 775, - "frameworks/react-vite": 3390, - "frameworks/react-webpack5": 1395, - "frameworks/server-webpack5": 775, - "frameworks/svelte-vite": 3244, - "frameworks/svelte-webpack5": 775, - "frameworks/sveltekit": 632, - "frameworks/vue-vite": 1343, - "frameworks/vue-webpack5": 832, - "frameworks/vue3-vite": 933, - "frameworks/vue3-webpack5": 834, - "frameworks/web-components-vite": 96, - "frameworks/web-components-webpack5": 791, - "lib/addons": 510, - "lib/builder-manager": 8509, - "lib/builder-vite": 25830, - "lib/builder-webpack5": 8214, - "lib/channel-postmessage": 4379, - "lib/channel-websocket": 1148, - "lib/channels": 1889, - "lib/cli": 149027, - "lib/client-api": 69, - "lib/client-logger": 1689, - "lib/codemod": 7881, - "lib/core-client": 70, - "lib/core-common": 24643, - "lib/core-events": 3107, - "lib/core-server": 104463, - "lib/core-webpack": 4554, - "lib/csf-plugin": 693, - "lib/csf-tools": 746382, - "lib/docs-tools": 14452, - "lib/instrumenter": 12471, - "lib/manager-api-shim": 53, - "lib/manager-api": 51137, - "lib/node-logger": 1030, - "lib/postinstall": 1480, - "lib/preview-api": 161620, - "lib/preview-web": 70, - "lib/preview": 365141, - "lib/router": 22845, - "lib/source-loader": 17370, - "lib/store": 64, - "lib/telemetry": 11868, - "lib/theming": 100031, - "lib/types": 313, - "presets/html-webpack": 466, - "presets/preact-webpack": 1020, - "presets/react-webpack": 6096, - "presets/server-webpack": 2822, - "presets/svelte-webpack": 3333, - "presets/vue-webpack": 2001, - "presets/vue3-webpack": 2057, - "presets/web-components-webpack": 1180, - "renderers/html": 3570, - "renderers/preact": 1889, - "renderers/react": 28909, - "renderers/server": 2442, - "renderers/svelte": 6958, - "renderers/vue": 9676, - "renderers/vue3": 172022, - "renderers/web-components": 7767, - "ui/blocks": 143722, - "ui/components": 2916698, - "ui/manager": 2508158 -} diff --git a/code/ui/manager/src/globals/exports.ts b/code/ui/manager/src/globals/exports.ts index bcc126d07c7d..a369f13a4d83 100644 --- a/code/ui/manager/src/globals/exports.ts +++ b/code/ui/manager/src/globals/exports.ts @@ -47,8 +47,9 @@ export default { 'version', ], '@storybook/components': [ - 'A', 'ActionBar', + 'ScrollArea', + 'A', 'AddonPanel', 'Badge', 'Bar', @@ -79,7 +80,6 @@ export default { 'Placeholder', 'Pre', 'ResetWrapper', - 'ScrollArea', 'Separator', 'Spaced', 'Span', @@ -196,6 +196,7 @@ export default { 'withTheme', ], '@storybook/api': [ + 'types', 'ActiveTabs', 'Consumer', 'ManagerContext', @@ -214,7 +215,6 @@ export default { 'optionOrAltSymbol', 'shortcutMatchesShortcut', 'shortcutToHumanString', - 'types', 'useAddonState', 'useArgTypes', 'useArgs', @@ -228,6 +228,7 @@ export default { 'useStorybookState', ], '@storybook/manager-api': [ + 'types', 'ActiveTabs', 'Consumer', 'ManagerContext', @@ -246,7 +247,6 @@ export default { 'optionOrAltSymbol', 'shortcutMatchesShortcut', 'shortcutToHumanString', - 'types', 'useAddonState', 'useArgTypes', 'useArgs', diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index bdff2cc6aeff..2e6b89e48767 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -5,13 +5,11 @@ import path, { dirname, join, relative } from 'path'; import type { Options } from 'tsup'; import type { PackageJson } from 'type-fest'; import { build } from 'tsup'; -import aliasPlugin from 'esbuild-plugin-alias'; import dedent from 'ts-dedent'; import slash from 'slash'; import { exec } from '../utils/exec'; /* TYPES */ - type Formats = 'esm' | 'cjs'; type BundlerConfig = { entries: string[]; @@ -27,7 +25,6 @@ type PackageJsonWithBundlerConfig = PackageJson & { type DtsConfigSection = Pick; /* MAIN */ - const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { const { name, @@ -75,26 +72,24 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { if (formats.includes('esm')) { tasks.push( build({ + treeshake: true, silent: true, entry: allEntries, watch, outDir, + env: { + NODE_ENV: 'production', + }, format: ['esm'], target: 'chrome100', clean: !watch, ...(dtsBuild === 'esm' ? dtsConfig : {}), platform: platform || 'browser', - esbuildPlugins: [ - aliasPlugin({ - process: path.resolve('../node_modules/process/browser.js'), - util: path.resolve('../node_modules/util/util.js'), - }), - ], external: externals, esbuildOptions: (c) => { /* eslint-disable no-param-reassign */ - c.conditions = ['module']; + c.conditions = [platform || 'browser', 'import', 'module']; c.platform = platform || 'browser'; Object.assign(c, getESBuildOptions(optimized)); /* eslint-enable no-param-reassign */ @@ -106,10 +101,14 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { if (formats.includes('cjs')) { tasks.push( build({ + treeshake: true, silent: true, entry: allEntries, watch, outDir, + env: { + NODE_ENV: 'production', + }, format: ['cjs'], target: 'node16', ...(dtsBuild === 'cjs' ? dtsConfig : {}), @@ -120,6 +119,7 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { esbuildOptions: (c) => { /* eslint-disable no-param-reassign */ c.platform = 'node'; + c.conditions = ['node', 'module']; Object.assign(c, getESBuildOptions(optimized)); /* eslint-enable no-param-reassign */ }, @@ -145,7 +145,6 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { }; /* UTILS */ - async function getDTSConfigs({ formats, entries, @@ -202,7 +201,6 @@ async function generateDTSMapperFile(file: string) { const hasFlag = (flags: string[], name: string) => !!flags.find((s) => s.startsWith(`--${name}`)); /* SELF EXECUTION */ - const flags = process.argv.slice(2); const cwd = process.cwd(); From 71b8ad56821253576894cd1350618304cb77563e Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 21:26:43 +0100 Subject: [PATCH 12/26] stats --- code/stats.json | 90 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 code/stats.json diff --git a/code/stats.json b/code/stats.json new file mode 100644 index 000000000000..86ac55763cd4 --- /dev/null +++ b/code/stats.json @@ -0,0 +1,90 @@ +{ + "addons/a11y": 22001, + "addons/actions": 8548, + "addons/backgrounds": 9070, + "addons/controls": 1749, + "addons/docs": 5256, + "addons/essentials": 948, + "addons/highlight": 1678, + "addons/interactions": 61572, + "addons/jest": 13036, + "addons/links": 3116, + "addons/measure": 14281, + "addons/outline": 10204, + "addons/storyshots-core": 6573, + "addons/storyshots-puppeteer": 6702, + "addons/storysource": 4383, + "addons/toolbars": 5844, + "addons/viewport": 8522, + "frameworks/angular": 1632, + "frameworks/ember": 757, + "frameworks/html-vite": 92, + "frameworks/html-webpack5": 782, + "frameworks/nextjs": 32858, + "frameworks/preact-vite": 343, + "frameworks/preact-webpack5": 786, + "frameworks/react-vite": 3473, + "frameworks/react-webpack5": 1408, + "frameworks/server-webpack5": 786, + "frameworks/svelte-vite": 3165, + "frameworks/svelte-webpack5": 786, + "frameworks/sveltekit": 645, + "frameworks/vue-vite": 1370, + "frameworks/vue-webpack5": 844, + "frameworks/vue3-vite": 963, + "frameworks/vue3-webpack5": 846, + "frameworks/web-components-vite": 102, + "frameworks/web-components-webpack5": 802, + "lib/addons": 344, + "lib/builder-manager": 8267, + "lib/builder-vite": 24896, + "lib/builder-webpack5": 8283, + "lib/channel-postmessage": 4436, + "lib/channel-websocket": 1193, + "lib/channels": 1907, + "lib/cli": 142598, + "lib/client-api": 69, + "lib/client-logger": 1713, + "lib/codemod": 7918, + "lib/core-client": 70, + "lib/core-common": 23852, + "lib/core-events": 3151, + "lib/core-server": 73194, + "lib/core-webpack": 4454, + "lib/csf-plugin": 719, + "lib/csf-tools": 746610, + "lib/docs-tools": 14515, + "lib/instrumenter": 12543, + "lib/manager-api-shim": 53, + "lib/manager-api": 49953, + "lib/node-logger": 1073, + "lib/postinstall": 1488, + "lib/preview-api": 157448, + "lib/preview-web": 70, + "lib/preview": 365317, + "lib/router": 20141, + "lib/source-loader": 17354, + "lib/store": 64, + "lib/telemetry": 11710, + "lib/theming": 75572, + "lib/types": 318, + "presets/html-webpack": 471, + "presets/preact-webpack": 1029, + "presets/react-webpack": 6158, + "presets/server-webpack": 2861, + "presets/svelte-webpack": 3416, + "presets/vue-webpack": 2055, + "presets/vue3-webpack": 2117, + "presets/web-components-webpack": 1185, + "renderers/html": 3583, + "renderers/preact": 1927, + "renderers/react": 28158, + "renderers/server": 2482, + "renderers/svelte": 6952, + "renderers/vue": 9649, + "renderers/vue3": 171268, + "renderers/web-components": 7502, + "ui/blocks": 136062, + "ui/components": 2936830, + "ui/manager": 1984259 +} From 57d63bdfc85aefce015622925b479a90e5282125 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 2 Feb 2023 23:22:06 +0100 Subject: [PATCH 13/26] cleanup --- code/lib/cli/test/default/cli.test.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/code/lib/cli/test/default/cli.test.js b/code/lib/cli/test/default/cli.test.js index f5a85ccaa4cf..b7ead3851c9e 100755 --- a/code/lib/cli/test/default/cli.test.js +++ b/code/lib/cli/test/default/cli.test.js @@ -1,9 +1,3 @@ -jest.mock('lodash-es', () => { - const x = jest.requireActual('lodash'); - - console.log({ x }); -}); - const run = require('../helpers'); describe('Default behavior', () => { From ddda55b702a294cbcd22ce2da38b73294b880e9a Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 02:11:26 +0100 Subject: [PATCH 14/26] fix ordering of exports --- code/ui/manager/scripts/generate-exports-file.ts | 2 +- code/ui/manager/src/globals/exports.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ui/manager/scripts/generate-exports-file.ts b/code/ui/manager/scripts/generate-exports-file.ts index afdbea8ff6e6..e05b6ed1bde6 100644 --- a/code/ui/manager/scripts/generate-exports-file.ts +++ b/code/ui/manager/scripts/generate-exports-file.ts @@ -30,7 +30,7 @@ async function generate(text: string) { const run = async () => { const data = Object.entries(values).reduce>((acc, [key, value]) => { - acc[key] = Object.keys(value).filter(removeDefault); + acc[key] = Object.keys(value).filter(removeDefault).sort(); return acc; }, {}); diff --git a/code/ui/manager/src/globals/exports.ts b/code/ui/manager/src/globals/exports.ts index bcc126d07c7d..b1cff9a85b9c 100644 --- a/code/ui/manager/src/globals/exports.ts +++ b/code/ui/manager/src/globals/exports.ts @@ -259,6 +259,6 @@ export default { 'useStorybookApi', 'useStorybookState', ], - '@storybook/addons': ['addons', 'types', 'mockChannel'], + '@storybook/addons': ['addons', 'mockChannel', 'types'], '@storybook/client-logger': ['deprecate', 'logger', 'once', 'pretty'], } as const; From 7398de2a9cf6ee4192f5d1d2050089f55ef326aa Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 09:13:26 +0100 Subject: [PATCH 15/26] update stats --- code/stats.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/stats.json b/code/stats.json index cdbb448f5fb7..76bf946b9af9 100644 --- a/code/stats.json +++ b/code/stats.json @@ -49,10 +49,10 @@ "lib/core-client": 70, "lib/core-common": 23852, "lib/core-events": 3151, - "lib/core-server": 73194, + "lib/core-server": 73909, "lib/core-webpack": 4454, "lib/csf-plugin": 719, - "lib/csf-tools": 746610, + "lib/csf-tools": 746789, "lib/docs-tools": 14515, "lib/instrumenter": 12543, "lib/manager-api-shim": 53, @@ -86,5 +86,5 @@ "renderers/web-components": 7502, "ui/blocks": 136059, "ui/components": 2936826, - "ui/manager": 1984240 -} \ No newline at end of file + "ui/manager": 1983971 +} From c5dd5180b98614c4cd592f4da5898a1ae6fde4e4 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 12:07:28 +0100 Subject: [PATCH 16/26] regen stats --- code/stats.json | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/code/stats.json b/code/stats.json index e69de29bb2d1..e764ecffd912 100644 --- a/code/stats.json +++ b/code/stats.json @@ -0,0 +1,58 @@ +{ + "addons/a11y": 22001, + "addons/actions": 8548, + "addons/backgrounds": 9070, + "addons/controls": 1749, + "addons/docs": 5397, + "addons/essentials": 948, + "addons/highlight": 1678, + "addons/interactions": 61572, + "addons/jest": 13036, + "addons/links": 3116, + "addons/measure": 14281, + "addons/outline": 10204, + "addons/storyshots-core": 6573, + "addons/storyshots-puppeteer": 6702, + "addons/storysource": 4383, + "addons/toolbars": 5844, + "addons/viewport": 8522, + "frameworks/angular": 1632, + "frameworks/ember": 757, + "frameworks/react-vite": 3473, + "frameworks/vue-webpack5": 844, + "lib/addons": 344, + "lib/channel-postmessage": 4436, + "lib/channel-websocket": 1193, + "lib/channels": 1907, + "lib/client-api": 69, + "lib/client-logger": 1713, + "lib/core-client": 70, + "lib/core-common": 23852, + "lib/core-events": 3151, + "lib/csf-plugin": 719, + "lib/csf-tools": 746789, + "lib/docs-tools": 14515, + "lib/instrumenter": 12543, + "lib/manager-api-shim": 53, + "lib/manager-api": 49953, + "lib/node-logger": 1073, + "lib/postinstall": 1488, + "lib/preview-api": 157448, + "lib/preview-web": 70, + "lib/preview": 365317, + "lib/router": 20141, + "lib/store": 64, + "lib/theming": 75562, + "lib/types": 318, + "renderers/html": 3583, + "renderers/preact": 1927, + "renderers/react": 28158, + "renderers/server": 2482, + "renderers/svelte": 6952, + "renderers/vue": 9649, + "renderers/vue3": 172272, + "renderers/web-components": 7502, + "ui/blocks": 136059, + "ui/components": 2936826, + "ui/manager": 1983971 +} From df6609d355b5e2394050450f7e300d97e1ffa2cd Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 16:04:06 +0100 Subject: [PATCH 17/26] use CSF version without lodash --- code/addons/links/package.json | 2 +- code/addons/storyshots-puppeteer/package.json | 2 +- code/lib/codemod/package.json | 2 +- code/lib/core-server/package.json | 2 +- code/lib/csf-tools/package.json | 2 +- code/lib/manager-api/package.json | 2 +- code/lib/preview-api/package.json | 2 +- code/lib/source-loader/package.json | 2 +- code/lib/types/package.json | 2 +- code/package.json | 2 +- code/stats.json | 4 +- code/ui/blocks/package.json | 2 +- code/ui/components/package.json | 2 +- code/yarn.lock | 44 +++++++++---------- scripts/package.json | 1 + scripts/prepare/bundle.ts | 17 +++++++ scripts/yarn.lock | 8 ++++ 17 files changed, 61 insertions(+), 37 deletions(-) diff --git a/code/addons/links/package.json b/code/addons/links/package.json index 246523796d33..084848cdf4bd 100644 --- a/code/addons/links/package.json +++ b/code/addons/links/package.json @@ -82,7 +82,7 @@ "dependencies": { "@storybook/client-logger": "7.0.0-beta.40", "@storybook/core-events": "7.0.0-beta.40", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/global": "^5.0.0", "@storybook/manager-api": "7.0.0-beta.40", "@storybook/preview-api": "7.0.0-beta.40", diff --git a/code/addons/storyshots-puppeteer/package.json b/code/addons/storyshots-puppeteer/package.json index ac4e6bdcf2f5..b3b42fb8203c 100644 --- a/code/addons/storyshots-puppeteer/package.json +++ b/code/addons/storyshots-puppeteer/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "@axe-core/puppeteer": "^4.2.0", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/node-logger": "7.0.0-beta.40", "@storybook/types": "7.0.0-beta.40", "@types/jest-image-snapshot": "^5.1.0", diff --git a/code/lib/codemod/package.json b/code/lib/codemod/package.json index 149b8f80ed5a..b33666a101d9 100644 --- a/code/lib/codemod/package.json +++ b/code/lib/codemod/package.json @@ -47,7 +47,7 @@ "@babel/core": "^7.20.2", "@babel/preset-env": "^7.20.2", "@babel/types": "^7.20.7", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/csf-tools": "7.0.0-beta.40", "@storybook/node-logger": "7.0.0-beta.40", "@storybook/types": "7.0.0-beta.40", diff --git a/code/lib/core-server/package.json b/code/lib/core-server/package.json index eabcddf99ffd..0975a4b5c1ef 100644 --- a/code/lib/core-server/package.json +++ b/code/lib/core-server/package.json @@ -57,7 +57,7 @@ "@storybook/builder-manager": "7.0.0-beta.40", "@storybook/core-common": "7.0.0-beta.40", "@storybook/core-events": "7.0.0-beta.40", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/csf-tools": "7.0.0-beta.40", "@storybook/docs-mdx": "next", "@storybook/global": "^5.0.0", diff --git a/code/lib/csf-tools/package.json b/code/lib/csf-tools/package.json index 3ae3d4b0c3a4..cf8801b01d8a 100644 --- a/code/lib/csf-tools/package.json +++ b/code/lib/csf-tools/package.json @@ -44,7 +44,7 @@ }, "dependencies": { "@babel/types": "^7.20.2", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/types": "7.0.0-beta.40", "fs-extra": "^11.1.0", "recast": "^0.23.1", diff --git a/code/lib/manager-api/package.json b/code/lib/manager-api/package.json index 20fd21b433e4..79704ddbc3e2 100644 --- a/code/lib/manager-api/package.json +++ b/code/lib/manager-api/package.json @@ -45,7 +45,7 @@ "@storybook/channels": "7.0.0-beta.40", "@storybook/client-logger": "7.0.0-beta.40", "@storybook/core-events": "7.0.0-beta.40", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/global": "^5.0.0", "@storybook/router": "7.0.0-beta.40", "@storybook/theming": "7.0.0-beta.40", diff --git a/code/lib/preview-api/package.json b/code/lib/preview-api/package.json index 4b98b0464480..669e4e3872e3 100644 --- a/code/lib/preview-api/package.json +++ b/code/lib/preview-api/package.json @@ -71,7 +71,7 @@ "@storybook/channels": "7.0.0-beta.40", "@storybook/client-logger": "7.0.0-beta.40", "@storybook/core-events": "7.0.0-beta.40", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/global": "^5.0.0", "@storybook/types": "7.0.0-beta.40", "@types/lodash-es": "^4.17.6", diff --git a/code/lib/source-loader/package.json b/code/lib/source-loader/package.json index 0f3ae65c291f..2f23280eb402 100644 --- a/code/lib/source-loader/package.json +++ b/code/lib/source-loader/package.json @@ -42,7 +42,7 @@ "prep": "../../../scripts/prepare/bundle.ts" }, "dependencies": { - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/types": "7.0.0-beta.40", "estraverse": "^5.2.0", "lodash": "^4.17.21", diff --git a/code/lib/types/package.json b/code/lib/types/package.json index 729cc1963377..9c7743ed6531 100644 --- a/code/lib/types/package.json +++ b/code/lib/types/package.json @@ -51,7 +51,7 @@ "file-system-cache": "^2.0.0" }, "devDependencies": { - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@types/node": "^16.0.0", "typescript": "~4.9.3" }, diff --git a/code/package.json b/code/package.json index d6949deeaf2c..a964d6a9aa82 100644 --- a/code/package.json +++ b/code/package.json @@ -137,7 +137,7 @@ "@storybook/core-events": "workspace:*", "@storybook/core-server": "workspace:*", "@storybook/core-webpack": "workspace:*", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/csf-plugin": "workspace:*", "@storybook/csf-tools": "workspace:*", "@storybook/docs-tools": "workspace:*", diff --git a/code/stats.json b/code/stats.json index e764ecffd912..2881d5cc9460 100644 --- a/code/stats.json +++ b/code/stats.json @@ -39,7 +39,7 @@ "lib/postinstall": 1488, "lib/preview-api": 157448, "lib/preview-web": 70, - "lib/preview": 365317, + "lib/preview": 316667, "lib/router": 20141, "lib/store": 64, "lib/theming": 75562, @@ -54,5 +54,5 @@ "renderers/web-components": 7502, "ui/blocks": 136059, "ui/components": 2936826, - "ui/manager": 1983971 + "ui/manager": 1935714 } diff --git a/code/ui/blocks/package.json b/code/ui/blocks/package.json index 6e2f59eb193d..9b8e46851d4d 100644 --- a/code/ui/blocks/package.json +++ b/code/ui/blocks/package.json @@ -47,7 +47,7 @@ "@storybook/client-logger": "7.0.0-beta.40", "@storybook/components": "7.0.0-beta.40", "@storybook/core-events": "7.0.0-beta.40", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/docs-tools": "7.0.0-beta.40", "@storybook/global": "^5.0.0", "@storybook/manager-api": "7.0.0-beta.40", diff --git a/code/ui/components/package.json b/code/ui/components/package.json index b02013a4e1f8..54f70fa5affb 100644 --- a/code/ui/components/package.json +++ b/code/ui/components/package.json @@ -49,7 +49,7 @@ }, "dependencies": { "@storybook/client-logger": "7.0.0-beta.40", - "@storybook/csf": "next", + "@storybook/csf": "0.0.2--canary.62.9cd6451.0", "@storybook/global": "^5.0.0", "@storybook/theming": "7.0.0-beta.40", "@storybook/types": "7.0.0-beta.40", diff --git a/code/yarn.lock b/code/yarn.lock index 8953821f2bf2..30168f0eb079 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5331,7 +5331,7 @@ __metadata: dependencies: "@storybook/client-logger": 7.0.0-beta.40 "@storybook/core-events": 7.0.0-beta.40 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/global": ^5.0.0 "@storybook/manager-api": 7.0.0-beta.40 "@storybook/preview-api": 7.0.0-beta.40 @@ -5404,7 +5404,7 @@ __metadata: resolution: "@storybook/addon-storyshots-puppeteer@workspace:addons/storyshots-puppeteer" dependencies: "@axe-core/puppeteer": ^4.2.0 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/node-logger": 7.0.0-beta.40 "@storybook/types": 7.0.0-beta.40 "@types/jest-image-snapshot": ^5.1.0 @@ -5701,7 +5701,7 @@ __metadata: "@storybook/client-logger": 7.0.0-beta.40 "@storybook/components": 7.0.0-beta.40 "@storybook/core-events": 7.0.0-beta.40 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/docs-tools": 7.0.0-beta.40 "@storybook/global": ^5.0.0 "@storybook/manager-api": 7.0.0-beta.40 @@ -5976,7 +5976,7 @@ __metadata: "@babel/core": ^7.20.2 "@babel/preset-env": ^7.20.2 "@babel/types": ^7.20.7 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/csf-tools": 7.0.0-beta.40 "@storybook/node-logger": 7.0.0-beta.40 "@storybook/types": 7.0.0-beta.40 @@ -6001,7 +6001,7 @@ __metadata: dependencies: "@popperjs/core": ^2.6.0 "@storybook/client-logger": 7.0.0-beta.40 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/global": ^5.0.0 "@storybook/theming": 7.0.0-beta.40 "@storybook/types": 7.0.0-beta.40 @@ -6088,7 +6088,7 @@ __metadata: "@storybook/builder-manager": 7.0.0-beta.40 "@storybook/core-common": 7.0.0-beta.40 "@storybook/core-events": 7.0.0-beta.40 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/csf-tools": 7.0.0-beta.40 "@storybook/docs-mdx": next "@storybook/global": ^5.0.0 @@ -6167,7 +6167,7 @@ __metadata: "@babel/parser": ^7.20.3 "@babel/traverse": ^7.20.1 "@babel/types": ^7.20.2 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/types": 7.0.0-beta.40 "@types/fs-extra": ^11.0.1 "@types/js-yaml": ^3.12.6 @@ -6179,23 +6179,21 @@ __metadata: languageName: unknown linkType: soft -"@storybook/csf@npm:^0.0.1": - version: 0.0.1 - resolution: "@storybook/csf@npm:0.0.1" +"@storybook/csf@npm:0.0.2--canary.62.9cd6451.0": + version: 0.0.2--canary.62.9cd6451.0 + resolution: "@storybook/csf@npm:0.0.2--canary.62.9cd6451.0" dependencies: - lodash: ^4.17.15 - checksum: 7b0f75763415f9147692a460b44417ee56ea9639433716a1fd4d1df4c8b0221cbc71b8da0fbed4dcecb3ccd6c7ed64be39f5c255c713539a6088a1d6488aaa24 + type-fest: ^2.19.0 + checksum: a2367af88744754338718d0ec047deebe50985c728351843c1d73d362f3031502481a19a8a2a0670025215fc0c7a94e6a002b7b0d63b8ac56d9a7128d381be72 languageName: node linkType: hard -"@storybook/csf@npm:next": - version: 0.0.2-next.8 - resolution: "@storybook/csf@npm:0.0.2-next.8" +"@storybook/csf@npm:^0.0.1": + version: 0.0.1 + resolution: "@storybook/csf@npm:0.0.1" dependencies: - expect-type: ^0.14.2 lodash: ^4.17.15 - type-fest: ^2.19.0 - checksum: 86f5599c030b87cbab6fa5e4b4a9ef1aeed5e838b993b2bae5f0fc50d79ae80d5cfbf2590a05bae0a95068ef77eec88d8c102072d63c77745afe74f91cfa03a3 + checksum: 7b0f75763415f9147692a460b44417ee56ea9639433716a1fd4d1df4c8b0221cbc71b8da0fbed4dcecb3ccd6c7ed64be39f5c255c713539a6088a1d6488aaa24 languageName: node linkType: hard @@ -6398,7 +6396,7 @@ __metadata: "@storybook/channels": 7.0.0-beta.40 "@storybook/client-logger": 7.0.0-beta.40 "@storybook/core-events": 7.0.0-beta.40 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/global": ^5.0.0 "@storybook/router": 7.0.0-beta.40 "@storybook/theming": 7.0.0-beta.40 @@ -6768,7 +6766,7 @@ __metadata: "@storybook/client-logger": 7.0.0-beta.40 "@storybook/core-common": 7.0.0-beta.40 "@storybook/core-events": 7.0.0-beta.40 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/global": ^5.0.0 "@storybook/types": 7.0.0-beta.40 "@types/lodash-es": ^4.17.6 @@ -6965,7 +6963,7 @@ __metadata: "@storybook/core-events": "workspace:*" "@storybook/core-server": "workspace:*" "@storybook/core-webpack": "workspace:*" - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/csf-plugin": "workspace:*" "@storybook/csf-tools": "workspace:*" "@storybook/docs-tools": "workspace:*" @@ -7156,7 +7154,7 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/source-loader@workspace:lib/source-loader" dependencies: - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@storybook/types": 7.0.0-beta.40 estraverse: ^5.2.0 jest-specific-snapshot: ^7.0.0 @@ -7317,7 +7315,7 @@ __metadata: dependencies: "@babel/core": ^7.12.10 "@storybook/channels": 7.0.0-beta.40 - "@storybook/csf": next + "@storybook/csf": 0.0.2--canary.62.9cd6451.0 "@types/babel__core": ^7.0.0 "@types/express": ^4.7.0 "@types/node": ^16.0.0 diff --git a/scripts/package.json b/scripts/package.json index 8a589c6906bb..cf1eeb51f355 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 f588141e70f8..208711a0a56c 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 */ @@ -102,6 +105,7 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { if (formats.includes('esm')) { tasks.push( build({ + metafile: true, treeshake: true, silent: true, entry: allEntries, @@ -117,8 +121,21 @@ 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|@storybook\/csf)\/.*/, + }), + ], + esbuildOptions: (c) => { /* eslint-disable no-param-reassign */ + c.alias = { + lodash: 'lodash-es', + }; c.conditions = [platform || 'browser', 'import', 'module']; c.platform = platform || 'browser'; Object.assign(c, getESBuildOptions(optimized)); diff --git a/scripts/yarn.lock b/scripts/yarn.lock index ab1edb9aca27..7f908b7513d8 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -2811,6 +2811,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 @@ -6358,6 +6359,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" From f950037a750e3dc097e4fee37555ba3165b16348 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 16:09:17 +0100 Subject: [PATCH 18/26] cleanup --- scripts/prepare/bundle.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index 208711a0a56c..2b48e701d43c 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -105,7 +105,6 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { if (formats.includes('esm')) { tasks.push( build({ - metafile: true, treeshake: true, silent: true, entry: allEntries, @@ -127,7 +126,7 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { }), lodashTransformer({ outLodashPackage: 'lodash-es', - filter: /node_modules\/(react-resize-detector|@storybook\/csf)\/.*/, + filter: /node_modules\/(react-resize-detector)\/.*/, }), ], From b0e1fb0714f79fe6f045bee517d3782fad783de9 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 16:13:48 +0100 Subject: [PATCH 19/26] fix linting --- code/renderers/vue3/src/docs/sourceDecorator.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/code/renderers/vue3/src/docs/sourceDecorator.ts b/code/renderers/vue3/src/docs/sourceDecorator.ts index 182b8b6a758e..f93a8385777c 100644 --- a/code/renderers/vue3/src/docs/sourceDecorator.ts +++ b/code/renderers/vue3/src/docs/sourceDecorator.ts @@ -4,7 +4,6 @@ import type { ArgTypes, Args, StoryContext, Renderer } from '@storybook/types'; import { SourceType, SNIPPET_RENDERED } from '@storybook/docs-tools'; -// eslint-disable-next-line import/no-extraneous-dependencies import parserHTML from 'prettier/parser-html'; // eslint-disable-next-line import/no-extraneous-dependencies From 812ea30d38013799e8b35e0337467a99be4db789 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 17:17:47 +0100 Subject: [PATCH 20/26] bump csf package --- code/addons/links/package.json | 2 +- code/addons/storyshots-puppeteer/package.json | 2 +- code/lib/codemod/package.json | 2 +- code/lib/core-server/package.json | 2 +- code/lib/csf-tools/package.json | 2 +- code/lib/manager-api/package.json | 2 +- code/lib/preview-api/package.json | 2 +- code/lib/source-loader/package.json | 2 +- code/lib/types/package.json | 2 +- code/package.json | 2 +- code/ui/blocks/package.json | 2 +- code/ui/components/package.json | 2 +- code/yarn.lock | 32 +++++++++---------- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/code/addons/links/package.json b/code/addons/links/package.json index 7dc834c6a98a..234662f14f3d 100644 --- a/code/addons/links/package.json +++ b/code/addons/links/package.json @@ -82,7 +82,7 @@ "dependencies": { "@storybook/client-logger": "7.0.0-beta.41", "@storybook/core-events": "7.0.0-beta.41", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/global": "^5.0.0", "@storybook/manager-api": "7.0.0-beta.41", "@storybook/preview-api": "7.0.0-beta.41", diff --git a/code/addons/storyshots-puppeteer/package.json b/code/addons/storyshots-puppeteer/package.json index f01f2c153ba4..825ce5d03667 100644 --- a/code/addons/storyshots-puppeteer/package.json +++ b/code/addons/storyshots-puppeteer/package.json @@ -35,7 +35,7 @@ }, "dependencies": { "@axe-core/puppeteer": "^4.2.0", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/node-logger": "7.0.0-beta.41", "@storybook/types": "7.0.0-beta.41", "@types/jest-image-snapshot": "^5.1.0", diff --git a/code/lib/codemod/package.json b/code/lib/codemod/package.json index 22c07f927095..bc9ed8f24262 100644 --- a/code/lib/codemod/package.json +++ b/code/lib/codemod/package.json @@ -47,7 +47,7 @@ "@babel/core": "^7.20.2", "@babel/preset-env": "^7.20.2", "@babel/types": "^7.20.7", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/csf-tools": "7.0.0-beta.41", "@storybook/node-logger": "7.0.0-beta.41", "@storybook/types": "7.0.0-beta.41", diff --git a/code/lib/core-server/package.json b/code/lib/core-server/package.json index 2af61efd4e3a..6ff9e6ae346c 100644 --- a/code/lib/core-server/package.json +++ b/code/lib/core-server/package.json @@ -57,7 +57,7 @@ "@storybook/builder-manager": "7.0.0-beta.41", "@storybook/core-common": "7.0.0-beta.41", "@storybook/core-events": "7.0.0-beta.41", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/csf-tools": "7.0.0-beta.41", "@storybook/docs-mdx": "next", "@storybook/global": "^5.0.0", diff --git a/code/lib/csf-tools/package.json b/code/lib/csf-tools/package.json index 29e41a3790e4..5260f9c83adf 100644 --- a/code/lib/csf-tools/package.json +++ b/code/lib/csf-tools/package.json @@ -44,7 +44,7 @@ }, "dependencies": { "@babel/types": "^7.20.2", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/types": "7.0.0-beta.41", "fs-extra": "^11.1.0", "recast": "^0.23.1", diff --git a/code/lib/manager-api/package.json b/code/lib/manager-api/package.json index 7b91a767bba6..4048707803f3 100644 --- a/code/lib/manager-api/package.json +++ b/code/lib/manager-api/package.json @@ -45,7 +45,7 @@ "@storybook/channels": "7.0.0-beta.41", "@storybook/client-logger": "7.0.0-beta.41", "@storybook/core-events": "7.0.0-beta.41", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/global": "^5.0.0", "@storybook/router": "7.0.0-beta.41", "@storybook/theming": "7.0.0-beta.41", diff --git a/code/lib/preview-api/package.json b/code/lib/preview-api/package.json index 90064a80bd41..04140c3b88bc 100644 --- a/code/lib/preview-api/package.json +++ b/code/lib/preview-api/package.json @@ -71,7 +71,7 @@ "@storybook/channels": "7.0.0-beta.41", "@storybook/client-logger": "7.0.0-beta.41", "@storybook/core-events": "7.0.0-beta.41", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/global": "^5.0.0", "@storybook/types": "7.0.0-beta.41", "@types/lodash-es": "^4.17.6", diff --git a/code/lib/source-loader/package.json b/code/lib/source-loader/package.json index 7a6849d87e26..505f1ba78534 100644 --- a/code/lib/source-loader/package.json +++ b/code/lib/source-loader/package.json @@ -42,7 +42,7 @@ "prep": "../../../scripts/prepare/bundle.ts" }, "dependencies": { - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/types": "7.0.0-beta.41", "estraverse": "^5.2.0", "lodash": "^4.17.21", diff --git a/code/lib/types/package.json b/code/lib/types/package.json index 9b180d2af2d4..5a2ed9f7cc17 100644 --- a/code/lib/types/package.json +++ b/code/lib/types/package.json @@ -51,7 +51,7 @@ "file-system-cache": "^2.0.0" }, "devDependencies": { - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@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 242e4dcc3244..e003b6a7f1fe 100644 --- a/code/package.json +++ b/code/package.json @@ -137,7 +137,7 @@ "@storybook/core-events": "workspace:*", "@storybook/core-server": "workspace:*", "@storybook/core-webpack": "workspace:*", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/csf-plugin": "workspace:*", "@storybook/csf-tools": "workspace:*", "@storybook/docs-tools": "workspace:*", diff --git a/code/ui/blocks/package.json b/code/ui/blocks/package.json index fb0d5963e861..7e29b550dbc9 100644 --- a/code/ui/blocks/package.json +++ b/code/ui/blocks/package.json @@ -47,7 +47,7 @@ "@storybook/client-logger": "7.0.0-beta.41", "@storybook/components": "7.0.0-beta.41", "@storybook/core-events": "7.0.0-beta.41", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/docs-tools": "7.0.0-beta.41", "@storybook/global": "^5.0.0", "@storybook/manager-api": "7.0.0-beta.41", diff --git a/code/ui/components/package.json b/code/ui/components/package.json index c22c2f144255..52f8414d0442 100644 --- a/code/ui/components/package.json +++ b/code/ui/components/package.json @@ -49,7 +49,7 @@ }, "dependencies": { "@storybook/client-logger": "7.0.0-beta.41", - "@storybook/csf": "0.0.2--canary.62.9cd6451.0", + "@storybook/csf": "0.0.2--canary.62.5777911.0", "@storybook/global": "^5.0.0", "@storybook/theming": "7.0.0-beta.41", "@storybook/types": "7.0.0-beta.41", diff --git a/code/yarn.lock b/code/yarn.lock index 6ae88b11969b..80ace647409b 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5338,7 +5338,7 @@ __metadata: dependencies: "@storybook/client-logger": 7.0.0-beta.41 "@storybook/core-events": 7.0.0-beta.41 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/global": ^5.0.0 "@storybook/manager-api": 7.0.0-beta.41 "@storybook/preview-api": 7.0.0-beta.41 @@ -5411,7 +5411,7 @@ __metadata: resolution: "@storybook/addon-storyshots-puppeteer@workspace:addons/storyshots-puppeteer" dependencies: "@axe-core/puppeteer": ^4.2.0 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/node-logger": 7.0.0-beta.41 "@storybook/types": 7.0.0-beta.41 "@types/jest-image-snapshot": ^5.1.0 @@ -5708,7 +5708,7 @@ __metadata: "@storybook/client-logger": 7.0.0-beta.41 "@storybook/components": 7.0.0-beta.41 "@storybook/core-events": 7.0.0-beta.41 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/docs-tools": 7.0.0-beta.41 "@storybook/global": ^5.0.0 "@storybook/manager-api": 7.0.0-beta.41 @@ -6004,7 +6004,7 @@ __metadata: "@babel/core": ^7.20.2 "@babel/preset-env": ^7.20.2 "@babel/types": ^7.20.7 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/csf-tools": 7.0.0-beta.41 "@storybook/node-logger": 7.0.0-beta.41 "@storybook/types": 7.0.0-beta.41 @@ -6029,7 +6029,7 @@ __metadata: dependencies: "@popperjs/core": ^2.6.0 "@storybook/client-logger": 7.0.0-beta.41 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/global": ^5.0.0 "@storybook/theming": 7.0.0-beta.41 "@storybook/types": 7.0.0-beta.41 @@ -6124,7 +6124,7 @@ __metadata: "@storybook/builder-manager": 7.0.0-beta.41 "@storybook/core-common": 7.0.0-beta.41 "@storybook/core-events": 7.0.0-beta.41 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/csf-tools": 7.0.0-beta.41 "@storybook/docs-mdx": next "@storybook/global": ^5.0.0 @@ -6203,7 +6203,7 @@ __metadata: "@babel/parser": ^7.20.3 "@babel/traverse": ^7.20.1 "@babel/types": ^7.20.2 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/types": 7.0.0-beta.41 "@types/fs-extra": ^11.0.1 "@types/js-yaml": ^3.12.6 @@ -6215,12 +6215,12 @@ __metadata: languageName: unknown linkType: soft -"@storybook/csf@npm:0.0.2--canary.62.9cd6451.0": - version: 0.0.2--canary.62.9cd6451.0 - resolution: "@storybook/csf@npm:0.0.2--canary.62.9cd6451.0" +"@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: a2367af88744754338718d0ec047deebe50985c728351843c1d73d362f3031502481a19a8a2a0670025215fc0c7a94e6a002b7b0d63b8ac56d9a7128d381be72 + checksum: 80c4ea3e09d9e93fd8cd438b3a894705bb84ffe90c7a71a01915e45c0f5ebf67a941e716a128cd95ed017181150484942ade24af84316e39d907bbc514b6d4b4 languageName: node linkType: hard @@ -6443,7 +6443,7 @@ __metadata: "@storybook/channels": 7.0.0-beta.41 "@storybook/client-logger": 7.0.0-beta.41 "@storybook/core-events": 7.0.0-beta.41 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/global": ^5.0.0 "@storybook/router": 7.0.0-beta.41 "@storybook/theming": 7.0.0-beta.41 @@ -6813,7 +6813,7 @@ __metadata: "@storybook/client-logger": 7.0.0-beta.41 "@storybook/core-common": 7.0.0-beta.41 "@storybook/core-events": 7.0.0-beta.41 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/global": ^5.0.0 "@storybook/types": 7.0.0-beta.41 "@types/lodash-es": ^4.17.6 @@ -7034,7 +7034,7 @@ __metadata: "@storybook/core-events": "workspace:*" "@storybook/core-server": "workspace:*" "@storybook/core-webpack": "workspace:*" - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/csf-plugin": "workspace:*" "@storybook/csf-tools": "workspace:*" "@storybook/docs-tools": "workspace:*" @@ -7225,7 +7225,7 @@ __metadata: version: 0.0.0-use.local resolution: "@storybook/source-loader@workspace:lib/source-loader" dependencies: - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@storybook/csf": 0.0.2--canary.62.5777911.0 "@storybook/types": 7.0.0-beta.41 estraverse: ^5.2.0 jest-specific-snapshot: ^7.0.0 @@ -7386,7 +7386,7 @@ __metadata: dependencies: "@babel/core": ^7.12.10 "@storybook/channels": 7.0.0-beta.41 - "@storybook/csf": 0.0.2--canary.62.9cd6451.0 + "@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 From 4fd31464fe3e8a52a5b8bfd9efdfd2d7abce2986 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 20:28:48 +0100 Subject: [PATCH 21/26] remove env setup for cjs bundles --- scripts/prepare/bundle.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index 2b48e701d43c..81c9e6487dd3 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -151,9 +151,6 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { entry: allEntries, watch, outDir, - env: { - NODE_ENV: 'production', - }, format: ['cjs'], target: 'node16', ...(dtsBuild === 'cjs' ? dtsConfig : {}), From ef244f8d69f3ca916f641b934dedb7c125f6cc7c Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 20:49:40 +0100 Subject: [PATCH 22/26] do not load esm in cjs bundle --- scripts/prepare/bundle.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index 81c9e6487dd3..f4d1d910ab5e 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -157,11 +157,16 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { platform: 'node', clean: !watch, external: externals, + esbuildPlugins: [ + esbuildAliasPlugin({ + 'lodash-es': 'lodash', + }), + ], esbuildOptions: (c) => { /* eslint-disable no-param-reassign */ c.platform = 'node'; - c.conditions = ['node', 'module']; + c.conditions = ['node', 'require']; Object.assign(c, getESBuildOptions(optimized)); /* eslint-enable no-param-reassign */ }, From 5ef185abb2470215baae9f332ff5f636eb90453f Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 21:06:41 +0100 Subject: [PATCH 23/26] add alias --- scripts/prepare/bundle.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index f4d1d910ab5e..e2d1fd19b4d6 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -135,8 +135,8 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { c.alias = { lodash: 'lodash-es', }; - c.conditions = [platform || 'browser', 'import', 'module']; c.platform = platform || 'browser'; + c.conditions = [platform || 'browser', 'import', 'module']; Object.assign(c, getESBuildOptions(optimized)); /* eslint-enable no-param-reassign */ }, @@ -165,6 +165,9 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { esbuildOptions: (c) => { /* eslint-disable no-param-reassign */ + c.alias = { + 'lodash-es': 'lodash', + }; c.platform = 'node'; c.conditions = ['node', 'require']; Object.assign(c, getESBuildOptions(optimized)); From 0c0b13b80e898ff7b127bea26a8be2ddaf502479 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 21:20:49 +0100 Subject: [PATCH 24/26] fix lodash manually, oof --- scripts/prepare/bundle.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index e2d1fd19b4d6..87ea2732abdd 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -132,6 +132,7 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { esbuildOptions: (c) => { /* eslint-disable no-param-reassign */ + c.absWorkingDir = cwd; c.alias = { lodash: 'lodash-es', }; @@ -157,14 +158,23 @@ 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': 'lodash', + 'lodash-es': require.resolve('lodash'), }), ], esbuildOptions: (c) => { /* eslint-disable no-param-reassign */ + c.absWorkingDir = cwd; c.alias = { 'lodash-es': 'lodash', }; From e1382fb2942a8dfc0c2fcef97cad99c0a462036e Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Fri, 3 Feb 2023 21:59:39 +0100 Subject: [PATCH 25/26] bump lockfiles --- code/yarn.lock | 123 +++++++++---------------------------------------- 1 file changed, 23 insertions(+), 100 deletions(-) diff --git a/code/yarn.lock b/code/yarn.lock index 80ace647409b..e933a9dbd4e5 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5877,20 +5877,6 @@ __metadata: languageName: unknown linkType: soft -"@storybook/channel-postmessage@npm:7.0.0-beta.40": - version: 7.0.0-beta.40 - resolution: "@storybook/channel-postmessage@npm:7.0.0-beta.40" - dependencies: - "@storybook/channels": 7.0.0-beta.40 - "@storybook/client-logger": 7.0.0-beta.40 - "@storybook/core-events": 7.0.0-beta.40 - "@storybook/global": ^5.0.0 - qs: ^6.10.0 - telejson: ^7.0.3 - checksum: 359bc17cdafc072f7738c5bcdf2e5797eac820280704cbb2787b2ad32ea4234d949563939d35a441b175b5b68cf3381c7d31f374096580839663e819f5a907f6 - languageName: node - linkType: hard - "@storybook/channel-websocket@7.0.0-beta.41, @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" @@ -5911,13 +5897,6 @@ __metadata: languageName: unknown linkType: soft -"@storybook/channels@npm:7.0.0-beta.40": - version: 7.0.0-beta.40 - resolution: "@storybook/channels@npm:7.0.0-beta.40" - checksum: bc339b2a7a18c28156188c11b3d2b85f4ae71b2ae81a71b7aa15bc3c49cc76eaf0999604adc4c3372bafc961bb27907a526f447efbde321424469cc97e739663 - languageName: node - linkType: hard - "@storybook/cli@7.0.0-beta.41, @storybook/cli@workspace:*, @storybook/cli@workspace:lib/cli": version: 0.0.0-use.local resolution: "@storybook/cli@workspace:lib/cli" @@ -5988,12 +5967,12 @@ __metadata: languageName: unknown linkType: soft -"@storybook/client-logger@npm:7.0.0-beta.40, @storybook/client-logger@npm:next": - version: 7.0.0-beta.40 - resolution: "@storybook/client-logger@npm:7.0.0-beta.40" +"@storybook/client-logger@npm:next": + version: 7.0.0-beta.41 + resolution: "@storybook/client-logger@npm:7.0.0-beta.41" dependencies: "@storybook/global": ^5.0.0 - checksum: de441fc1a4deef416362a2e3a1b33478c3112776767cdd7498f4496495137369f9367a2f70c55695be41704cf760aa8e9882aed434e53853ee9afb7a0989e833 + checksum: 0c4d8d8fdafb2ada1cd8a9990ebebda4cc1266de06506289f93cca57fd5f512739590d74fbf8414438316b11b84218127faac52d16bf96e2106ac6103e7094cb languageName: node linkType: hard @@ -6108,13 +6087,6 @@ __metadata: languageName: unknown linkType: soft -"@storybook/core-events@npm:7.0.0-beta.40": - version: 7.0.0-beta.40 - resolution: "@storybook/core-events@npm:7.0.0-beta.40" - checksum: 8f883451c030339ebe69c693cb06d4e932207fdea4c17be0348c17e55569c90a9e21621d10ed6c57f57d33041154693796ecf54a41c70a5c166fb6e060bc9f67 - languageName: node - linkType: hard - "@storybook/core-server@7.0.0-beta.41, @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" @@ -6233,17 +6205,6 @@ __metadata: languageName: node linkType: hard -"@storybook/csf@npm:next": - version: 0.0.2-next.8 - resolution: "@storybook/csf@npm:0.0.2-next.8" - dependencies: - expect-type: ^0.14.2 - lodash: ^4.17.15 - type-fest: ^2.19.0 - checksum: 86f5599c030b87cbab6fa5e4b4a9ef1aeed5e838b993b2bae5f0fc50d79ae80d5cfbf2590a05bae0a95068ef77eec88d8c102072d63c77745afe74f91cfa03a3 - languageName: node - linkType: hard - "@storybook/docs-mdx@npm:next": version: 0.0.1-next.6 resolution: "@storybook/docs-mdx@npm:0.0.1-next.6" @@ -6384,15 +6345,15 @@ __metadata: linkType: soft "@storybook/instrumenter@npm:next": - version: 7.0.0-beta.40 - resolution: "@storybook/instrumenter@npm:7.0.0-beta.40" + version: 7.0.0-beta.41 + resolution: "@storybook/instrumenter@npm:7.0.0-beta.41" dependencies: - "@storybook/channels": 7.0.0-beta.40 - "@storybook/client-logger": 7.0.0-beta.40 - "@storybook/core-events": 7.0.0-beta.40 + "@storybook/channels": 7.0.0-beta.41 + "@storybook/client-logger": 7.0.0-beta.41 + "@storybook/core-events": 7.0.0-beta.41 "@storybook/global": ^5.0.0 - "@storybook/preview-api": 7.0.0-beta.40 - checksum: 823b46722e14d455a8d13f3d4dc2164cb17fd12be761046a64461c144cfdd8244a30b054304adb87c09d0495a958413bb9f98d5141545f460619ccc541ef4f30 + "@storybook/preview-api": 7.0.0-beta.41 + checksum: 6f780570b39d1a8cd1c006abf7c951e1ae86b39beefe52b6308bcf6ffaee7b6e584f70833000cd88b5192cf141d290beb1c28dfb85b5dc2a1ef1358bcb547d3f languageName: node linkType: hard @@ -6831,30 +6792,6 @@ __metadata: languageName: unknown linkType: soft -"@storybook/preview-api@npm:7.0.0-beta.40": - version: 7.0.0-beta.40 - resolution: "@storybook/preview-api@npm:7.0.0-beta.40" - dependencies: - "@storybook/channel-postmessage": 7.0.0-beta.40 - "@storybook/channels": 7.0.0-beta.40 - "@storybook/client-logger": 7.0.0-beta.40 - "@storybook/core-events": 7.0.0-beta.40 - "@storybook/csf": next - "@storybook/global": ^5.0.0 - "@storybook/types": 7.0.0-beta.40 - "@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: 8d4b43f566960f5bad7612764771acd6eb172b83668bd198fc138a80d74e2120450e721446d6eff3cd363c97c23ffa7b302b4c243dceeb3a21a8c96571661df2 - languageName: node - linkType: hard - "@storybook/preview-web@7.0.0-beta.41, @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" @@ -7396,20 +7333,6 @@ __metadata: languageName: unknown linkType: soft -"@storybook/types@npm:7.0.0-beta.40": - version: 7.0.0-beta.40 - resolution: "@storybook/types@npm:7.0.0-beta.40" - dependencies: - "@babel/core": ^7.12.10 - "@storybook/channels": 7.0.0-beta.40 - "@types/babel__core": ^7.0.0 - "@types/express": ^4.7.0 - express: ^4.17.3 - file-system-cache: ^2.0.0 - checksum: f137c4df7bc58e9eafda1f4a7f01c027ac81a4d08e98f55d1c9c3c8c1415f18a9be516b6f1e4fa211a7a2aed65546035165513278a656f90ac663d4f772ea005 - 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" @@ -10452,13 +10375,13 @@ __metadata: linkType: hard "axios@npm:^1.0.0": - version: 1.3.1 - resolution: "axios@npm:1.3.1" + version: 1.3.2 + resolution: "axios@npm:1.3.2" dependencies: follow-redirects: ^1.15.0 form-data: ^4.0.0 proxy-from-env: ^1.1.0 - checksum: 2a5bda6ad006cc14f3226f9e98cf99254c032199fe5bef7f25cd787eafecc273f56cb7e300cab1e8574c9e7ff3646d180ef526382883b4e3bb46311ad4c2e47d + checksum: 163f4b41e7a447b17aa131cd915aea0cf35aa00eb62531292c66359436dc16eef82cab64a5dc2cafcb612744b34789fa84615031cd06a55ac982e7add14e4468 languageName: node linkType: hard @@ -13544,9 +13467,9 @@ __metadata: linkType: hard "electron-to-chromium@npm:^1.4.251, electron-to-chromium@npm:^1.4.284": - version: 1.4.285 - resolution: "electron-to-chromium@npm:1.4.285" - checksum: 34b90670cad2106e548f99aea6cfaa6f5d0f9fd76078bbc599dde6cf0a25d4469709ddef0e4cb3ce7b15a929006ae5820f09b3086de4d2f4c4a9c6f270a15c47 + version: 1.4.286 + resolution: "electron-to-chromium@npm:1.4.286" + checksum: eaf7833b7b1baf40ea4971bdf407ac128a6fee8d01cd8b5d54f11d5eeb6d581343194b00b15bcb01c1337792bb8cd3ac0b3db883dbf47bb509ed9a988f10a179 languageName: node linkType: hard @@ -24925,8 +24848,8 @@ __metadata: linkType: hard "rollup@npm:^3.0.0, rollup@npm:^3.10.0": - version: 3.12.1 - resolution: "rollup@npm:3.12.1" + version: 3.13.0 + resolution: "rollup@npm:3.13.0" dependencies: fsevents: ~2.3.2 dependenciesMeta: @@ -24934,7 +24857,7 @@ __metadata: optional: true bin: rollup: dist/bin/rollup - checksum: a34a11b03779b46a810fe69df98395ebd588145b792d149eb39a56fb4e92b19afb249075f86065d0fd767709348b5a034df913e81d1bf7ac66c25e14e0c8bb1b + checksum: 2e1d7eeddc7a5e78a238aab8620d613bed6856abb2d511a15978b1738a9ee04f0e84e4c4696e6dbf44609dd081ec878a22dc0e2ec4d9afb1fc2c544964a1c59c languageName: node linkType: hard @@ -26772,8 +26695,8 @@ __metadata: linkType: hard "terser@npm:^5.10.0, terser@npm:^5.14.1": - version: 5.16.2 - resolution: "terser@npm:5.16.2" + version: 5.16.3 + resolution: "terser@npm:5.16.3" dependencies: "@jridgewell/source-map": ^0.3.2 acorn: ^8.5.0 @@ -26781,7 +26704,7 @@ __metadata: source-map-support: ~0.5.20 bin: terser: bin/terser - checksum: e68c4ecc738c897277353b1883980030475f895b6c4ea9be06e1ed49eb193655efeec408f71a60492464857df86533e7e20474db9b02aa3d3389d1305e5edad8 + checksum: c798a39187982f193f70f057ccb9f2d4090f8a32c2aad93c63732617053e124bb24abe1056bc06dea1ebae912f209af8b29cc7fc763e14137003b512fc5909c1 languageName: node linkType: hard From bb04939893b4dd1d335e47384d72d9341306a4ea Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 7 Feb 2023 11:38:24 +0100 Subject: [PATCH 26/26] cleanup --- code/lib/router/package.json | 1 - code/yarn.lock | 1 - 2 files changed, 2 deletions(-) diff --git a/code/lib/router/package.json b/code/lib/router/package.json index b11724ed492c..1b3b9fb011f9 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/yarn.lock b/code/yarn.lock index 7d392bee14d5..31c1489c5df3 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -7180,7 +7180,6 @@ __metadata: "@storybook/client-logger": 7.0.0-beta.43 "@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