angular-cn/packages/compiler-cli/test/metadata
Paul Gschwendtner 4131715df5 fix(compiler-cli): incorrect bundled metadata for static class member call expressions (#28762)
Currently if developers use call expressions in their static
class members ([like we do in Angular](https://github.com/angular/angular/blob/master/packages/core/src/change_detection/differs/keyvalue_differs.ts#L121)),
the metadata that is generated for flat modules is invalid. This
is because the metadata bundler logic currently does not handle
call expressions in static class members and the symbol references
are not rewritten to avoid relative paths in the bundle.

Static class members using a call expression are not relevant for
the ViewEngine AOT compilation, but it is problematic that the
bundled metadata references modules using their original relative
path. This means that the bundled metadata is no longer encapsulated
and depends on other emitted files to be emitted in the proper place.

These incorrect relative paths can now cause issues where NGC
looks for the referenced symbols in the incorrect path. e.g.

```
src/
 | lib/
    | index.ts -> References the call expression using `../../di`
```

Now the metadata looks like that:

```
node_modules/
  | @angular/
  -- | core/
  -- -- | core.metadata.json -> Says that the call expr. is in `../../di`.
  | di/
```

Now if NGC tries to use the metadata files and create the summary files,
NGC resolves the call expression to the `node_modules/di` module. Since
the "unexpected" module does not contain the desired symbol, NGC will
error out.

We should fix this by ensuring that we don't ship corrupted metadata
to NPM which contains relative references that can cause such
failures (other imports can be affected as well; it depends on what
modules the developer has installed and how we import our call
expressions).

Fixes #28741.

PR Close #28762
2019-02-19 12:53:18 -08:00
..
BUILD.bazel test(ivy): mark failing test targets with fixme-ivy-jit and fixme-ivy-local tags (#26471) 2018-10-23 08:57:42 -07:00
bundler_spec.ts fix(compiler-cli): incorrect bundled metadata for static class member call expressions (#28762) 2019-02-19 12:53:18 -08:00
collector_spec.ts feat: add TypeScript 3 support (#25275) 2018-08-27 21:07:53 -04:00
evaluator_spec.ts feat: add TypeScript 3 support (#25275) 2018-08-27 21:07:53 -04:00
index_writer_spec.ts refactor(compiler): remove all source-level traces to tsc-wrapped (#18966) 2017-09-13 20:47:37 -04:00
symbols_spec.ts feat: add TypeScript 3 support (#25275) 2018-08-27 21:07:53 -04:00
typescript.mocks.ts feat: add TypeScript 3 support (#25275) 2018-08-27 21:07:53 -04:00