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

Angular always devMode enabled when using build-storybook #16211

Closed
literalpie opened this issue Oct 1, 2021 · 3 comments
Closed

Angular always devMode enabled when using build-storybook #16211

literalpie opened this issue Oct 1, 2021 · 3 comments

Comments

@literalpie
Copy link
Contributor

literalpie commented Oct 1, 2021

Describe the bug
When using the angular.json @storybook/angular/build-storybook builder, prod mode is not used like I would expect.

To Reproduce
This Repo

  • Building with npm run build-storybook works as expected, prod mode is not used in Angular stories. (tested with npx serve ./storybook-static)
  • Wuilding with npm run build-storybook-builder runs Angular stories in dev mode (notice that it is logged in the console when stories are first loaded )

System
Environment Info:

System:
OS: macOS 11.6
CPU: (12) x64 Intel(R) Xeon(R) CPU E5-1650 v2 @ 3.50GHz
Binaries:
Node: 16.6.1 - ~/.nvm/versions/node/v16.6.1/bin/node
Yarn: 3.0.1 - /usr/local/bin/yarn
npm: 7.20.3 - ~/.nvm/versions/node/v16.6.1/bin/npm
Browsers:
Chrome: 94.0.4606.61
Firefox: 92.0.1
Safari: 15.0
npmPackages:
@storybook/addon-actions: ^6.4.0-beta.3 => 6.4.0-beta.3
@storybook/addon-docs: ^6.4.0-beta.3 => 6.4.0-beta.3
@storybook/addon-essentials: ^6.4.0-beta.3 => 6.4.0-beta.3
@storybook/addon-links: ^6.4.0-beta.3 => 6.4.0-beta.3
@storybook/angular: ^6.4.0-beta.3 => 6.4.0-beta.3
@storybook/builder-webpack5: ^6.4.0-beta.3 => 6.4.0-beta.3
@storybook/manager-webpack5: ^6.4.0-beta.3 => 6.4.0-beta.3

Additional context
When running build-storybook from the sb command line, this error is output:

Error: Cannot enable prod mode after platform setup.

Which makes me question if it is intentional to enable prod mode when building the static storybook, or a "happy accident".

Angular Dev mode causes change detection to be run twice every time it would normally be run once. There are other things that are enabled that make dev mode slower/larger.

I see this issue in 6.3.x also

@rbrinson-extron
Copy link

I'm not certain if the issue that I am experiencing is related. However, I get the
Error: Cannot enable prod mode after platform setup.
message in the developer tools console in Firefox and Safari but NOT in Chrome or Edge. This is happening after upgrading to Angular 12 and Storybook 6.3.

The project is an Angular library built for production on AWS CodeBuild. When the library was on Angular 11.2.14 and Storybook 6.1.21, we did not receive any such errors in any browser. After upgrading to Angular 12.2.11 and Storybook 6.3.12, we noticed that Firefox and Safari would generate the above error in the browser console once for each page visited. Subsequent visits would not generate the error.

Is this a known issue? Is there something that I can do to correct the issue in either the Angular project or the Storybook configuration?

Affected Browsers:
Firefox v94.0.1
Safari v15.1

Build Environment:
Ubuntu 18.04
Nodejs v12.22.2
npm 6.14.13

Snippet of Dev Dependencies:

    "@angular-devkit/build-angular": "~12.2.11",
    "@angular-devkit/core": "~12.2.11",
    "@angular/cli": "~12.2.11",
    "@angular/compiler-cli": "~12.2.11",
    "@angular/language-service": "~12.2.11",
    "@babel/core": "~7.15.8",
    "@extron/build-tools": "~1.0.1-beta.32",
    "@extron/versioning": "~2.1.0",
    "@invisionapp/dsm-storybook": "~0.0.147",
    "@storybook/addon-essentials": "~6.3.12",
    "@storybook/addon-knobs": "~6.3.1",
    "@storybook/addon-options": "~5.3.21",
    "@storybook/addons": "~6.3.12",
    "@storybook/angular": "~6.3.12",
    "@storybook/builder-webpack5": "~6.3.12",
    "@storybook/manager-webpack5": "~6.3.12",
    "@storybook/preset-scss": "~1.0.3",

@sherlock1982
Copy link

Looks like storybook runs in devMode. But you can also enable prod mode in preview.js:

import { enableProdMode } from '@angular/core';

enableProdMode();

I'm using Angular14 + Storybook 6.5.10

@shilman
Copy link
Member

shilman commented Jun 9, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:

@shilman shilman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants