-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Build: Overhaul dev script & compile-babel & compile-tsc #17338
Changes from all commits
5d9a1c8
cd36ab5
5444107
e4aff5c
bea3416
9c77ed4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -221,7 +221,6 @@ jobs: | |
name: Run E2E tests | ||
# Do not test CRA here because it's done in PnP part | ||
# TODO: Remove `web_components_typescript` as soon as Lit 2 stable is released | ||
# TODO: Add `angular` as soon as Storybook is compatible with Angular 13 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cleanup, AFAICS we DO support angular13 now, it's literally in the list below |
||
command: yarn test:e2e-framework vue3 angular130 angular13 angular12 angular11 web_components_typescript web_components_lit2 | ||
no_output_timeout: 5m | ||
- store_artifacts: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
"common/**/*", | ||
"ember/**/*", | ||
"html/**/*", | ||
"svelte/**/*", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the svelte app, has a before this file was copied over (multiple times) to all the |
||
"postinstall/**/*", | ||
"react/**/*", | ||
"vue/**/*", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,8 @@ import { AnyFramework, StoryFn } from '@storybook/csf'; | |
|
||
import React from 'react'; | ||
|
||
// @ts-ignore | ||
import HOC from './HOC.svelte'; | ||
Comment on lines
-5
to
-6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See point above
|
||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import HOC from '@storybook/addon-docs/svelte/HOC.svelte'; | ||
|
||
export const prepareForInline = (storyFn: StoryFn<AnyFramework>) => { | ||
const el = React.useRef(null); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import React from 'react'; | |
import { addons } from '@storybook/addons'; | ||
|
||
import { StoryPanel } from './StoryPanel'; | ||
import { ADDON_ID, PANEL_ID } from '.'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This just makes it easier to actually find references to this file, the In fact, during my prebundling work this was actually a problem, so let's avoid it shall we? |
||
import { ADDON_ID, PANEL_ID } from './index'; | ||
|
||
addons.register(ADDON_ID, (api) => { | ||
addons.addPanel(PANEL_ID, { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,19 +4,17 @@ import { decorateStory } from './decorators'; | |
import './globals'; | ||
import { render, renderToDOM } from './render'; | ||
|
||
const { configure: coreConfigure, clientApi, forceReRender } = start(renderToDOM, { | ||
const { | ||
configure: coreConfigure, | ||
clientApi, | ||
forceReRender, | ||
} = start(renderToDOM, { | ||
decorateStory, | ||
render, | ||
}); | ||
|
||
export const { | ||
setAddon, | ||
addDecorator, | ||
addParameters, | ||
clearDecorators, | ||
getStorybook, | ||
raw, | ||
} = clientApi; | ||
export const { setAddon, addDecorator, addParameters, clearDecorators, getStorybook, raw } = | ||
clientApi; | ||
Comment on lines
+7
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just formatting |
||
|
||
const framework = 'svelte'; | ||
export const storiesOf = (kind: string, m: any) => | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
declare module 'global'; | ||
declare module '*.svelte'; | ||
declare module '@storybook/svelte/templates/SlotDecorator.svelte'; | ||
declare module '@storybook/svelte/templates/PreviewRender.svelte'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,8 +143,8 @@ npx sb@next link --local /path/to/local-repro-directory | |
|
||
<details> | ||
|
||
<summary>`yarn dev` watches everything but is resource-intensive</summary> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the |
||
<summary>`yarn build --all --watch` watches everything but is resource-intensive</summary> | ||
|
||
It's troublesome to know which packages you're going to change ahead of time, and watching all of them can be highly demanding, even on modern machines. If you're working on a powerful enough machine, you can use `yarn dev` instead of `yarn build`. | ||
It's troublesome to know which packages you're going to change ahead of time, and watching all of them can be highly demanding, even on modern machines. If you're working on a powerful enough machine, you can use `yarn build --all --watch` instead of `yarn build`. | ||
|
||
</details> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,7 @@ | |
}, | ||
"files": [ | ||
"dist/**/*", | ||
"dll/**/*", | ||
"types/**/*", | ||
Comment on lines
-34
to
-35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cleanup, neither of these folders exist anymore |
||
"templates/**/*", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the templates directory, I've moved the non-source files we previously had babel copy them into dist (multiple times). Now they are located in the package root in a templates directory. (and so they have to be in the allow-list for npm! |
||
"*.js", | ||
"*.d.ts" | ||
], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,11 @@ export default async (options: Options & Record<string, any>): Promise<Configura | |
|
||
const configEntryPath = path.resolve(path.join(workingDir, 'storybook-config-entry.js')); | ||
virtualModuleMapping[configEntryPath] = handlebars( | ||
await readTemplate(path.join(__dirname, 'virtualModuleModernEntry.js.handlebars')), | ||
await readTemplate( | ||
require.resolve( | ||
'@storybook/builder-webpack4/templates/virtualModuleModernEntry.js.handlebars' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So here's a discussion point: I can resolve to a file in the current package's root in (at least) 2 ways:
Option 2 works by working up with the So option 2 would look like this instead: path.resolve(
path.join(
pkgDir.sync(__dirname),
'./templates/virtualModuleModernEntry.js.handlebars'
)
) In fact I HAD to use the above technique in 1 place because of unit-tests mocking the file-system. SO should I use option 2 everywhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reason it feels safer to me, it feels sort of weird to Another alternative would be do it relative |
||
) | ||
), | ||
{ | ||
storiesFilename, | ||
configs, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,7 @@ | |
}, | ||
"files": [ | ||
"dist/**/*", | ||
"dll/**/*", | ||
"types/**/*", | ||
Comment on lines
-34
to
-35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cleanup |
||
"templates/**/*", | ||
"*.js", | ||
"*.d.ts" | ||
], | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ | |
"compilerOptions": { | ||
"rootDir": "./src" | ||
}, | ||
"include": [ | ||
"src/**/*" | ||
], | ||
Comment on lines
+6
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When working on the stdout and stderr coming from I ran into a problem where TSC tried to compile files in |
||
"exclude": [ | ||
"src/**/*.test.*", | ||
"src/**/tests/**/*", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,8 +38,7 @@ | |
"dist/**/*", | ||
"README.md", | ||
"*.js", | ||
"*.d.ts", | ||
"versions.json" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cleanup: This file does not exist |
||
"*.d.ts" | ||
], | ||
"scripts": { | ||
"prepare": "node ../../scripts/prepare.js", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
#!/usr/bin/env node | ||
|
||
const { writeJson, readJson } = require('fs-extra'); | ||
const { readJson, writeFile } = require('fs-extra'); | ||
const path = require('path'); | ||
const globby = require('globby'); | ||
const semver = require('@storybook/semver'); | ||
const { default: dedent } = require('ts-dedent'); | ||
|
||
const rootDirectory = path.join(__dirname, '..', '..', '..'); | ||
|
||
|
@@ -39,9 +40,13 @@ const run = async () => { | |
.sort((package1, package2) => package1.name.localeCompare(package2.name)) | ||
.reduce((acc, { name }) => ({ ...acc, [name]: updatedVersion }), {}); | ||
|
||
await writeJson(path.join(__dirname, '..', 'src', 'versions.json'), packageToVersionMap, { | ||
spaces: 2, | ||
}); | ||
await writeFile( | ||
path.join(__dirname, '..', 'src', 'versions.ts'), | ||
dedent` | ||
// auto generated file, do not edit | ||
export default ${JSON.stringify(packageToVersionMap, null, 2)} | ||
` | ||
); | ||
}; | ||
Comment on lines
+43
to
50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This script now generates a It's easy enough to do (as you can see). The reason I did this, is because By generating the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shilman I can revert this if you'd like... We should remove the script if we're not using it... |
||
|
||
run().catch((e) => { | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// auto generated file, do not edit | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shilman I did not see ANY references of the script that generates this (but the file is up to date, so I assume something is using it?) Could you let me know if another script is generating this? |
||
export default { | ||
'@storybook/addon-a11y': '6.5.0-alpha.23', | ||
'@storybook/addon-actions': '6.5.0-alpha.23', | ||
'@storybook/addon-backgrounds': '6.5.0-alpha.23', | ||
'@storybook/addon-controls': '6.5.0-alpha.23', | ||
'@storybook/addon-docs': '6.5.0-alpha.23', | ||
'@storybook/addon-essentials': '6.5.0-alpha.23', | ||
'@storybook/addon-interactions': '6.5.0-alpha.23', | ||
'@storybook/addon-jest': '6.5.0-alpha.23', | ||
'@storybook/addon-links': '6.5.0-alpha.23', | ||
'@storybook/addon-measure': '6.5.0-alpha.23', | ||
'@storybook/addon-outline': '6.5.0-alpha.23', | ||
'@storybook/addon-storyshots': '6.5.0-alpha.23', | ||
'@storybook/addon-storyshots-puppeteer': '6.5.0-alpha.23', | ||
'@storybook/addon-storysource': '6.5.0-alpha.23', | ||
'@storybook/addon-toolbars': '6.5.0-alpha.23', | ||
'@storybook/addon-viewport': '6.5.0-alpha.23', | ||
'@storybook/addons': '6.5.0-alpha.23', | ||
'@storybook/angular': '6.5.0-alpha.23', | ||
'@storybook/api': '6.5.0-alpha.23', | ||
'@storybook/builder-webpack4': '6.5.0-alpha.23', | ||
'@storybook/builder-webpack5': '6.5.0-alpha.23', | ||
'@storybook/channel-postmessage': '6.5.0-alpha.23', | ||
'@storybook/channel-websocket': '6.5.0-alpha.23', | ||
'@storybook/channels': '6.5.0-alpha.23', | ||
'@storybook/cli': '6.5.0-alpha.23', | ||
'@storybook/client-api': '6.5.0-alpha.23', | ||
'@storybook/client-logger': '6.5.0-alpha.23', | ||
'@storybook/codemod': '6.5.0-alpha.23', | ||
'@storybook/components': '6.5.0-alpha.23', | ||
'@storybook/core': '6.5.0-alpha.23', | ||
'@storybook/core-client': '6.5.0-alpha.23', | ||
'@storybook/core-common': '6.5.0-alpha.23', | ||
'@storybook/core-events': '6.5.0-alpha.23', | ||
'@storybook/core-server': '6.5.0-alpha.23', | ||
'@storybook/csf-tools': '6.5.0-alpha.23', | ||
'@storybook/ember': '6.5.0-alpha.23', | ||
'@storybook/html': '6.5.0-alpha.23', | ||
'@storybook/instrumenter': '6.5.0-alpha.23', | ||
'@storybook/manager-webpack4': '6.5.0-alpha.23', | ||
'@storybook/manager-webpack5': '6.5.0-alpha.23', | ||
'@storybook/node-logger': '6.5.0-alpha.23', | ||
'@storybook/postinstall': '6.5.0-alpha.23', | ||
'@storybook/preact': '6.5.0-alpha.23', | ||
'@storybook/preview-web': '6.5.0-alpha.23', | ||
'@storybook/react': '6.5.0-alpha.23', | ||
'@storybook/router': '6.5.0-alpha.23', | ||
'@storybook/server': '6.5.0-alpha.23', | ||
'@storybook/source-loader': '6.5.0-alpha.23', | ||
'@storybook/store': '6.5.0-alpha.23', | ||
'@storybook/svelte': '6.5.0-alpha.23', | ||
'@storybook/theming': '6.5.0-alpha.23', | ||
'@storybook/ui': '6.5.0-alpha.23', | ||
'@storybook/vue': '6.5.0-alpha.23', | ||
'@storybook/vue3': '6.5.0-alpha.23', | ||
'@storybook/web-components': '6.5.0-alpha.23', | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import global from 'global'; | ||
import React, { createElement, ElementType, FunctionComponent, Fragment } from 'react'; | ||
|
||
import type { Parameters } from '@storybook/api'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
import type { Parameters } from '@storybook/csf'; | ||
|
||
import { IFrame } from './IFrame'; | ||
import { EmptyBlock } from './EmptyBlock'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,8 @@ | |
}, | ||
"files": [ | ||
"dist/**/*", | ||
"dll/**/*", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cleanup |
||
"types/**/*", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This actually DOES exist here, I assume the |
||
"templates/**/*", | ||
"*.js", | ||
"*.d.ts" | ||
], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SO this is an interesting one:
I was tweaking around with the output from the compile-babel command, and when it piped stdout to the main process, it started complaining about
loose
not being configured correctly.It suggested I added this, and when I did the error disappeared. 🎈
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was also an issue I faced when using the babel config for the prebundler work.