91 Commits

Author SHA1 Message Date
Paul Gschwendtner
647d7bdd88 refactor: fix typescript strict flag failures in all tests ()
Fixes all TypeScript failures caused by enabling the `--strict`
flag for test source files. We also want to enable the strict
options for tests as the strictness enforcement improves the
overall codehealth, unveiled common issues and additionally it
allows us to enable `strict` in the `tsconfig.json` that is picked
up by IDE's.

PR Close 
2019-07-18 14:21:26 -07:00
Pete Bacon Darwin
7186f9c016 refactor(ivy): implement a virtual file-system layer in ngtsc + ngcc ()
To improve cross platform support, all file access (and path manipulation)
is now done through a well known interface (`FileSystem`).

For testing a number of `MockFileSystem` implementations are provided.
These provide an in-memory file-system which emulates operating systems
like OS/X, Unix and Windows.

The current file system is always available via the static method,
`FileSystem.getFileSystem()`. This is also used by a number of static
methods on `AbsoluteFsPath` and `PathSegment`, to avoid having to pass
`FileSystem` objects around all the time. The result of this is that one
must be careful to ensure that the file-system has been initialized before
using any of these static methods. To prevent this happening accidentally
the current file system always starts out as an instance of `InvalidFileSystem`,
which will throw an error if any of its methods are called.

You can set the current file-system by calling `FileSystem.setFileSystem()`.
During testing you can call the helper function `initMockFileSystem(os)`
which takes a string name of the OS to emulate, and will also monkey-patch
aspects of the TypeScript library to ensure that TS is also using the
current file-system.

Finally there is the `NgtscCompilerHost` to be used for any TypeScript
compilation, which uses a given file-system.

All tests that interact with the file-system should be tested against each
of the mock file-systems. A series of helpers have been provided to support
such tests:

* `runInEachFileSystem()` - wrap your tests in this helper to run all the
wrapped tests in each of the mock file-systems.
* `addTestFilesToFileSystem()` - use this to add files and their contents
to the mock file system for testing.
* `loadTestFilesFromDisk()` - use this to load a mirror image of files on
disk into the in-memory mock file-system.
* `loadFakeCore()` - use this to load a fake version of `@angular/core`
into the mock file-system.

All ngcc and ngtsc source and tests now use this virtual file-system setup.

PR Close 
2019-06-25 16:25:24 -07:00
Alex Eagle
86aba1e8f3 build: add moduleName to ngFactory sourcefiles ()
PR Close 
2019-03-19 01:10:49 -04:00
Greg Magolan
ea09430039 build: rules_nodejs 0.26.0 & use @npm instead of @ngdeps now that downstream angular build uses angular bundles ()
PR Close 
2019-02-28 12:06:36 -08:00
Paul Gschwendtner
744b0205e2 build: fix failing compiler-cli tests on windows ()
Note that this fixes `compiler-cli` tests within `compiler-cli/test`,
but there seem to be remaining `ngcc` tests within `compiler-cli/src`
which aren't working on Windows. This is out-of-scope for this commit.

PR Close 
2019-02-05 14:31:10 -05:00
Alex Eagle
a58fd210e9 feat(compiler-cli): resolve generated Sass/Less files to .css inputs ()
Users might have run the CSS Preprocessor tool *before* the Angular
compiler. For example, we do it that way under Bazel. This means that
the design-time reference is different from the compile-time one - the
input to the Angular compiler is a plain .css file.

We assume that the preprocessor does a trivial 1:1 mapping using the same
basename with a different extension.

PR Close 
2019-01-18 09:49:19 -08:00
Alex Rickabaugh
49537458ea test(ivy): update //packages/compiler-cli tests for Ivy ()
These tests are not relevant to Ivy:

//packages/compiler-cli/test/diagnostics:check_types
//packages/compiler-cli/test/diagnostics:expression_diagnostics
//packages/compiler-cli/test/transformers:test
//packages/compiler-cli/test:extract_i18n

The //packages/compiler-cli/test:ngtools_api test has 2 specs, one of
which passes and the other of which depends on ngtsc supporting lazy
routes. It's now disabled with fixmeIvy().

