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

Storybook for Angular fails with default/initial library config (Zero-config setup) #16110

Closed
snebjorn opened this issue Sep 20, 2021 · 20 comments

Comments

@snebjorn
Copy link

Describe the bug

Storybook for Angular fails to build with default (initial) library configuration. It'll complain about a missing tsConfig setting. But the tsConfig is present - just not in the expected place.

info => Using angular project "my-lib:build" for configuring Storybook
ERR! => Could not get angular cli webpack config
ERR! Error: Missing required options in project target. Check "tsConfig"

This is the default (created by angular cli) library config (angular.json)

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "my-lib": {
      "projectType": "library",
      "root": "projects/my-lib",
      "sourceRoot": "projects/my-lib/src",
      "prefix": "lib",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:ng-packagr",
          "options": {
            "project": "projects/my-lib/ng-package.json"
            // <-------------------------------------------------- Storybook complains there is no tsConfig here
          },
          "configurations": {
            "production": {
              "tsConfig": "projects/my-lib/tsconfig.lib.prod.json" // <-- but it's here
            },
            "development": {
              "tsConfig": "projects/my-lib/tsconfig.lib.json" // <------- and here
            }
          },
          "defaultConfiguration": "production"
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "projects/my-lib/src/test.ts",
            "tsConfig": "projects/my-lib/tsconfig.spec.json",
            "karmaConfig": "projects/my-lib/karma.conf.js"
          }
        }
      }
    }
  },
  "defaultProject": "my-lib"
}

To Reproduce
Repo: https://github.com/snebjorn/ng12-lib

Steps to reproduce:

  1. ng new ng12-lib --create-application=false
  2. cd .\ng12-lib\
  3. ng generate library my-lib
  4. npx sb@next init
  5. npm run storybook
  6. Observe error: Error: Missing required options in project target. Check "tsConfig"

System

Environment Info:

  System:
    OS: Windows 10 10.0.19041
    CPU: (4) x64 Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
  Binaries:
    Node: 14.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 7.24.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 93.0.4577.82
    Edge: Spartan (44.19041.1023.0), Chromium (93.0.961.52)
  npmPackages:
    @storybook/addon-actions: ^6.4.0-alpha.39 => 6.4.0-alpha.39
    @storybook/addon-essentials: ^6.4.0-alpha.39 => 6.4.0-alpha.39
    @storybook/addon-links: ^6.4.0-alpha.39 => 6.4.0-alpha.39
    @storybook/angular: ^6.4.0-alpha.39 => 6.4.0-alpha.39
    @storybook/builder-webpack5: ^6.4.0-alpha.39 => 6.4.0-alpha.39
    @storybook/manager-webpack5: ^6.4.0-alpha.39 => 6.4.0-alpha.39

Other concerns
When installing NPM threw these warnings.

npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.

Would probably be a good idea to get these updated :)

@snebjorn
Copy link
Author

After adding the tsConfig propety to the options

"architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:ng-packagr",
      "options": {
        "project": "projects/my-lib/ng-package.json",
        "tsConfig": "projects/my-lib/tsconfig.lib.prod.json" // <--- added
      },

and running npm run storybook I get the following errors.

I was expecting a working but empty storybook page.

