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

Webpack: Make manager and preview build processes cancelable #17809

Merged
merged 13 commits into from
Apr 6, 2022

Conversation

yannbf
Copy link
Member

@yannbf yannbf commented Mar 28, 2022

Issue: N/A

What I did

Transformed the build and start steps, for both manager and preview, for both webpack4 and webpack5, so that they are all generators. This allows us to e.g. cancel the execution of preview when manager fail and vice versa.
The reason we need this is because the processes happen in parallel, so we need a generator in order to get some control over their executions.

There are lots of duplication between the builders, they certainly can be improved.

co-authored by @ndelangen

How to test

repro.mp4

Sample code from video:

// lib/core-server/build-static.ts | lib/core-server/build-dev.ts
await prompts({
      type: 'confirm',
      name: 'test',
      message: `Do you want to answer?`,
});
// examples/react-ts/main.ts

const throwError = async () => {
  throw new Error('bla');
};

const previewWebpack = true;

if (!previewWebpack) {
  config.webpackFinal = throwError;
} else {
  // @ts-ignore
  config.managerWebpack = throwError;
}
  • Is this testable with Jest or Chromatic screenshots?
  • Does this need a new example in the kitchen sink apps?
  • Does this need an update to the documentation?

If your answer is yes to any of these, please make sure to include it in your PR.

@yannbf yannbf added the maintenance User-facing maintenance tasks label Mar 28, 2022
@nx-cloud
Copy link

nx-cloud bot commented Mar 28, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 1da2437. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 1 target

Sent with 💌 from NxCloud.

@yannbf
Copy link
Member Author

yannbf commented Mar 28, 2022

@ndelangen any ideas about the Typescript issues? weird that they don't happen locally while editing or building (but they do when running yarn nx run @storybook/builder-webpack4:prepare --optimized)

@ndelangen
Copy link
Member

I think I resolved the typescript issues... I also changed the return type of the builders in case an error occurs. I think in-line with #15885

@shilman shilman changed the title feat: make manager and preview build processes cancelable Webpack: Make manager and preview build processes cancelable Mar 31, 2022
@ndelangen ndelangen requested a review from shilman April 5, 2022 08:47
@ndelangen ndelangen merged commit 32419be into next Apr 6, 2022
@ndelangen ndelangen deleted the feat/cancelable-builder-process branch April 6, 2022 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants