storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.79k stars 9.33k forks source link

[Bug]: Angular i18n Incompatibility #23085

Open USSDlover opened 1 year ago

USSDlover commented 1 year ago

Describe the bug

After adding i18n we will update the angular.json by introducing the required locales, and by that the command ng run angular-app:storybook will failed with this error

info => Using default Webpack5 setup
<i> [webpack-dev-middleware] wait until bundle finished
9% setup compilation build-angulard:\Projects\node_modules\webpack\lib\javascript\JavascriptModulesPlugin.js:151
                        throw new TypeError(
                              ^

TypeError: The 'compilation' argument must be an instance of Compilation

To Reproduce

  1. Create new Angular project with ng new my-app
  2. Install Angular Localization by ng add @angular/localize
  3. Head over to angular.json and add the required locales to build configuration.
{
  "projects": {
    "my-app": {
      "i18n": {
        "locales": {
          "ar": "src/locale/messages.ar.xlf"
        },
        "sourceLocale": "en"
      },
      "architect": {
        "build": {
          "configurations": {
            "production": {
              "localize": true
            },
            "development": {
              "localize": [
                "en"
              ]
            }
          },
          "defaultConfiguration": "production"
        }
      }
    }
  }
}
  1. Add storybook with npx storybook@latest init
  2. Run the storybook with npm run storybook

System

Environment Info:

  System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 9.6.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (114.0.1823.43)
  npmPackages:
    @storybook/addon-essentials: 7.0.21 => 7.0.21
    @storybook/addon-interactions: 7.0.21 => 7.0.21
    @storybook/addon-links: 7.0.21 => 7.0.21
    @storybook/angular: 7.0.21 => 7.0.21
    @storybook/blocks: 7.0.21 => 7.0.21
    @storybook/testing-library: 0.0.14-next.2 => 0.0.14-next.2

Additional context

SEQUOiA87 commented 4 months ago

We got the same issue here. Any hints on how to fix/workaround it without creating a dummy build configuration just for storybook (which I guess is what @USSDlover meant with "Quick fix was to introduce another build configuration for storybook with localize: false.")?

Thanks in advance!