Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future / pre-built manager - using esbuild #18550

Merged
merged 77 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
53941ed
wip
ndelangen Jun 23, 2022
433ce7e
Merge branch 'future/tsup-libs-1' into future/pbm/stage0
ndelangen Jun 23, 2022
7034730
wip
ndelangen Jun 23, 2022
5cbe4a2
ok, so this is step 1, just an option, not final.
ndelangen Jun 23, 2022
f543123
polyfills and such
ndelangen Jun 23, 2022
42bcdaa
Made a new manager-builder package, purely based on esbuild
ndelangen Jun 23, 2022
6d8c17c
progress
ndelangen Jun 24, 2022
7aeedfd
wip
ndelangen Jun 24, 2022
680d2ba
optimize
ndelangen Jun 24, 2022
79e2b95
fix lockfile
ndelangen Jun 24, 2022
fc96c97
cleanup
ndelangen Jun 24, 2022
82aea41
cleanup
ndelangen Jun 24, 2022
4461be2
cleanup
ndelangen Jun 24, 2022
fa872be
cleanup, I'm in the process of removing stats output completely from …
ndelangen Jun 27, 2022
002602d
wip
ndelangen Jun 27, 2022
8b98d81
fix
ndelangen Jun 27, 2022
41ba71b
fixes
ndelangen Jun 27, 2022
8b1fd16
change code to make it work and all that kind of stuff
ndelangen Jun 27, 2022
5806c1d
small correction
ndelangen Jun 27, 2022
4f4e81d
add pnp support?
ndelangen Jun 27, 2022
0486456
see if this helps
ndelangen Jun 27, 2022
37c63bb
improve
ndelangen Jun 27, 2022
4a7f2e6
fix tests
ndelangen Jun 27, 2022
624b384
hmm
ndelangen Jun 27, 2022
c2c1980
found the problem finally!
ndelangen Jun 28, 2022
0cf66eb
cleanup
ndelangen Jun 28, 2022
988982a
cleanup
ndelangen Jun 28, 2022
0cd0ee3
test
ndelangen Jun 28, 2022
6652719
fix examples e2e test
ndelangen Jun 28, 2022
b2456bc
try to fix bench
ndelangen Jun 28, 2022
ba20be8
try new version of sb bench
ndelangen Jun 28, 2022
bab81c2
hmm
ndelangen Jun 28, 2022
b2b4c2f
Merge branch 'future/tsup-libs-1' into future/pbm/stage0
ndelangen Jun 29, 2022
dd733a7
Merge branch 'future/base' into future/pbm/stage0
ndelangen Jun 29, 2022
ca96423
add a check script in each package
ndelangen Jun 29, 2022
b34e020
add a `yarn check` command similar to `yarn build` for type checking …
ndelangen Jun 29, 2022
54c5fea
Merge branch 'future/base' into future/pbm/stage0
ndelangen Jun 29, 2022
ac9051d
Merge branch 'future/pbm/stage0' into future/type-checking-script
ndelangen Jun 29, 2022
3d687c4
Merge branch 'future/base' into future/pbm/stage0
ndelangen Jun 29, 2022
8fa554c
Merge branch 'future/pbm/stage0' into future/type-checking-script
ndelangen Jun 29, 2022
ca3d3cc
fix
ndelangen Jun 29, 2022
438396a
Merge branch 'future/pbm/stage0' into future/type-checking-script
ndelangen Jun 29, 2022
0cd7a5e
make theming use TSup again (didn't I do this before?!?!?!
ndelangen Jun 29, 2022
755ac81
Merge branch 'future/pbm/stage0' into future/type-checking-script
ndelangen Jun 29, 2022
f444aff
Merge branch 'future/base' into future/pbm/stage0
ndelangen Jun 29, 2022
5661ebc
fix
ndelangen Jun 29, 2022
f9c2887
Merge branch 'future/pbm/stage0' into future/type-checking-script
ndelangen Jun 29, 2022
cff35ff
add assert polyfill, urgh! yuck!
ndelangen Jun 29, 2022
8db89d2
add assert polyfill, urgh, yuck!
ndelangen Jun 29, 2022
817bc21
Merge branch 'future/pbm/stage0' into future/type-checking-script
ndelangen Jun 29, 2022
db0bfe3
fix
ndelangen Jun 29, 2022
98cecda
Merge branch 'future/pbm/stage0' into future/type-checking-script
ndelangen Jun 29, 2022
31494ae
..
ndelangen Jun 29, 2022
bfc3c9a
Merge branch 'future/pbm/stage0' into future/type-checking-script
ndelangen Jun 29, 2022
09a728e
cleanup
ndelangen Jun 29, 2022
ac0317e
swap out assert for a hyper-lightweight alternative. It has what we n…
ndelangen Jun 29, 2022
5d69729
try this
ndelangen Jun 29, 2022
164263c
Merge branch 'future/pbm/stage0' into future/type-checking-script
ndelangen Jun 30, 2022
5a3eef5
use playright in the bench
ndelangen Jun 30, 2022
186fb8f
Merge pull request #18606 from storybookjs/future/playright-bench
ndelangen Jun 30, 2022
afaf987
Merge pull request #18603 from storybookjs/future/type-checking-script
ndelangen Jun 30, 2022
4731572
Merge branch 'future/base' into future/prebuilt-manager-esbuild
ndelangen Jul 1, 2022
15b78a9
Merge branch 'future/pbm/stage0' of github.com:storybookjs/storybook …
ndelangen Jul 1, 2022
e595591
Merge branch 'future/base' into future/prebuilt-manager-esbuild
ndelangen Jul 2, 2022
0fea552
no unsafe eval
ndelangen Jul 5, 2022
bd8a220
add support for preview-head.html to new prebuild manager
ndelangen Jul 5, 2022
b188566
add refs feature back
ndelangen Jul 5, 2022
974b58f
fix test
ndelangen Jul 5, 2022
df75162
fix deepscan issue
ndelangen Jul 5, 2022
7eb15b6
merge future/base
ndelangen Jul 5, 2022
445e120
cleanup
ndelangen Jul 5, 2022
9338267
fix removed new package
ndelangen Jul 5, 2022
795c33c
add comments to explain the situation with globals, and why we do wha…
ndelangen Jul 6, 2022
364f6af
cleanup
ndelangen Jul 6, 2022
3ec6235
cleanup and add LOGLEVEL support
ndelangen Jul 6, 2022
8b7bc3b
fix and add a CI check that generated files are not mutated during CI…
ndelangen Jul 6, 2022
8a703bf
move event name to core-events package
ndelangen Jul 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ jobs:
command: yarn install --immutable
- run:
name: Bootstrap
command: yarn bootstrap --build --manager
command: |
yarn bootstrap --build
git diff --exit-code
- save_cache:
name: Save Yarn cache
key: build-yarn-2-cache-v3--{{ checksum "yarn.lock" }}
Expand Down
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ docs/public
storybook-static
built-storybooks
lib/cli/test
lib/manager-webpack5/prebuilt
lib/core-server/prebuilt
lib/codemod/src/transforms/__testfixtures__
scripts/storage
scripts/repros-generator
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ cypress/screenshots
examples/ember-cli/ember-output
.verdaccio-cache
tsconfig.tsbuildinfo
lib/manager-webpack5/prebuilt
lib/manager-webpack5/prebuilt
examples/angular-cli/addon-jest.testresults.json
junit.xml
.next
Expand Down
2 changes: 1 addition & 1 deletion examples/react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build-storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true storybook build",
"debug": "cross-env NODE_OPTIONS=--inspect-brk STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true storybook dev -p 9011",
"storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true storybook dev --no-manager-cache"
"storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true storybook dev --port=3044"
},
"dependencies": {
"formik": "^2.2.9",
Expand Down
2 changes: 1 addition & 1 deletion examples/web-components-kitchen-sink/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"@storybook/addon-viewport": "link:../../addons/viewport",
"@storybook/addons": "link:../../lib/addons",
"@storybook/api": "link:../../lib/api",
"@storybook/builder-manager": "link:../../lib/builder-manager",
"@storybook/builder-webpack5": "link:../../lib/builder-webpack5",
"@storybook/channel-postmessage": "link:../../lib/channel-postmessage",
"@storybook/channel-websocket": "link:../../lib/channel-websocket",
Expand All @@ -46,7 +47,6 @@
"@storybook/csf-tools": "link:../../lib/csf-tools",
"@storybook/docs-tools": "link:../../lib/docs-tools",
"@storybook/jest": "^0.0.5",
"@storybook/manager-webpack5": "link:../../lib/manager-webpack5",
"@storybook/mdx1-csf": "canary",
"@storybook/node-logger": "link:../../lib/node-logger",
"@storybook/postinstall": "link:../../lib/postinstall",
Expand Down
4 changes: 4 additions & 0 deletions lib/addons/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import global from 'global';
import type { ReactElement } from 'react';
import { Channel } from '@storybook/channels';
import { SET_CONFIG } from '@storybook/core-events';
import type { API } from '@storybook/api';
import type { RenderData as RouterData } from '@storybook/router';
import { logger } from '@storybook/client-logger';
Expand Down Expand Up @@ -124,6 +125,9 @@ export class AddonStore {

setConfig = (value: Config) => {
Object.assign(this.config, value);
if (this.hasChannel()) {
this.getChannel().emit(SET_CONFIG, value);
}
};

getConfig = () => this.config;
Expand Down
14 changes: 12 additions & 2 deletions lib/api/src/modules/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import global from 'global';
import pick from 'lodash/pick';
import deepEqual from 'fast-deep-equal';
import { create } from '@storybook/theming';
import { SET_CONFIG } from '@storybook/core-events';
import type { ThemeVars } from '@storybook/theming';
import { once } from '@storybook/client-logger';
import { dedent } from 'ts-dedent';
Expand Down Expand Up @@ -93,7 +94,7 @@ export const focusableUIElements = {
storyPanelRoot: 'storybook-panel-root',
};

export const init: ModuleFn = ({ store, provider, singleStory }) => {
export const init: ModuleFn = ({ store, provider, singleStory, fullAPI }) => {
const api = {
toggleFullscreen(toggled?: boolean) {
return store.setState(
Expand Down Expand Up @@ -295,5 +296,14 @@ export const init: ModuleFn = ({ store, provider, singleStory }) => {

const persisted = pick(store.getState(), 'layout', 'ui', 'selectedPanel');

return { api, state: merge(api.getInitialOptions(), persisted) };
return {
api,
state: merge(api.getInitialOptions(), persisted),
init: () => {
api.setOptions(merge(api.getInitialOptions(), persisted));
fullAPI.on(SET_CONFIG, () => {
api.setOptions(merge(api.getInitialOptions(), persisted));
});
},
};
};
3 changes: 1 addition & 2 deletions lib/api/src/modules/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Channel } from '@storybook/channels';
import type { ThemeVars } from '@storybook/theming';

import type { API, State, ModuleFn, HashEntry } from '../index';
import type { StoryMapper, Refs } from './refs';
import type { StoryMapper } from './refs';
import type { UIOptions } from './layout';

interface SidebarOptions {
Expand All @@ -29,7 +29,6 @@ export interface Provider {
getConfig(): {
sidebar?: SidebarOptions;
theme?: ThemeVars;
refs?: Refs;
StoryMapper?: StoryMapper;
[k: string]: any;
} & Partial<UIOptions>;
Expand Down
2 changes: 1 addition & 1 deletion lib/api/src/modules/refs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export const init: ModuleFn<SubAPI, SubState, void> = (
},
};

const refs = (!singleStory && provider.getConfig().refs) || {};
const refs: Refs = (!singleStory && global.REFS) || {};

const initialState: SubState['refs'] = refs;

Expand Down
33 changes: 15 additions & 18 deletions lib/api/src/tests/refs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ const { fetch } = global;
jest.mock('global', () => {
const globalMock = {
fetch: jest.fn(() => Promise.resolve({})),
REFS: {
fake: {
id: 'fake',
url: 'https://example.com',
title: 'Fake',
},
},
};
// Change global.location value to handle edge cases
// Add additional variations of global.location mock return values in this array.
Expand All @@ -26,15 +33,7 @@ jest.mock('global', () => {
});

const provider = {
getConfig: jest.fn().mockReturnValue({
refs: {
fake: {
id: 'fake',
url: 'https://example.com',
title: 'Fake',
},
},
}),
getConfig: jest.fn().mockReturnValue({}),
};

const store = {
Expand Down Expand Up @@ -167,16 +166,14 @@ describe('Refs API', () => {

it('passes version when set on the ref', async () => {
// given
provider.getConfig.mockReturnValueOnce({
refs: {
fake: {
id: 'fake',
url: 'https://example.com',
title: 'Fake',
version: '2.1.3-rc.2',
},
global.REFS = {
fake: {
id: 'fake',
url: 'https://example.com',
title: 'Fake',
version: '2.1.3-rc.2',
},
});
};
initRefs({ provider, store });

expect(fetch.mock.calls).toMatchInlineSnapshot(`
Expand Down
3 changes: 3 additions & 0 deletions lib/builder-manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Manager-Builder

TODO
74 changes: 74 additions & 0 deletions lib/builder-manager/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"name": "@storybook/builder-manager",
"version": "7.0.0-alpha.10",
"description": "Storybook manager builder",
"keywords": [
"storybook"
],
"homepage": "https://github.com/storybookjs/storybook/tree/main/lib/core",
"bugs": {
"url": "https://github.com/storybookjs/storybook/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/storybookjs/storybook.git",
"directory": "lib/builder-manager"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/storybook"
},
"license": "MIT",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist/**/*",
"templates/**/*",
"*.js",
"*.d.ts"
],
"scripts": {
"check": "tsc --noEmit",
"prepare": "esrun ../../scripts/prepare/bundle.ts"
},
"dependencies": {
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
"@storybook/core-common": "7.0.0-alpha.10",
"@storybook/node-logger": "7.0.0-alpha.10",
"@storybook/ui": "7.0.0-alpha.10",
"@types/ejs": "^3.1.1",
"@yarnpkg/esbuild-plugin-pnp": "^3.0.0-rc.10",
"browser-assert": "^1.2.1",
"chalk": "^4.1.0",
"ejs": "^3.1.8",
"esbuild": "^0.14.47",
"esbuild-plugin-alias": "^0.2.1",
"express": "^4.17.1",
"fs-extra": "^9.0.1",
"readdirp": "^3.6.0",
"rollup-plugin-node-polyfills": "^0.2.1"
},
"devDependencies": {
"@digitak/esrun": "^3.2.2",
"typescript": "~4.6.3"
},
"publishConfig": {
"access": "public"
},
"bundler": {
"entries": [
"./src/index.ts"
],
"platform": "node"
},
"gitHead": "b13dd8fb52819d73d4983148af8ffc5d683e8b75"
}
Loading