<ref *1> {
  message: '\x1B[90m[tsl] \x1B[39m\x1B[1m\x1B[31mERROR\x1B[39m\x1B[22m\r\n' +
    "\x1B[1m\x1B[31m      TS6053: File '../false' not found.\x1B[39m\x1B[22m",
  file: '~\\ng12-lib\\.storybook\\tsconfig.json',
  loc: undefined,
  location: undefined,
  loaderSource: 'ts-loader-default_b3a4201cf1c03fdc',
  module: NormalModule {
    dependencies: [],
    blocks: [],
    type: 'javascript/auto',
    context: '~\\ng12-lib\\stories',
    layer: null,
    needId: true,
    debugId: 1263,
    resolveOptions: {},
    factoryMeta: undefined,
    useSourceMap: true,
    useSimpleSourceMap: false,
    _warnings: undefined,
    _errors: [
      [Circular *1],
      ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
      Error: error while parsing tsconfig.json
          at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:18)
          at processResult (~\ng12-lib\node_modules\webpack\lib\NormalModule.js:713:19)
          at ~\ng12-lib\node_modules\webpack\lib\NormalModule.js:819:5
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:399:11
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:251:18
          at context.callback (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
          at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:9)
          at LOADER_EXECUTION (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
          at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
          at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:143:11)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:140:6
    ],
    buildMeta: {},
    buildInfo: {
      cacheable: true,
      parsed: true,
      fileDependencies: [LazySet],
      contextDependencies: [LazySet],
      missingDependencies: [LazySet],
      buildDependencies: [LazySet],
      valueDependencies: undefined,
      hash: 'd6219df4dfdad3ce16b5fa1b13cfd160',
      assets: undefined,
      assetsInfo: undefined
    },
    presentationalDependencies: undefined,
    request: '~\\ng12-lib\\node_modules\\ts-loader\\index.js??ruleSet[1].rules[8].use[0]!~\\ng12-lib\\node_modules\\@storybook\\angular\\dist\\ts3.9\\server\\ngx-template-loader\\index.js!~\\ng12-lib\\node_modules\\@storybook\\source-loader\\dist\\cjs\\index.js??ruleSet[1].rules[14]!~\\ng12-lib\\stories\\Button.stories.ts',
    userRequest: '~\\ng12-lib\\stories\\Button.stories.ts',
    rawRequest: './Button.stories.ts',
    binary: false,
    parser: JavascriptParser {
      hooks: [Object],
      sourceType: 'auto',
      scope: undefined,
      state: undefined,
      comments: undefined,
      semicolons: undefined,
      statementPath: undefined,
      prevStatement: undefined,
      currentTagData: undefined
    },
    parserOptions: undefined,
    generator: JavascriptGenerator {},
    generatorOptions: undefined,
    resource: '~\\ng12-lib\\stories\\Button.stories.ts',
    resourceResolveData: {
      _ResolverCachePluginCacheMiss: true,
      context: [Object],
      path: '~\\ng12-lib\\stories\\Button.stories.ts',
      request: undefined,
      query: '',
      fragment: '',
      module: false,
      directory: false,
      file: false,
      internal: false,
      fullySpecified: false,
      descriptionFilePath: '~\\ng12-lib\\package.json',
      descriptionFileData: [Object],
      descriptionFileRoot: '~\\ng12-lib',
      relativePath: './stories/Button.stories.ts',
      __innerRequest_request: undefined,
      __innerRequest_relativePath: './stories/Button.stories.ts',
      __innerRequest: './stories/Button.stories.ts'
    },
    matchResource: undefined,
    loaders: [ [Object], [Object], [Object] ],
    error: ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
    Error: error while parsing tsconfig.json
        at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:18)
        at processResult (~\ng12-lib\node_modules\webpack\lib\NormalModule.js:713:19)
        at ~\ng12-lib\node_modules\webpack\lib\NormalModule.js:819:5
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:399:11
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:251:18
        at context.callback (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
        at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:9)
        at LOADER_EXECUTION (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
        at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
        at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:143:11)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:140:6,
    _source: null,
    _sourceSizes: Map(2) { 'javascript' => 39, undefined => 39 },
    _sourceTypes: Set(1) { 'javascript' },
    _lastSuccessfulBuildMeta: {},
    _forceBuild: false,
    _isEvaluatingSideEffects: false,
    _addedSideEffectsBailout: undefined,
    _ast: null
  }
}
ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
Error: error while parsing tsconfig.json
    at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:18)
    at processResult (~\ng12-lib\node_modules\webpack\lib\NormalModule.js:713:19)
    at ~\ng12-lib\node_modules\webpack\lib\NormalModule.js:819:5
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:399:11
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:251:18
    at context.callback (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
    at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:9)
    at LOADER_EXECUTION (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
    at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
    at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:143:11)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:140:6
<ref *1> {
  message: '\x1B[90m[tsl] \x1B[39m\x1B[1m\x1B[31mERROR\x1B[39m\x1B[22m\r\n' +
    "\x1B[1m\x1B[31m      TS6053: File '../false' not found.\x1B[39m\x1B[22m",
  file: '~\\ng12-lib\\.storybook\\tsconfig.json',
  loc: undefined,
  location: undefined,
  loaderSource: 'ts-loader-default_b3a4201cf1c03fdc',
  module: NormalModule {
    dependencies: [],
    blocks: [],
    type: 'javascript/auto',
    context: '~\\ng12-lib\\stories',
    layer: null,
    needId: true,
    debugId: 1264,
    resolveOptions: {},
    factoryMeta: undefined,
    useSourceMap: true,
    useSimpleSourceMap: false,
    _warnings: undefined,
    _errors: [
      [Circular *1],
      ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
      Error: error while parsing tsconfig.json
          at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:18)
          at processResult (~\ng12-lib\node_modules\webpack\lib\NormalModule.js:713:19)
          at ~\ng12-lib\node_modules\webpack\lib\NormalModule.js:819:5
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:399:11
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:251:18
          at context.callback (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
          at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:9)
          at LOADER_EXECUTION (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
          at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
          at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:143:11)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:140:6
    ],
    buildMeta: {},
    buildInfo: {
      cacheable: true,
      parsed: true,
      fileDependencies: [LazySet],
      contextDependencies: [LazySet],
      missingDependencies: [LazySet],
      buildDependencies: [LazySet],
      valueDependencies: undefined,
      hash: 'd6219df4dfdad3ce16b5fa1b13cfd160',
      assets: undefined,
      assetsInfo: undefined
    },
    presentationalDependencies: undefined,
    request: '~\\ng12-lib\\node_modules\\ts-loader\\index.js??ruleSet[1].rules[8].use[0]!~\\ng12-lib\\node_modules\\@storybook\\angular\\dist\\ts3.9\\server\\ngx-template-loader\\index.js!~\\ng12-lib\\node_modules\\@storybook\\source-loader\\dist\\cjs\\index.js??ruleSet[1].rules[14]!~\\ng12-lib\\stories\\Header.stories.ts',
    userRequest: '~\\ng12-lib\\stories\\Header.stories.ts',
    rawRequest: './Header.stories.ts',
    binary: false,
    parser: JavascriptParser {
      hooks: [Object],
      sourceType: 'auto',
      scope: undefined,
      state: undefined,
      comments: undefined,
      semicolons: undefined,
      statementPath: undefined,
      prevStatement: undefined,
      currentTagData: undefined
    },
    parserOptions: undefined,
    generator: JavascriptGenerator {},
    generatorOptions: undefined,
    resource: '~\\ng12-lib\\stories\\Header.stories.ts',
    resourceResolveData: {
      _ResolverCachePluginCacheMiss: true,
      context: [Object],
      path: '~\\ng12-lib\\stories\\Header.stories.ts',
      request: undefined,
      query: '',
      fragment: '',
      module: false,
      directory: false,
      file: false,
      internal: false,
      fullySpecified: false,
      descriptionFilePath: '~\\ng12-lib\\package.json',
      descriptionFileData: [Object],
      descriptionFileRoot: '~\\ng12-lib',
      relativePath: './stories/Header.stories.ts',
      __innerRequest_request: undefined,
      __innerRequest_relativePath: './stories/Header.stories.ts',
      __innerRequest: './stories/Header.stories.ts'
    },
    matchResource: undefined,
    loaders: [ [Object], [Object], [Object] ],
    error: ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
    Error: error while parsing tsconfig.json
        at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:18)
        at processResult (~\ng12-lib\node_modules\webpack\lib\NormalModule.js:713:19)
        at ~\ng12-lib\node_modules\webpack\lib\NormalModule.js:819:5
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:399:11
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:251:18
        at context.callback (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
        at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:9)
        at LOADER_EXECUTION (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
        at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
        at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:143:11)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:140:6,
    _source: null,
    _sourceSizes: Map(2) { 'javascript' => 39, undefined => 39 },
    _sourceTypes: Set(1) { 'javascript' },
    _lastSuccessfulBuildMeta: {},
    _forceBuild: false,
    _isEvaluatingSideEffects: false,
    _addedSideEffectsBailout: undefined,
    _ast: null
  }
}
ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
Error: error while parsing tsconfig.json
    at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:18)
    at processResult (~\ng12-lib\node_modules\webpack\lib\NormalModule.js:713:19)
    at ~\ng12-lib\node_modules\webpack\lib\NormalModule.js:819:5
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:399:11
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:251:18
    at context.callback (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
    at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:9)
    at LOADER_EXECUTION (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
    at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
    at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:143:11)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:140:6
<ref *1> {
  message: '\x1B[90m[tsl] \x1B[39m\x1B[1m\x1B[31mERROR\x1B[39m\x1B[22m\r\n' +
    "\x1B[1m\x1B[31m      TS6053: File '../false' not found.\x1B[39m\x1B[22m",
  file: '~\\ng12-lib\\.storybook\\tsconfig.json',
  loc: undefined,
  location: undefined,
  loaderSource: 'ts-loader-default_b3a4201cf1c03fdc',
  module: NormalModule {
    dependencies: [],
    blocks: [],
    type: 'javascript/auto',
    context: '~\\ng12-lib\\stories',
    layer: null,
    needId: true,
    debugId: 1265,
    resolveOptions: {},
    factoryMeta: undefined,
    useSourceMap: true,
    useSimpleSourceMap: false,
    _warnings: undefined,
    _errors: [
      [Circular *1],
      ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
      Error: error while parsing tsconfig.json
          at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:18)
          at processResult (~\ng12-lib\node_modules\webpack\lib\NormalModule.js:713:19)
          at ~\ng12-lib\node_modules\webpack\lib\NormalModule.js:819:5
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:399:11
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:251:18
          at context.callback (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
          at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:9)
          at LOADER_EXECUTION (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
          at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
          at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:143:11)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
          at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
          at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:140:6
    ],
    buildMeta: {},
    buildInfo: {
      cacheable: true,
      parsed: true,
      fileDependencies: [LazySet],
      contextDependencies: [LazySet],
      missingDependencies: [LazySet],
      buildDependencies: [LazySet],
      valueDependencies: undefined,
      hash: 'd6219df4dfdad3ce16b5fa1b13cfd160',
      assets: undefined,
      assetsInfo: undefined
    },
    presentationalDependencies: undefined,
    request: '~\\ng12-lib\\node_modules\\ts-loader\\index.js??ruleSet[1].rules[8].use[0]!~\\ng12-lib\\node_modules\\@storybook\\angular\\dist\\ts3.9\\server\\ngx-template-loader\\index.js!~\\ng12-lib\\node_modules\\@storybook\\source-loader\\dist\\cjs\\index.js??ruleSet[1].rules[14]!~\\ng12-lib\\stories\\Page.stories.ts',
    userRequest: '~\\ng12-lib\\stories\\Page.stories.ts',
    rawRequest: './Page.stories.ts',
    binary: false,
    parser: JavascriptParser {
      hooks: [Object],
      sourceType: 'auto',
      scope: undefined,
      state: undefined,
      comments: undefined,
      semicolons: undefined,
      statementPath: undefined,
      prevStatement: undefined,
      currentTagData: undefined
    },
    parserOptions: undefined,
    generator: JavascriptGenerator {},
    generatorOptions: undefined,
    resource: '~\\ng12-lib\\stories\\Page.stories.ts',
    resourceResolveData: {
      _ResolverCachePluginCacheMiss: true,
      context: [Object],
      path: '~\\ng12-lib\\stories\\Page.stories.ts',
      request: undefined,
      query: '',
      fragment: '',
      module: false,
      directory: false,
      file: false,
      internal: false,
      fullySpecified: false,
      descriptionFilePath: '~\\ng12-lib\\package.json',
      descriptionFileData: [Object],
      descriptionFileRoot: '~\\ng12-lib',
      relativePath: './stories/Page.stories.ts',
      __innerRequest_request: undefined,
      __innerRequest_relativePath: './stories/Page.stories.ts',
      __innerRequest: './stories/Page.stories.ts'
    },
    matchResource: undefined,
    loaders: [ [Object], [Object], [Object] ],
    error: ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
    Error: error while parsing tsconfig.json
        at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:18)
        at processResult (~\ng12-lib\node_modules\webpack\lib\NormalModule.js:713:19)
        at ~\ng12-lib\node_modules\webpack\lib\NormalModule.js:819:5
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:399:11
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:251:18
        at context.callback (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
        at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:9)
        at LOADER_EXECUTION (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
        at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
        at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:143:11)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
        at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
        at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:140:6,
    _source: null,
    _sourceSizes: Map(2) { 'javascript' => 39, undefined => 39 },
    _sourceTypes: Set(1) { 'javascript' },
    _lastSuccessfulBuildMeta: {},
    _forceBuild: false,
    _isEvaluatingSideEffects: false,
    _addedSideEffectsBailout: undefined,
    _ast: null
  }
}
ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
Error: error while parsing tsconfig.json
    at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:18)
    at processResult (~\ng12-lib\node_modules\webpack\lib\NormalModule.js:713:19)
    at ~\ng12-lib\node_modules\webpack\lib\NormalModule.js:819:5
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:399:11
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:251:18
    at context.callback (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:124:13)
    at Object.loader (~\ng12-lib\node_modules\ts-loader\dist\index.js:18:9)
    at LOADER_EXECUTION (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:132:14)
    at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:133:4)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
    at runSyncOrAsync (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:143:11)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:250:2)
    at iterateNormalLoaders (~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:239:10)
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:254:3
    at ~\ng12-lib\node_modules\loader-runner\lib\LoaderRunner.js:140:6
{
  rawMessage: "ERROR TS6053: File '../false' not found.",
  message: '\x1B[1m\x1B[31mERROR in \x1B[39m\x1B[22m\x1B[1m\x1B[36m~\\ng12-lib\\.storybook\\tsconfig.json(2,14)\x1B[39m\x1B[22m\x1B[1m\x1B[31m:\x1B[39m\x1B[22m\r\n' + 
    "\x1B[90mTS6053: \x1B[39mFile '../false' not found.",
  location: { line: 2, character: 14 },
  file: '~\\ng12-lib\\.storybook\\tsconfig.json'
}

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