PR Close 
2018-11-29 21:31:35 -08:00
Paul Gschwendtner
0ada23a5fb fix(compiler-cli): only pass canonical genfile paths to compiler host ()
In a more specific scenario: Considering people use a custom TypeScript compiler host with `NGC`, they _could_ expect only posix paths in methods like `writeFile`. This at first glance sounds like a trivial issue that should be just fixed by the actual compiler host, but usually TypeScript internal API's just pass around posix normalized paths, and therefore it would be good to follow the same standards when passing JSON genfiles to the `CompilerHost`.

For normal TypeScript files (and TS genfiles), this is already consistent because those will be handled by the actual TypeScript `Program` (see `emitCallback`).

PR Close 
2018-11-13 10:51:19 -08:00
Misko Hevery
7d2a746090 build: remove ivy JIT mode ()
PR Close 
2018-11-02 15:44:05 -07:00
Igor Minar
ee0b857172 build: rename the ivy compile mode 'local' to 'aot' ()
PR Close 
2018-10-23 14:14:49 -07:00
Igor Minar
4237c34c78 test(ivy): mark failing test targets with fixme-ivy-jit and fixme-ivy-local tags ()
We are close enough to blacklist a few test targets, rather than whitelist targets to run...

Because bazel rules can be composed of other rules that don't inherit tags automatically,
I had to explicitly mark all of our ts_library and ng_module targes with "ivy-local" and
"ivy-jit" tags so that we can create a query that excludes all fixme- tagged targets even
if those targets are composed of other targets that don't inherit this tag.

This is the updated overview of ivy related bazel tags:

- ivy-only: target that builds or runs only under ivy
- fixme-ivy-jit: target that doesn't yet build or run under ivy with --compile=jit
- fixme-ivy-local: target that doesn't yet build or run under ivy with --compile=local
- no-ivy-jit: target that is not intended to build or run under ivy with --compile=jit
- no-ivy-local: target that is not intended to build or run under ivy with --compile=local

PR Close 
2018-10-23 08:57:42 -07:00
Greg Magolan
1f3331f5e6 build(bazel): use fine-grained npm deps () ()
PR Close 
2018-10-19 20:59:29 -07:00
Greg Magolan
b99d7ed5bf build(bazel): update to rules_typescript 0.17.0 & rules_nodejs 0.13.4 ()
PR Close 
2018-09-18 13:05:38 -07:00
Alex Eagle
bdbb2f9bfa ci: update to bazel 0.17 ()
this includes support for @ character in labels, which we need for fine-grained deps

PR Close 
2018-09-17 12:51:52 -07:00
Alex Rickabaugh
a0c4b2d8f0 fix(ivy): add @nocollapse when writing closure-annotated code ()
Closure requires @nocollapse on Ivy definition static fields in order
to not convert them to standalone constants. However tsickle, the tool
which would ordinarily be responsible for adding @nocollapse, doesn't
properly annotate fields which are added synthetically via transforms.
So this commit adds @nocollapse by applying regular expressions against
code during the final write to disk.

PR Close 
2018-09-11 06:53:21 -07:00
Igor Minar
317d40d879 test(compiler-cli): improve testing harness for incremental compilation ()
In tsc 3.0 the check that enables program structure reuse in tryReuseStructureFromOldProgram has changed
and now uses identity comparison on arrays within CompilerOptions. Since we recreate the options
on each incremental compilation, we now fail this check.

After this change the default set of options is reused in between incremental compilations, but we still
allow options to be overriden if needed.

PR Close 
2018-08-27 21:07:53 -04:00
Alex Rickabaugh
ab32ac6bb7 test(compiler-cli): fix the incremental ngc tests so that they run under bazel ()
PR Close 
2018-08-27 21:07:53 -04:00
Greg Magolan
1d051c5841 build(bazel): use bazel managed node_modules for downstream angular from source build support ()
PR Close 
2018-07-26 17:02:21 -07:00
George Kalpakas
00c110b055 build: upgrade jasmine (and related typings) to latest version ()
With these changes, the types are a little stricter now and also not
compatible with Protractor's jasmine-like syntax. So, we have to also
use `@types/jasminewd2` for e2e tests (but not for non-e2e tests).

I also had to "augment" `@types/jasminewd2`, because the latest
typings from [DefinitelyTyped][1] do not reflect the fact that the
`jasminewd2` version (v2.1.0) currently used by Protractor supports
passing a `done` callback to a spec.

[1]: 566e039485/types/jasminewd2/index.d.ts (L9-L15)

Fixes 
Closes 

PR Close 
2018-07-06 13:48:02 -07:00
Mark Levy
d8f7b293d7 fix(compiler): support . in import statements. ()
fix 

PR Close 
2018-06-13 20:29:22 -07:00
Alex Eagle
017d67cdf8 test: switch to ts_web_test_suite ()
Unit tests now run on Firefox too

PR Close 
2018-05-15 11:40:56 -07:00
Oussama Ben Brahim
193737a1ea fix(compiler-cli): use numeric comparison for TypeScript version ()
Fixes 

PR Close 
2018-03-30 07:58:36 -07:00
Chuck Jazdzewski
4e004f3783 ci(compiler-cli): run compiler-cli tests in bazel ()
PR Close 
2018-03-28 10:02:53 -07:00
Veres Lajos
de90314304 style: typos fixed - https://github.com/vlajos/misspell-fixer ()
PR Close 
2018-03-27 14:51:53 -04:00
Alex Rickabaugh
6ef9f2278f feat(ivy): @NgModule -> ngInjectorDef compilation ()
This adds compilation of @NgModule providers and imports into
ngInjectorDef statements in generated code. All @NgModule annotations
will be compiled and the @NgModule decorators removed from the
resultant js output.

All @Injectables will also be compiled in Ivy mode, and the decorator
removed.

PR Close 
2018-03-16 12:57:11 -07:00
Olivier Combe
3b167be069 feat(compiler): support for singleline, multiline & jsdoc comments ()
PR Close 
2018-03-15 14:48:53 -07:00
Chuck Jazdzewski
6e5e819e80 fix(compiler-cli): emit correct css string escape sequences ()
Works around an issue with TypeScript 2.6 and 2.7 that causes
the tranformer emit to emit incorrect escapes for css string
literals.

Fixes: 

PR Close 
2018-03-15 11:37:50 -07:00
Chuck Jazdzewski
8449eb8d62 build: upgrade to TypeScript 2.7 ()
Fixes: 

PR Close 
2018-03-12 09:27:23 -07:00
Alex Eagle
40315bef3d fix(compiler-cli): enableResourceInlining handles both styles and styleUrls ()
When both are present, the inlined styles are appended to the end of the styles

PR Close 
2018-03-11 22:14:32 -07:00
Alex Eagle
123efba388 fix(compiler-cli): resolve resource URLs before loading them under enableResourceInlining ()
Also turn on the feature for Bazel ng_module rules

PR Close 
2018-03-11 22:14:31 -07:00
Alex Eagle
b5be18f405 feat(compiler-cli): add resource inlining to ngc ()
When angularCompilerOptions { enableResourceInlining: true }, we replace all templateUrl and styleUrls properties in @Component with template/styles

PR Close 
2018-03-09 09:15:12 -08:00
Chuck Jazdzewski
eb8ddd2983 feat(compiler-cli): reflect static methods added to classes in metadata ()
PR Close 
2018-02-01 08:30:58 -08:00
Chuck Jazdzewski
64d16dee02 feat(compiler): implement "enableIvy" compiler option ()
The "enableIvy" compiler option is the initial implementation
of the Render3 (or Ivy) code generation. This commit enables
generation generating "Hello, World" (example in the test)
but not much else. It is currenly only useful for internal Ivy
testing as Ivy is in development.

PR Close 
2018-01-18 18:22:44 -06:00
Chuck Jazdzewski
7f93aad836 fix(compiler-cli): do not lower expressions in non-modules ()
Fixes: 

PR Close 
2018-01-18 18:21:42 -06:00
Chuck Jazdzewski
83d207d0a7 build: upgrade to TypeScript 2.6 ()
Fixes 

PR Close 
2017-12-22 20:15:47 -08:00
Trotyl
05ff6c09ca fix(compiler): make tsx file aot compatible
fixes 
2017-12-15 07:53:46 -08:00
Martin Probst
8c52088346 fix(compiler-cli): merge @fileoverview comments. ()
Previously, this code would unconditionally add a @fileoverview
comment to generated files, and only if the contained any code at all.

However often existing fileoverview comments should be copied from the
file the generated file was originally based off of. This allows users
to e.g. include Closure Compiler directives in their original
`component.ts` file, which will then automaticallly also apply to code
generated from it.

This special cases `@license` comments, as Closure disregards directives
in comments containing `@license`.

PR Close 
2017-12-12 11:37:55 -08:00
Keen Yee Liau
073f485c72 fix(compiler-cli): Fix swallowed Error messages ()
This commit fixes a bug in which non-formatted errors are silently
dropped.

Internal issue: b/67739418

PR Close 
2017-12-06 16:49:22 -08:00
Chuck Jazdzewski
8ecda94899 feat(compiler-cli): improve error messages produced during structural errors ()
The errors produced when error were encountered while interpreting the
content of a directive was often incomprehencible. With this change
these kind of error messages should be easier to understand and diagnose.

PR Close 
2017-11-27 16:59:57 -06:00
Chuck Jazdzewski
dcfffbf828 build: fix build failures () 2017-11-15 22:33:30 -08:00
Alex Eagle
5b16ce9302 fix(compiler-cli): don't report emit diagnostics when --noEmitOnError is off () 2017-11-02 14:49:38 -07:00
Tobias Bosch
54480f7dfc fix(compiler): report errors properly in G3 in certain conditions ()
Condition: static analysis error, given:
- noResolve:true
- generateCodeForLibraries: false
- CompilerHost.getSourceFile throws on non existent files

All of these are true in G3.
PR Close 
2017-10-30 21:24:30 -04:00
Tobias Bosch
04eb80cc2b fix(compiler): always use relative paths to refer to generated code
Previously we generated imports like `@angular/material/index.ngfactory`,
which doesn’t make sense as we don’t ship generated code on npm

Closes 
2017-10-30 18:28:25 -04:00
Tobias Bosch
957be960d2 fix(compiler): recover from structural errors in watch mode ()
This also changes the compiler so that we throw less often
on structural changes and produce a meaningful state
in the `ng.Program` in case of errors.

Related to 

PR Close 
2017-10-26 18:43:00 -04:00
Tobias Bosch
18e9d86a3b fix(compiler): translate emit diagnostics with noEmitOnError: true. ()
This prevents errors reported against `.ngfactory.ts` files show up
as the result of running `ngc`.

Closes 
PR Close 
2017-10-26 18:42:59 -04:00
Tobias Bosch
a869aeecd2 fix(compiler): don’t store invalid state when using listLazyRoutes ()
Previously, `listLazyRoute` would store invalid information in a compiler
internal cache, which lead to incorrect paths that were used during emit.
This commit fixes this.

PR Close 
2017-10-26 18:42:59 -04:00
Chuck Jazdzewski
7bfeac746e fix(compiler-cli): only use error collector when needed. ()
The error collector changes behavior of the metadata resolver
in ways that haven't been fully hardened. This changes limits
its use to the lazy route detection and the language service.

Issue: 

PR Close 
2017-10-24 17:06:41 -04:00
Tobias Bosch
c92efc15fb fix(compiler): don’t type check templates with skipTemplateCodegen ()
This change is needed to prevent users’ builds from breaking.

If a user sets `fullTemlateTypeCheck` to true, we will
continue to check the templates even when `skipTemplateCodegen` is true
as well.

Related to 

PR Close 
2017-10-24 17:06:34 -04:00
Tobias Bosch
fc0b1d5b61 fix(compiler): correctly calculate the outDir if it repeats a parts of the rootDir. ()
Fixes 

PR Close 
2017-10-23 18:46:04 -04:00
Tobias Bosch
8d45fefc31 refactor(compiler): remove old ngtools api and add listLazyRoutes to new api ()
Usages of `NgTools_InternalApi_NG_2` from `@angular/compiler-cli` will now
throw an error.

Adds `listLazyRoutes` to `@angular/compiler-cli/ngtools2.ts` for getting
the lazy routes of a `ng.Program`.
PR Close 
2017-10-23 18:46:04 -04:00