Skip to content

Conversation

@kroeder
Copy link
Member

@kroeder kroeder commented Nov 1, 2018

Issue: N/A

What I did

There was a bug with the webpack plugin TsconfigPathsPlugin where Storybook in Angular could not import angular components when they are built.

This was my test scenario

// Starting from a projects/index.stories.ts file

// Fails (path: ./dist/lib-a)
import { LibAModule } from 'lib-a';

// Works (path: /projects/lib-a/src/lib/lib-a.module.ts)
import { LibAModule } from '../lib-a/src/lib/lib-a.module';

After checking the angular values here: https://github.com/angular/angular-cli/blob/9f114aee1e009c3580784dd3bb7299bdf4a5918c/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/server.ts#L21

I added

      new TsconfigPathsPlugin({
        configFile: cliWebpackConfigOptions.buildOptions.tsConfig,
        // After ng build my-lib the default value of 'main' in the package.json is 'umd'
        // This causes that you cannot import components directly from dist
        // https://github.com/angular/angular-cli/blob/9f114aee1e009c3580784dd3bb7299bdf4a5918c/packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/browser.ts#L68
        mainFields: [
          ...(cliWebpackConfigOptions.supportES2015 ? ['es2015'] : []),
          'browser',
          'module',
          'main',
        ],

How to test

@kroeder
Copy link
Member Author

kroeder commented Nov 1, 2018

I will combine this with angular cli projects in order to have a direct test of this change

@igor-dv
Copy link
Member

igor-dv commented Nov 1, 2018

@kroeder I would keep these PRs separate

@kroeder
Copy link
Member Author

kroeder commented Nov 1, 2018

Alright 👍

@codecov
Copy link

codecov bot commented Nov 4, 2018

Codecov Report

Merging #4682 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4682   +/-   ##
=======================================
  Coverage   35.59%   35.59%           
=======================================
  Files         557      557           
  Lines        6732     6732           
  Branches      884      884           
=======================================
  Hits         2396     2396           
  Misses       3876     3876           
  Partials      460      460
Impacted Files Coverage Δ
app/angular/src/server/angular-cli_config.js 0% <ø> (ø) ⬆️
...-native/src/preview/components/OnDeviceUI/index.js 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 870cee3...4eefcbc. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants