diff --git a/app/angular/package.json b/app/angular/package.json index 3719cbee53f..cdb8717d78a 100644 --- a/app/angular/package.json +++ b/app/angular/package.json @@ -41,7 +41,6 @@ "devDependencies": { "@types/autoprefixer": "^9.4.0", "@types/webpack-env": "^1.13.9", - "typescript": "^3.4.4", "zone.js": "^0.8.29" }, "peerDependencies": { @@ -52,9 +51,11 @@ "@angular/forms": ">=6.0.0", "@angular/platform-browser": ">=6.0.0", "@angular/platform-browser-dynamic": ">=6.0.0", + "@angular-devkit/build-angular": ">=6.0.0", "autoprefixer": "^8.1.0", "babel-loader": "^7.0.0 || ^8.0.0", "rxjs": "^6.0.0", + "typescript": "^3.4.4", "zone.js": "^0.8.29" }, "engines": { diff --git a/app/angular/src/server/__tests__/create-fork-ts-checker-plugin.test.ts b/app/angular/src/server/__tests__/create-fork-ts-checker-plugin.test.ts index a65ba622f7a..f51bdd1e098 100644 --- a/app/angular/src/server/__tests__/create-fork-ts-checker-plugin.test.ts +++ b/app/angular/src/server/__tests__/create-fork-ts-checker-plugin.test.ts @@ -3,7 +3,7 @@ import getTsLoaderOptions from '../ts_config'; import createForkTsCheckerInstance from '../create-fork-ts-checker-plugin'; // eslint-disable-next-line global-require -jest.mock('fs', () => require('./fs')); +jest.mock('fs', () => require('../../../../../__mocks__/fs')); jest.mock('path', () => ({ resolve: () => 'tsconfig.json', })); diff --git a/app/angular/src/server/__tests__/ts_config.test.ts b/app/angular/src/server/__tests__/ts_config.test.ts index 4eeb38ae9a1..f282bbbd37b 100644 --- a/app/angular/src/server/__tests__/ts_config.test.ts +++ b/app/angular/src/server/__tests__/ts_config.test.ts @@ -1,7 +1,7 @@ import getTsLoaderOptions from '../ts_config'; // eslint-disable-next-line global-require -jest.mock('fs', () => require('../../../../__mocks__/fs')); +jest.mock('fs', () => require('../../../../../__mocks__/fs')); jest.mock('path', () => ({ resolve: () => 'tsconfig.json', })); diff --git a/app/angular/src/server/angular-cli_config.ts b/app/angular/src/server/angular-cli_config.ts index 67c94bfced8..b08d79a2b3f 100644 --- a/app/angular/src/server/angular-cli_config.ts +++ b/app/angular/src/server/angular-cli_config.ts @@ -1,3 +1,5 @@ +import { CompilerOptions } from 'typescript'; +import { Path } from '@angular-devkit/core'; import path from 'path'; import fs from 'fs'; import { logger } from '@storybook/node-logger'; @@ -8,9 +10,6 @@ import { filterOutStylingRules, getAngularCliParts, } from './angular-cli_utils'; -import { Path } from '@angular-devkit/core'; - -import { CompilerOptions } from 'typescript'; // todo add more accurate typings interface BasicOptions { diff --git a/app/angular/src/server/angular-cli_utils.ts b/app/angular/src/server/angular-cli_utils.ts index 9c955a40ab3..1335d3ea447 100644 --- a/app/angular/src/server/angular-cli_utils.ts +++ b/app/angular/src/server/angular-cli_utils.ts @@ -1,5 +1,9 @@ import fs from 'fs'; import { basename, dirname, normalize, relative, resolve, Path } from '@angular-devkit/core'; +import { + getCommonConfig, + getStylesConfig, +} from '@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs'; import { RuleSetRule, Configuration } from 'webpack'; @@ -54,14 +58,10 @@ export function isBuildAngularInstalled() { // todo add type export function getAngularCliParts(cliWebpackConfigOptions: any) { - // eslint-disable-next-line global-require, import/no-extraneous-dependencies - // tslint:disable-next-line: no-implicit-dependencies - const ngCliConfigFactory = require('@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs'); - try { return { - cliCommonConfig: ngCliConfigFactory.getCommonConfig(cliWebpackConfigOptions), - cliStyleConfig: ngCliConfigFactory.getStylesConfig(cliWebpackConfigOptions), + cliCommonConfig: getCommonConfig(cliWebpackConfigOptions), + cliStyleConfig: getStylesConfig(cliWebpackConfigOptions), }; } catch (e) { return null; diff --git a/app/angular/src/server/framework-preset-angular-cli.ts b/app/angular/src/server/framework-preset-angular-cli.ts index 6f91e9a5bdd..4d34f5f22de 100644 --- a/app/angular/src/server/framework-preset-angular-cli.ts +++ b/app/angular/src/server/framework-preset-angular-cli.ts @@ -1,11 +1,11 @@ +import { Configuration } from 'webpack'; +import { Path } from '@angular-devkit/core'; import { logger } from '@storybook/node-logger'; import { getAngularCliWebpackConfigOptions, applyAngularCliWebpackConfig, } from './angular-cli_config'; -import { Path } from '@angular-devkit/core'; -import { Configuration } from 'webpack'; export function webpackFinal(config: Configuration) { const cwd = process.cwd() as Path;