Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
183ab1b
getting started add install cli yarn
May 27, 2023
e92438e
Merge branch 'next' into docs/get-started-init-yarn
May 29, 2023
16d0156
search label for attribute doesn't match id of input (fixes #23463)
Jul 14, 2023
303bc06
Merge branch 'next' into 23463-search-input-label-for
yannbf Aug 15, 2023
6b00ed9
Make sure the Next.js Image Context is reused instead of recreated wh…
martinnabhan Aug 20, 2023
ba0e4e2
Merge branch 'next' into bugfix/nextjs-image-context
ndelangen Aug 25, 2023
f4a1021
Make sure the Next.js Image Context is reused instead of recreated wh…
martinnabhan Aug 29, 2023
3bd2046
add visual tests addon to storybook:ui
yannbf Aug 30, 2023
15b8f83
sanitize ansi codes in error message and stack
yannbf Aug 31, 2023
e2e9c24
use node 18 to generate angular sandboxes
JReinhold Aug 31, 2023
07b6e3e
temp workflow rename
JReinhold Aug 31, 2023
3c17f4b
debug strategy
JReinhold Aug 31, 2023
ce6c6f5
improve error message
JReinhold Aug 31, 2023
123bcb4
remove debug
JReinhold Aug 31, 2023
1e9c34f
rename gh workflow back
JReinhold Aug 31, 2023
73810cd
extract angular prerelease to separate CI run
JReinhold Aug 31, 2023
7a4bad6
add node version log to angular prerelease ci
JReinhold Aug 31, 2023
36370f9
add angular job to ci workflow
JReinhold Aug 31, 2023
52ecb89
treat empty error messages in telemetry reports and allow non-error i…
yannbf Aug 31, 2023
d72e968
enable daily jobs again
JReinhold Aug 31, 2023
6f219e9
fix bad circleci config
JReinhold Aug 31, 2023
dd9722d
make cleanpaths case insensitive
yannbf Aug 31, 2023
d6be6ba
Fix generated properties on Svelte event handler
j3rem1e Aug 31, 2023
d5e10e4
improvements to generate script
JReinhold Aug 31, 2023
25e7e8d
test gh workflow
JReinhold Aug 31, 2023
4610e4a
remove test workflow
JReinhold Sep 1, 2023
c48ba15
remove node hack from sanitization
yannbf Sep 1, 2023
acbcacf
treat empty error messages in telemetry reports and allow non-error i…
yannbf Aug 31, 2023
e92d874
categorize webpack builder error
yannbf Sep 1, 2023
553789e
standardize errors thrown in webpack builder
yannbf Sep 1, 2023
ea268a9
fix generate sandbox task
JReinhold Sep 1, 2023
d607118
fix typo
omahs Sep 2, 2023
623dfda
fix typo
omahs Sep 2, 2023
a5e0b3c
fix typo
omahs Sep 2, 2023
8b3c2e3
Docs: Fix page router path to pathname
sakottishfold Sep 4, 2023
f84b79e
Merge branch 'next' into fix-docs-path-to-pathname
sakottishfold Sep 4, 2023
1903fc6
Remove parasite "console.log" sourceDecorator.ts
oruman Sep 4, 2023
24b837c
add more context to explanation in core-events errors
yannbf Sep 4, 2023
c17d887
Merge pull request #24028 from storybookjs/yann/sanitize-errors-more
yannbf Sep 4, 2023
421eb2b
Merge branch 'bugfix/nextjs-image-context' of github.com:martinnabhan…
ndelangen Sep 4, 2023
81f61a0
Merge pull request #24033 from storybookjs/fix-angular-prerelease-san…
yannbf Sep 4, 2023
a93bc31
Merge branch 'next' into yann/webpack-builder-error
yannbf Sep 4, 2023
6947671
fix types and ignore linting problem
ndelangen Sep 4, 2023
ba9bd06
Merge branch 'next' into pr/martinnabhan/23881
ndelangen Sep 4, 2023
a0ade70
Merge branch 'next' into pr/martinnabhan/23881
ndelangen Sep 4, 2023
d273746
Merge branch 'next' into patch-1
kasperpeulen Sep 4, 2023
a4973a4
cleanup tests
yannbf Sep 1, 2023
183ad26
fix types via a bit convoluted work-around
ndelangen Sep 4, 2023
43f4345
Merge pull request #24031 from storybookjs/yann/webpack-builder-error
ndelangen Sep 4, 2023
1d93663
Merge pull request #24063 from storybookjs/yann/more-context-on-core-…
yannbf Sep 4, 2023
4d728c3
Merge pull request #23881 from martinnabhan/bugfix/nextjs-image-context
ndelangen Sep 4, 2023
1219a42
Replace volta node version config
johnhunter Aug 29, 2023
e4e0836
Update docs with fnm instructions
johnhunter Aug 29, 2023
2abcd06
Use .nvmrc file for node version
johnhunter Aug 30, 2023
9403f3c
Use .nvmrc file for node version
johnhunter Aug 30, 2023
f534bc6
Minor docs changes
johnhunter Aug 30, 2023
3648a0e
categorize angular legacy build options error
yannbf Aug 30, 2023
248a6c5
fix(traverse-helpers): validate property key
egorprnn Sep 4, 2023
129335f
Merge branch 'next' into 23463-search-input-label-for
ndelangen Sep 4, 2023
f48ad32
Merge pull request #24015 from johnhunter/node-version-nvmrc
yannbf Sep 4, 2023
a024424
Merge pull request #24062 from oruman/patch-1
yannbf Sep 4, 2023
5a27579
Merge branch 'next' into 23463-search-input-label-for
yannbf Sep 4, 2023
95bdc7e
small refactor
yannbf Sep 4, 2023
da19621
Merge pull request #24061 from masaya48/fix-docs-path-to-pathname
yannbf Sep 4, 2023
911aee2
Adds action video to the documentation
jonniebigodes Sep 4, 2023
527dfd1
Merge branch 'next' into patch-1
jonniebigodes Sep 4, 2023
1598f56
Merge pull request #24053 from omahs/patch-1
jonniebigodes Sep 4, 2023
4b0b3ac
Merge branch 'next' into docs/get-started-init-yarn
jonniebigodes Sep 4, 2023
8d0257a
Merge pull request #22822 from eliot05/docs/get-started-init-yarn
jonniebigodes Sep 4, 2023
3bab816
Merge pull request #24068 from MrZillaGold/patch-4
shilman Sep 5, 2023
f3463e7
Merge branch 'next' into 23463-search-input-label-for
yannbf Sep 5, 2023
02dcda1
Merge branch 'next' into yann/angular-browsertarget-error
yannbf Sep 5, 2023
a767c8b
Merge pull request #23753 from storybookjs/yann/add-chromatic-addon
yannbf Sep 5, 2023
93e8935
Merge branch 'next' into yann/angular-browsertarget-error
ndelangen Sep 5, 2023
7728d23
Update yarn.lock file
kasperpeulen Sep 5, 2023
babb96b
Merge branch 'next' into yann/angular-browsertarget-error
yannbf Sep 5, 2023
2ef76cf
Merge branch 'next' into 23463-search-input-label-for
yannbf Sep 5, 2023
7c7f86e
Use type from packageManager class
Sep 5, 2023
0a4c504
Use npx if user has yarn1
Sep 5, 2023
c8623d9
add angular.json path in error message
yannbf Sep 5, 2023
0a81127
Merge pull request #24014 from storybookjs/yann/angular-browsertarget…
yannbf Sep 5, 2023
089c182
Merge branch 'next' into 23463-search-input-label-for
yannbf Sep 5, 2023
f345826
Merge branch 'next' into cli/fix-add-command
Sep 5, 2023
fccc51f
Merge pull request #23464 from plumpNation/23463-search-input-label-for
yannbf Sep 5, 2023
c3997d4
add platform info to telemetry event
yannbf Sep 5, 2023
f1ba7fe
fix error processing and add browser info
yannbf Sep 5, 2023
0cb9932
Merge pull request #24079 from storybookjs/cli/fix-add-command
Sep 5, 2023
e0d4456
add browser info to preview runtime error
yannbf Sep 5, 2023
6f6c2be
Merge branch 'next' into docs_adds_actions_video
jonniebigodes Sep 5, 2023
8580060
Merge pull request #24072 from storybookjs/docs_adds_actions_video
jonniebigodes Sep 5, 2023
d627022
Merge pull request #24020 from j3rem1e/bug/24019
kasperpeulen Sep 6, 2023
e894dfd
cleanup
yannbf Sep 6, 2023
0bdbff7
Strip color and inform the user how to dedupe
kasperpeulen Sep 6, 2023
6153840
Update snapshots
kasperpeulen Sep 6, 2023
363c268
optmize getting browserinfo
yannbf Sep 6, 2023
3de1219
refactor preprocessError function
yannbf Sep 6, 2023
a1fd317
Merge branch 'next' into yann/improve-telemetry-metadata
yannbf Sep 6, 2023
d98ff76
Update snapshots
kasperpeulen Sep 6, 2023
08e371c
Merge pull request #24087 from storybookjs/kasper/fix-ci
kasperpeulen Sep 7, 2023
d2fc6de
Merge pull request #24081 from storybookjs/yann/improve-telemetry-met…
yannbf Sep 7, 2023
e822f29
Revert "Sandboxes: Use Node 18 to generate Angular prerelease sandboxes"
kasperpeulen Sep 7, 2023
c3e267e
Mark angular-cli/prerelease as inDevelopment
kasperpeulen Sep 7, 2023
84156b0
Fix parallelism
kasperpeulen Sep 7, 2023
32e8c0b
Merge pull request #24100 from storybookjs/revert-24033-fix-angular-p…
yannbf Sep 7, 2023
faeabfa
fix svelte-vite detection for NPM workspaces
legnaleurc Sep 7, 2023
d8c5bba
Merge pull request #24085 from legnaleurc/fix/monorepo
JReinhold Sep 8, 2023
db93b38
Minor fix to the WC TS snippets
jonniebigodes Sep 8, 2023
ea56889
Merge pull request #24113 from storybookjs/chore_fix_wc_snippets
jonniebigodes Sep 8, 2023
7d7ab4d
Write changelog for 7.5.0-alpha.2
storybook-bot Sep 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -609,30 +609,30 @@ workflows:
requires:
- build
- create-sandboxes:
parallelism: 35
parallelism: 34
requires:
- build
# - smoke-test-sandboxes: # disabled for now
# requires:
# - create-sandboxes
- build-sandboxes:
parallelism: 35
parallelism: 34
requires:
- create-sandboxes
- chromatic-sandboxes:
parallelism: 32
parallelism: 31
requires:
- build-sandboxes
- e2e-production:
parallelism: 32
parallelism: 31
requires:
- build-sandboxes
- e2e-dev:
parallelism: 4
requires:
- create-sandboxes
- test-runner-production:
parallelism: 32
parallelism: 31
requires:
- build-sandboxes
# TODO: reenable once we find out the source of flakyness
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/canary-release-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

node-version-file: '.nvmrc'
- name: Cache dependencies
uses: actions/cache@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/danger-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
name: Danger JS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
- uses: actions/checkout@v3
node-version-file: '.nvmrc'
- name: Danger JS
uses: danger/danger-js@11.2.6
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-patch-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
node-version-file: '.nvmrc'

- name: Cache dependencies
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
node-version-file: '.nvmrc'

- name: Cache dependencies
uses: actions/cache@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
node-version-file: '.nvmrc'

- name: Cache dependencies
uses: actions/cache@v3
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ coverage/
/**/LICENSE
code/docs/public
package-lock.json
.nvmrc
storybook-static
.jest-test-results.json
*.jar
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.20
16 changes: 16 additions & 0 deletions CHANGELOG.prerelease.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 7.5.0-alpha.2

- Angular: Categorize legacy build options error - [#24014](https://github.com/storybookjs/storybook/pull/24014), thanks [@yannbf](https://github.com/yannbf)!
- Builder-Webpack5: Categorize builder error - [#24031](https://github.com/storybookjs/storybook/pull/24031), thanks [@yannbf](https://github.com/yannbf)!
- CI: Inform the user how to dedupe and strip color from info command - [#24087](https://github.com/storybookjs/storybook/pull/24087), thanks [@kasperpeulen](https://github.com/kasperpeulen)!
- CLI: Fix packageManager handling in `sb add` - [#24079](https://github.com/storybookjs/storybook/pull/24079), thanks [@Integrayshaun](https://github.com/Integrayshaun)!
- CLI: Improve sanitization logic in crash reports - [#24028](https://github.com/storybookjs/storybook/pull/24028), thanks [@yannbf](https://github.com/yannbf)!
- Maintenance: Add more context to explanation in core-events errors - [#24063](https://github.com/storybookjs/storybook/pull/24063), thanks [@yannbf](https://github.com/yannbf)!
- Monorepo: Fix `svelte-vite` detection - [#24085](https://github.com/storybookjs/storybook/pull/24085), thanks [@legnaleurc](https://github.com/legnaleurc)!
- NextJS: Fix Image Context reuse (ensure singleton by externalizing it) - [#23881](https://github.com/storybookjs/storybook/pull/23881), thanks [@martinnabhan](https://github.com/martinnabhan)!
- Source-loader: Fix property key validation - [#24068](https://github.com/storybookjs/storybook/pull/24068), thanks [@MrZillaGold](https://github.com/MrZillaGold)!
- Svelte: Fix generated properties on Svelte event handler - [#24020](https://github.com/storybookjs/storybook/pull/24020), thanks [@j3rem1e](https://github.com/j3rem1e)!
- Telemetry: Add platform info to telemetry event - [#24081](https://github.com/storybookjs/storybook/pull/24081), thanks [@yannbf](https://github.com/yannbf)!
- UI: Fix target id in searchfield label - [#23464](https://github.com/storybookjs/storybook/pull/23464), thanks [@plumpNation](https://github.com/plumpNation)!
- Vue3: Remove console.log in sourceDecorator - [#24062](https://github.com/storybookjs/storybook/pull/24062), thanks [@oruman](https://github.com/oruman)!

## 7.5.0-alpha.1

- Core: Add CJS entrypoints to errors in core events - [#24038](https://github.com/storybookjs/storybook/pull/24038), thanks [@yannbf](https://github.com/yannbf)!
Expand Down
15 changes: 13 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# Getting started

Storybook is developed against a specific node version. We recommend using [Volta](https://volta.sh/) as it will automatically install the correct node and yarn version when you first use the repo. If you chose not to use Volta please ensure you you have node version 16 installed (suggestion: v16.5)
Storybook is developed against a specific node version which is defined in an `.nvmrc` file. You can use any Node version manager that uses the `.nvmrc` configuration file (we recommend [fnm](https://fnm.vercel.app/)).

## Using fnm as a Node version manager

- Install fnm [as per instructions](https://github.com/Schniz/fnm/tree/master#installation)
- In your shell setup include the `use-on-cd`, `corepack-enabled` and `version-file-strategy recursive` parameters in the `fnm env` command, e.g.

```sh
eval "$(fnm env --use-on-cd --corepack-enabled --version-file-strategy recursive)"
```

## Running the local development environment

- Ensure if you are using Windows to use the Windows Subsystem for Linux (WSL).
- Run `yarn start` in the root directory to run a basic test Storybook "sandbox".

The `yarn start` script will generate a React Vite TypeScript sandbox with a set of test stories inside it, as well as taking all steps required to get it running (building the various packages we need etc). There is no need to run `yarn` or `yarn install` as `yarn start` will do this for you.

## Issues
### Issues

If you run `yarn start` and encounter the following error, try rerunning `yarn start` a second time:

Expand Down
6 changes: 5 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,11 @@ Starting in 7.0, we drop support for Angular < 14

#### Angular: Drop support for calling Storybook directly

In Storybook 6.4 we have deprecated calling Storybook directly (`npm run storybook`) for Angular. In Storybook 7.0, we've removed it entirely. Instead you have to set up the Storybook builder in your `angular.json` and execute `ng run <your-project>:storybook` to start Storybook. Please visit https://github.com/storybookjs/storybook/tree/next/code/frameworks/angular to set up Storybook for Angular correctly.
_Has automigration_

In Storybook 6.4 we deprecated calling Storybook directly (e.g. `npm run storybook`) for Angular. In Storybook 7.0, we've removed it entirely. Instead, you have to set up the Storybook builder in your `angular.json` and execute `ng run <your-project>:storybook` to start Storybook.

You can run `npx storybook@next automigrate` to automatically fix your configuration, or visit https://github.com/storybookjs/storybook/tree/next/code/frameworks/angular/README.md#how-do-i-migrate-to-an-angular-storybook-builder for instructions on how to set up Storybook for Angular manually.

#### Angular: Application providers and ModuleWithProviders

Expand Down
2 changes: 1 addition & 1 deletion code/addons/themes/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { spawn } = require('child_process');

const PACKAGE_MANAGER_TO_COMMAND = {
npm: 'npx',
yarn1: 'yarn dlx',
yarn1: 'npx',
yarn2: 'yarn dlx',
pnpm: 'pnpm dlx',
};
Expand Down
131 changes: 65 additions & 66 deletions code/builders/builder-webpack5/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import { dirname, join, parse } from 'path';
import express from 'express';
import fs from 'fs-extra';
import { PREVIEW_BUILDER_PROGRESS } from '@storybook/core-events';
import {
WebpackCompilationError,
WebpackInvocationError,
WebpackMissingStatsError,
} from '@storybook/core-events/server-errors';

import prettyTime from 'pretty-hrtime';

Expand Down Expand Up @@ -117,21 +122,19 @@ const starter: StarterFunction = async function* starterGeneratorFn({
yield;

const config = await getConfig(options);

if (config.stats === 'none' || config.stats === 'summary') {
throw new WebpackMissingStatsError();
}
yield;

const compiler = webpackInstance(config);

if (!compiler) {
const err = `${config.name}: missing webpack compiler at runtime!`;
logger.error(err);
return {
bail,
totalTime: process.hrtime(startTime),
stats: {
hasErrors: () => true,
hasWarnings: () => false,
toJson: () => ({ warnings: [] as any[], errors: [err] }),
} as any as Stats,
};
throw new WebpackInvocationError({
// eslint-disable-next-line local-rules/no-uncategorized-errors
error: new Error(`Missing Webpack compiler at runtime!`),
});
}

yield;
Expand Down Expand Up @@ -172,6 +175,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({
const middlewareOptions: Parameters<typeof webpackDevMiddleware>[1] = {
publicPath: config.output?.publicPath as string,
writeToDisk: true,
stats: 'errors-only',
};

compilation = webpackDevMiddleware(compiler, middlewareOptions);
Expand All @@ -184,19 +188,24 @@ const starter: StarterFunction = async function* starterGeneratorFn({
router.use(compilation);
router.use(webpackHotMiddleware(compiler, { log: false }));

const stats = await new Promise<Stats>((ready, stop) => {
compilation?.waitUntilValid(ready as any);
reject = stop;
const stats = await new Promise<Stats>((res, rej) => {
compilation?.waitUntilValid(res as any);
reject = rej;
});
yield;

if (!stats) {
throw new Error('no stats after building preview');
throw new WebpackMissingStatsError();
}

if (stats.hasErrors()) {
// eslint-disable-next-line @typescript-eslint/no-throw-literal
throw stats;
const { warnings, errors } = getWebpackStats({ config, stats });

if (warnings.length > 0) {
warnings?.forEach((e) => logger.error(e.message));
}

if (errors.length > 0) {
throw new WebpackCompilationError({ errors });
}

return {
Expand All @@ -206,6 +215,22 @@ const starter: StarterFunction = async function* starterGeneratorFn({
};
};

function getWebpackStats({ config, stats }: { config: Configuration; stats: Stats }) {
const statsOptions =
typeof config.stats === 'string'
? config.stats
: {
...(config.stats as StatsOptions),
warnings: true,
errors: true,
};
const { warnings = [], errors = [] } = stats?.toJson(statsOptions) || {};
return {
warnings,
errors,
};
}

/**
* This function is a generator so that we can abort it mid process
* in case of failure coming from other processes e.g. manager builder
Expand All @@ -215,73 +240,47 @@ const starter: StarterFunction = async function* starterGeneratorFn({
const builder: BuilderFunction = async function* builderGeneratorFn({ startTime, options }) {
const webpackInstance = await executor.get(options);
yield;
logger.info('=> Compiling preview..');
const config = await getConfig(options);

if (config.stats === 'none' || config.stats === 'summary') {
throw new WebpackMissingStatsError();
}
yield;

const compiler = webpackInstance(config);

if (!compiler) {
const err = `${config.name}: missing webpack compiler at runtime!`;
logger.error(err);
return {
hasErrors: () => true,
hasWarnings: () => false,
toJson: () => ({ warnings: [] as any[], errors: [err] }),
} as any as Stats;
throw new WebpackInvocationError({
// eslint-disable-next-line local-rules/no-uncategorized-errors
error: new Error(`Missing Webpack compiler at runtime!`),
});
}

const webpackCompilation = new Promise<Stats>((succeed, fail) => {
compiler.run((error, stats) => {
if (error || !stats || stats.hasErrors()) {
logger.error('=> Failed to build the preview');
process.exitCode = 1;

if (error) {
logger.error(error.message);
if (error) {
compiler.close(() => fail(new WebpackInvocationError({ error })));
return;
}

compiler.close(() => fail(error));
if (!stats) {
throw new WebpackMissingStatsError();
}

return;
}
const { warnings, errors } = getWebpackStats({ config, stats });

if (stats && (stats.hasErrors() || stats.hasWarnings())) {
const { warnings = [], errors = [] } = stats.toJson(
typeof config.stats === 'string'
? config.stats
: {
warnings: true,
errors: true,
...(config.stats as StatsOptions),
}
);

errors.forEach((e) => logger.error(e.message));
warnings.forEach((e) => logger.error(e.message));

compiler.close(() =>
options.debugWebpack
? fail(stats)
: fail(new Error('=> Webpack failed, learn more with --debug-webpack'))
);

return;
}
if (warnings.length > 0) {
warnings?.forEach((e) => logger.error(e.message));
}

logger.trace({ message: '=> Preview built', time: process.hrtime(startTime) });
if (stats && stats.hasWarnings()) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- we know it has warnings because of hasWarnings()
stats
.toJson({ warnings: true } as StatsOptions)
.warnings!.forEach((e) => logger.warn(e.message));
if (errors.length > 0) {
compiler.close(() => fail(new WebpackCompilationError({ errors })));
return;
}

// https://webpack.js.org/api/node/#run
// #15227
compiler.close((closeErr) => {
if (closeErr) {
return fail(closeErr);
return fail(new WebpackInvocationError({ error: closeErr }));
}

return succeed(stats as Stats);
Expand Down
6 changes: 4 additions & 2 deletions code/frameworks/angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- [moduleMetadata decorator](#modulemetadata-decorator)
- [applicationConfig decorator](#applicationconfig-decorator)
- [FAQ](#faq)
- [How do I migrate to a Angular Storybook builder?](#how-do-i-migrate-to-a-angular-storybook-builder)
- [How do I migrate to an Angular Storybook builder?](#how-do-i-migrate-to-an-angular-storybook-builder)
- [Do you have only one Angular project in your workspace?](#do-you-have-only-one-angular-project-in-your-workspace)
- [Adjust your `package.json`](#adjust-your-packagejson)
- [I have multiple projects in my Angular workspace](#i-have-multiple-projects-in-my-angular-workspace)
Expand Down Expand Up @@ -252,10 +252,12 @@ export const WithCustomApplicationProvider: Story = {

## FAQ

### How do I migrate to a Angular Storybook builder?
### How do I migrate to an Angular Storybook builder?

The Storybook [Angular builder](https://angular.io/guide/glossary#builder) is a new way to run Storybook in an Angular workspace. It is a drop-in replacement for running `storybook dev` and `storybook build` directly.

You can run `npx storybook@next automigrate` to try let Storybook detect and automatically fix your configuration. Otherwise, you can follow the next steps to manually adjust your configuration.

#### Do you have only one Angular project in your workspace?

In this case go to your `angular.json` and add `storybook` and `build-storybook` entries in `architect` section of your project like shown above.
Expand Down
Loading