@snebjorn
Copy link
Author

For some reason the generated storybook tsconfig had "extends": "../False",

When I changed that to

{
  "extends": "../tsconfig.json",
  // ...

it started to look manageable.

But seems you forgot about e2e tests. They too are generated by default.
Had to add "../projects/**/e2e/**/*"

{
  "exclude": [
    "../src/test.ts",
    "../src/**/*.spec.ts",
    "../projects/**/*.spec.ts",
    "../projects/**/e2e/**/*" // <--- added this
  ],

@snebjorn
Copy link
Author

snebjorn commented Sep 20, 2021

Storybook didn't automatically pickup on my stories. I needed to alter .storybook/main.js

module.exports = {
  stories: [
    '../stories/**/*.stories.mdx',
    '../stories/**/*.stories.@(js|jsx|ts|tsx)',
    // added the below
    '../projects/**/*.stories.mdx',
    '../projects/**/*.stories.@(js|jsx|ts|tsx)',
  ],

Ideally it would be as below. But in my default library project there is no src folder. Storybook will throw an error if it's listed in the config and the folder is missing.

module.exports = {
  stories: [
    '../stories/**/*.stories.mdx',
    '../stories/**/*.stories.@(js|jsx|ts|tsx)',
    '../src/**/*.stories.mdx',
    '../src/**/*.stories.@(js|jsx|ts|tsx)',
    '../projects/**/*.stories.mdx',
    '../projects/**/*.stories.@(js|jsx|ts|tsx)',
  ],

@ThibaudAV
Copy link
Contributor

Another workaround :

I don't know if this will help but I had the same need on my project

here's what I did:

I added a new project specifically for storybook and I use the native storybook builder.
In this project there is a stupid architect (style-injection) just for Sotrybook so with that it can use it internally with angular-cli to create webpack config

// angular.json
  "projects": {
...(i've only one other library with ng-pkgr)
    "storybook": {
      "projectType": "library",
      "root": "./",
      "architect": {
        "style-injection": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "tsConfig": ".storybook/tsconfig.json", // <- needed to have dedicated tsconfig for storybook  
            "styles": [".storybook/index.scss"], // <- to add global style like in real app 
            "outputPath": "noop",
            "index": "noop",
            "main": "noop"
          }
        },
        "start": {
          "builder": "@storybook/angular:start-storybook",
          "options": {
            "browserTarget": "storybook:style-injection",
            "compodoc": false,
            "port": 9008
          }
        },
        "build": {
          "builder": "@storybook/angular:build-storybook",
          "options": {
            "browserTarget": "storybook:style-injection",
            "compodoc": false
          }
        }
      }
    }
    ...

in my package.json script :

    "storybook": "ng run storybook:start",
    "storybook:build": "ng run storybook:build",

@chriscarpenter12
Copy link

@ThibaudAV Do you have an example repo where this is setup? What does the .storybook/tsconfig.json look like? I have an Angular only library repo we've had storybook 6.1.x working in it and getting this thing upgraded to Angular 12 + Storybook 6.4.x has not been straightforward to say the least..

@shilman
Copy link
Member

shilman commented Dec 10, 2021

https://github.com/storybookjs/storybook/blob/next/examples/angular-cli/angular.json

@chriscarpenter12 I've started to document the migration here. I'm not an Angular person, so any suggestions are welcome:

#16980

@chriscarpenter12
Copy link

I saw the new architect configs referenced in a few places, but how is that picked up by running/building storybook? Because your package.json storybook script isn't calling that architect? Shouldn't it be something like npx ng run angular-cli:storybook? Or is the start-storybook binary just looking for a well named storybook architect? Stuff like this it's just not inherently clear from outside this project.

Also what is this config?

@shilman
Copy link
Member

shilman commented Dec 10, 2021

@chriscarpenter12 Yes start-storybook is looking for storybook architect. perhaps @ThibaudAV can clarify and we also need to update the main documentation.

@ThibaudAV
Copy link
Contributor

you currently have 2 ways to start Storybook

  • the classic as before start-storybook
  • with the builder in angular.json with ng run angular-cli:storybook as angular serve, test, lint ext...
    They are both present in the angular-cli example project

if you have an angular workspace with only library I recommend you to use the builder

Do you have an example repo where this is setup?

here for ex:
https://github.com/gravitee-io/gravitee-ui-particles/blob/main/ui-particles-angular/.storybook/tsconfig.json

@stale
Copy link

stale bot commented Jan 9, 2022

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jan 9, 2022
@snebjorn
Copy link
Author

snebjorn commented Mar 25, 2023

Just checked with the latest versions.

Then when I run

ng run my-project:storybook

I get this error

Error: Could not find the '@storybook/angular:start-storybook' builder's node package.

Seems this is still an issue.

These are the packages from the package.json

  "dependencies": {
    "@angular/animations": "^15.2.0",
    "@angular/common": "^15.2.0",
    "@angular/compiler": "^15.2.0",
    "@angular/core": "^15.2.0",
    "@angular/forms": "^15.2.0",
    "@angular/platform-browser": "^15.2.0",
    "@angular/platform-browser-dynamic": "^15.2.0",
    "@angular/router": "^15.2.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.2.4",
    "@angular/cli": "~15.2.4",
    "@angular/compiler-cli": "^15.2.0",
    "@types/jasmine": "~4.3.0",
    "jasmine-core": "~4.5.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "~4.9.4"
  }

Seems to be missing at least @storybook/angular

@shilman
Copy link
Member

shilman commented Mar 28, 2023

@snebjorn Can you try using the 7.0 release (which is currently in RC):

npx sb@next init

I believe this is already fixed there.

@snebjorn
Copy link
Author

Just checked with the latest RC versions. (as of writing: [email protected])

  • ng new my-project
  • cd my-project
  • npx sb@next init

v7 docs doesn't say to alter angular.json so I didn't (https://storybook.js.org/docs/7.0/angular/get-started/install)

Running: ng run my-project:storybook
Gives this error

Project target does not exist.

Docs didn't say to create my-project:storybook in angular.json so the project target do indeed not exist.

Here's the packages from the package.json

  "dependencies": {
    "@angular/animations": "^15.2.0",
    "@angular/common": "^15.2.0",
    "@angular/compiler": "^15.2.0",
    "@angular/core": "^15.2.0",
    "@angular/forms": "^15.2.0",
    "@angular/platform-browser": "^15.2.0",
    "@angular/platform-browser-dynamic": "^15.2.0",
    "@angular/router": "^15.2.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.2.4",
    "@angular/cli": "~15.2.4",
    "@angular/compiler-cli": "^15.2.0",
    "@types/jasmine": "~4.3.0",
    "jasmine-core": "~4.5.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "~4.9.4"
  }

@valentinpalkovic
Copy link
Contributor

valentinpalkovic commented May 8, 2023

v7 docs doesn't say to alter angular.json so I didn't (https://storybook.js.org/docs/7.0/angular/get-started/install)

@snebjorn Right, because Storybook does this for you when you run npx storybook init. If you have already Storybook initialized, please follow the manual setup: https://github.com/storybookjs/storybook/tree/next/code/frameworks/angular#manual-setup

I cannot reproduce your issue with the following steps:

  • ng new my-project
  • cd my-project
  • npx sb@next init

The angular.json gets edited successfully. Which OS do you use?

@snebjorn
Copy link
Author

snebjorn commented May 8, 2023

I'm using Windows

Edition	Windows 11 Enterprise
Version	21H2
OS build	22000.1817
Experience	Windows Feature Experience Pack 1000.22000.1817.0

@valentinpalkovic
Copy link
Contributor

valentinpalkovic commented May 8, 2023

@snebjorn I am still unable to replicate your mentioned issue on a Windows machine. The angular.json file gets manipulated accordingly.

@snebjorn
Copy link
Author

snebjorn commented May 8, 2023

does npx sb@next init have a log some where?

~\my-stuff> ng new my-project
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS
CREATE my-project/angular.json (2720 bytes)
CREATE my-project/package.json (1041 bytes)
CREATE my-project/README.md (1063 bytes)
CREATE my-project/tsconfig.json (901 bytes)
CREATE my-project/.editorconfig (274 bytes)
CREATE my-project/.gitignore (548 bytes)
CREATE my-project/tsconfig.app.json (263 bytes)
CREATE my-project/tsconfig.spec.json (273 bytes)
CREATE my-project/.vscode/extensions.json (130 bytes)
CREATE my-project/.vscode/launch.json (470 bytes)
CREATE my-project/.vscode/tasks.json (938 bytes)
CREATE my-project/src/main.ts (214 bytes)
CREATE my-project/src/favicon.ico (1642 bytes)
CREATE my-project/src/index.html (295 bytes)
CREATE my-project/src/styles.css (80 bytes)
CREATE my-project/src/app/app.module.ts (314 bytes)
CREATE my-project/src/app/app.component.html (23083 bytes)
CREATE my-project/src/app/app.component.spec.ts (904 bytes)
CREATE my-project/src/app/app.component.ts (214 bytes)
CREATE my-project/src/app/app.component.css (0 bytes)
CREATE my-project/src/assets/.gitkeep (0 bytes)
✔ Packages installed successfully.
    Successfully initialized git.
~\my-stuff> cd .\my-project\
~\my-stuff\my-project [master]> ls

    Directory: ~\my-stuff\my-project

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----          08/05/2023    14:38                .vscode
d----          08/05/2023    14:41                node_modules
d----          08/05/2023    14:38                src
-a---          08/05/2023    14:38            274 .editorconfig
-a---          08/05/2023    14:38            548 .gitignore
-a---          08/05/2023    14:38           2720 angular.json
-a---          08/05/2023    14:41         441949 package-lock.json
-a---          08/05/2023    14:38           1041 package.json
-a---          08/05/2023    14:38           1063 README.md
-a---          08/05/2023    14:38            263 tsconfig.app.json
-a---          08/05/2023    14:38            901 tsconfig.json
-a---          08/05/2023    14:38            273 tsconfig.spec.json

~\my-stuff\my-project [master]> npx sb@next init
Need to install the following packages:
  [email protected]
Ok to proceed? (y)
~\my-stuff\my-project [master]> ng run my-project:storybook
Project target does not exist.
~\my-stuff\my-project [master]> ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 16.0.0
Node: 18.15.0
Package Manager: npm 9.5.0
OS: win32 x64

Angular: 16.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1600.0
@angular-devkit/build-angular   16.0.0
@angular-devkit/core            16.0.0
@angular-devkit/schematics      16.0.0
@schematics/angular             16.0.0
rxjs                            7.8.1
typescript                      5.0.4

@valentinpalkovic
Copy link
Contributor

It seems that even the sb init doesn't get executed! It should look like this:

Bildschirmfoto 2023-05-08 um 15 01 22

I can't see this output in your logs. I have also tried your node and npm version and I am still not able to reproduce the issue :/

@snebjorn
Copy link
Author

snebjorn commented May 8, 2023

Appears there's an issue with running npx on my machine.
Installing it in the project and running it from there seems to work 🎉

image

@valentinpalkovic
Copy link
Contributor

Great! I will close this issue then.

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

5 participants