diff --git a/packages/@angular/cli/utilities/read-tsconfig.ts b/packages/@angular/cli/utilities/read-tsconfig.ts index 84baf70e71d0..0ee83f2d43e1 100644 --- a/packages/@angular/cli/utilities/read-tsconfig.ts +++ b/packages/@angular/cli/utilities/read-tsconfig.ts @@ -1,11 +1,10 @@ import * as path from 'path'; -import * as ts from 'typescript'; import { requireProjectModule } from '../utilities/require-project-module'; export function readTsconfig(tsconfigPath: string) { const projectTs = requireProjectModule(path.dirname(tsconfigPath), 'typescript'); - const configResult = projectTs.readConfigFile(tsconfigPath, ts.sys.readFile); - const tsConfig = projectTs.parseJsonConfigFileContent(configResult.config, ts.sys, + const configResult = projectTs.readConfigFile(tsconfigPath, projectTs.sys.readFile); + const tsConfig = projectTs.parseJsonConfigFileContent(configResult.config, projectTs.sys, path.dirname(tsconfigPath), undefined, tsconfigPath); return tsConfig; } diff --git a/packages/@ngtools/webpack/package.json b/packages/@ngtools/webpack/package.json index acbd41a6a1f3..b52b6b475add 100644 --- a/packages/@ngtools/webpack/package.json +++ b/packages/@ngtools/webpack/package.json @@ -34,7 +34,6 @@ "source-map": "^0.5.6" }, "peerDependencies": { - "typescript": "^2.0.2", "webpack": "^2.2.0 || ^3.0.0" } } diff --git a/packages/@ngtools/webpack/src/angular_compiler_plugin.ts b/packages/@ngtools/webpack/src/angular_compiler_plugin.ts index 40d65fbd0d3d..d909b2d82691 100644 --- a/packages/@ngtools/webpack/src/angular_compiler_plugin.ts +++ b/packages/@ngtools/webpack/src/angular_compiler_plugin.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as fs from 'fs'; import { fork, ForkOptions, ChildProcess } from 'child_process'; import * as path from 'path'; diff --git a/packages/@ngtools/webpack/src/compiler_host.ts b/packages/@ngtools/webpack/src/compiler_host.ts index f2ea6d4f346b..daa76e006fd9 100644 --- a/packages/@ngtools/webpack/src/compiler_host.ts +++ b/packages/@ngtools/webpack/src/compiler_host.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import {basename, dirname, join, sep} from 'path'; import * as fs from 'fs'; diff --git a/packages/@ngtools/webpack/src/entry_resolver.ts b/packages/@ngtools/webpack/src/entry_resolver.ts index e406dc60e900..51dbf2358037 100644 --- a/packages/@ngtools/webpack/src/entry_resolver.ts +++ b/packages/@ngtools/webpack/src/entry_resolver.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as fs from 'fs'; import {join} from 'path'; import * as ts from 'typescript'; diff --git a/packages/@ngtools/webpack/src/gather_diagnostics.ts b/packages/@ngtools/webpack/src/gather_diagnostics.ts index 2145f045d4af..c321c3a45acc 100644 --- a/packages/@ngtools/webpack/src/gather_diagnostics.ts +++ b/packages/@ngtools/webpack/src/gather_diagnostics.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { time, timeEnd } from './benchmark'; diff --git a/packages/@ngtools/webpack/src/index.ts b/packages/@ngtools/webpack/src/index.ts index 78778e1ad439..1b2f43ddb5ef 100644 --- a/packages/@ngtools/webpack/src/index.ts +++ b/packages/@ngtools/webpack/src/index.ts @@ -1,5 +1,20 @@ +// @ignoreDep typescript +import { satisfies } from 'semver'; + +// Test if typescript is available +try { + const version = require('typescript').version; + if (!satisfies(version, '^2.0.2')) { + throw new Error(); + } +} catch (e) { + throw new Error('Could not find local "typescript" package.' + + 'The "@ngtools/webpack" package requires a local "typescript@^2.0.2" package to be installed.' + + e); +} + export * from './plugin'; export * from './angular_compiler_plugin'; export * from './extract_i18n_plugin'; -export {ngcLoader as default} from './loader'; -export {PathsPlugin} from './paths-plugin'; +export { ngcLoader as default } from './loader'; +export { PathsPlugin } from './paths-plugin'; diff --git a/packages/@ngtools/webpack/src/ngtools_api.ts b/packages/@ngtools/webpack/src/ngtools_api.ts index d9d133c22133..4f37069ac08b 100644 --- a/packages/@ngtools/webpack/src/ngtools_api.ts +++ b/packages/@ngtools/webpack/src/ngtools_api.ts @@ -1,4 +1,5 @@ // @ignoreDep @angular/compiler-cli +// @ignoreDep typescript /** * This is a copy of types in @compiler-cli/src/ngtools_api.d.ts file, * together with safe imports for private apis for cases where @angular/compiler-cli isn't diff --git a/packages/@ngtools/webpack/src/paths-plugin.ts b/packages/@ngtools/webpack/src/paths-plugin.ts index 0c5d16da62c0..8f05721669a9 100644 --- a/packages/@ngtools/webpack/src/paths-plugin.ts +++ b/packages/@ngtools/webpack/src/paths-plugin.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as path from 'path'; import * as ts from 'typescript'; import { diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index 02b1ca0f8403..8c256a366794 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as fs from 'fs'; import * as path from 'path'; import * as ts from 'typescript'; diff --git a/packages/@ngtools/webpack/src/refactor.ts b/packages/@ngtools/webpack/src/refactor.ts index 98e816e7e0df..71356fdbd913 100644 --- a/packages/@ngtools/webpack/src/refactor.ts +++ b/packages/@ngtools/webpack/src/refactor.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript // TODO: move this in its own package. import * as path from 'path'; import * as ts from 'typescript'; diff --git a/packages/@ngtools/webpack/src/transformers/ast_helpers.ts b/packages/@ngtools/webpack/src/transformers/ast_helpers.ts index 87a33d025604..8e59157877eb 100644 --- a/packages/@ngtools/webpack/src/transformers/ast_helpers.ts +++ b/packages/@ngtools/webpack/src/transformers/ast_helpers.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { WebpackCompilerHost } from '../compiler_host'; import { makeTransform, TransformOperation } from './make_transform'; diff --git a/packages/@ngtools/webpack/src/transformers/export_lazy_module_map.spec.ts b/packages/@ngtools/webpack/src/transformers/export_lazy_module_map.spec.ts index 59ad4f121cb7..1712e160dbde 100644 --- a/packages/@ngtools/webpack/src/transformers/export_lazy_module_map.spec.ts +++ b/packages/@ngtools/webpack/src/transformers/export_lazy_module_map.spec.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { oneLine, stripIndent } from 'common-tags'; import { transformTypescript } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/export_lazy_module_map.ts b/packages/@ngtools/webpack/src/transformers/export_lazy_module_map.ts index 40019cbc0339..fe56fe6191a5 100644 --- a/packages/@ngtools/webpack/src/transformers/export_lazy_module_map.ts +++ b/packages/@ngtools/webpack/src/transformers/export_lazy_module_map.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as path from 'path'; import * as ts from 'typescript'; diff --git a/packages/@ngtools/webpack/src/transformers/export_ngfactory.spec.ts b/packages/@ngtools/webpack/src/transformers/export_ngfactory.spec.ts index 51f7715ba099..8477143fc2dc 100644 --- a/packages/@ngtools/webpack/src/transformers/export_ngfactory.spec.ts +++ b/packages/@ngtools/webpack/src/transformers/export_ngfactory.spec.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { oneLine, stripIndent } from 'common-tags'; import { transformTypescript } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/export_ngfactory.ts b/packages/@ngtools/webpack/src/transformers/export_ngfactory.ts index cb045fd58aae..4b46545d91ec 100644 --- a/packages/@ngtools/webpack/src/transformers/export_ngfactory.ts +++ b/packages/@ngtools/webpack/src/transformers/export_ngfactory.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { findAstNodes, getFirstNode } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/insert_import.ts b/packages/@ngtools/webpack/src/transformers/insert_import.ts index a8bb4966138e..c8ea9539fa5e 100644 --- a/packages/@ngtools/webpack/src/transformers/insert_import.ts +++ b/packages/@ngtools/webpack/src/transformers/insert_import.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { findAstNodes, getFirstNode } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/register_locale_data.spec.ts b/packages/@ngtools/webpack/src/transformers/register_locale_data.spec.ts index 203f11aa1fc0..f18ce7663b0c 100644 --- a/packages/@ngtools/webpack/src/transformers/register_locale_data.spec.ts +++ b/packages/@ngtools/webpack/src/transformers/register_locale_data.spec.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { oneLine, stripIndent } from 'common-tags'; import { transformTypescript } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/register_locale_data.ts b/packages/@ngtools/webpack/src/transformers/register_locale_data.ts index bd2f8fd45c7c..e389d8d3409d 100644 --- a/packages/@ngtools/webpack/src/transformers/register_locale_data.ts +++ b/packages/@ngtools/webpack/src/transformers/register_locale_data.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { findAstNodes, getFirstNode } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/remove_import.ts b/packages/@ngtools/webpack/src/transformers/remove_import.ts index 58cfdbcf6705..29df47b9de3f 100644 --- a/packages/@ngtools/webpack/src/transformers/remove_import.ts +++ b/packages/@ngtools/webpack/src/transformers/remove_import.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { findAstNodes } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/replace_bootstrap.spec.ts b/packages/@ngtools/webpack/src/transformers/replace_bootstrap.spec.ts index 65c317567e10..6dd34a23cb3b 100644 --- a/packages/@ngtools/webpack/src/transformers/replace_bootstrap.spec.ts +++ b/packages/@ngtools/webpack/src/transformers/replace_bootstrap.spec.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { oneLine, stripIndent } from 'common-tags'; import { transformTypescript } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/replace_bootstrap.ts b/packages/@ngtools/webpack/src/transformers/replace_bootstrap.ts index 3df2a1f0a5f0..d5fcce50fcec 100644 --- a/packages/@ngtools/webpack/src/transformers/replace_bootstrap.ts +++ b/packages/@ngtools/webpack/src/transformers/replace_bootstrap.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { findAstNodes } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/replace_resources.spec.ts b/packages/@ngtools/webpack/src/transformers/replace_resources.spec.ts index 5b6b4dbd5b2c..f687f4abbd1b 100644 --- a/packages/@ngtools/webpack/src/transformers/replace_resources.spec.ts +++ b/packages/@ngtools/webpack/src/transformers/replace_resources.spec.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { oneLine, stripIndent } from 'common-tags'; import { transformTypescript } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/transformers/replace_resources.ts b/packages/@ngtools/webpack/src/transformers/replace_resources.ts index 51091f2f0d18..460c749d904e 100644 --- a/packages/@ngtools/webpack/src/transformers/replace_resources.ts +++ b/packages/@ngtools/webpack/src/transformers/replace_resources.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as ts from 'typescript'; import { findAstNodes, getFirstNode } from './ast_helpers'; diff --git a/packages/@ngtools/webpack/src/type_checker.ts b/packages/@ngtools/webpack/src/type_checker.ts index 30014cd0f48e..18c1629a3ee0 100644 --- a/packages/@ngtools/webpack/src/type_checker.ts +++ b/packages/@ngtools/webpack/src/type_checker.ts @@ -1,3 +1,4 @@ +// @ignoreDep typescript import * as process from 'process'; import * as ts from 'typescript'; import chalk from 'chalk'; diff --git a/tests/e2e/tests/misc/version.ts b/tests/e2e/tests/misc/version.ts index c49c0c62dae3..7b12da7f7da0 100644 --- a/tests/e2e/tests/misc/version.ts +++ b/tests/e2e/tests/misc/version.ts @@ -6,5 +6,8 @@ export default function() { return ng('version') .then(() => deleteFile('.angular-cli.json')) // doesn't fail on a project with missing .angular-cli.json + .then(() => ng('version')) + // Doesn't fail outside a project. + .then(() => process.chdir('/')) .then(() => ng('version')); }