refactor(docs-infra): replace `System.import()` with `import()` (#32923)

`System.import()` has been deprecated in webpack and produces the
following warning when building the app:

```
WARNING in ./src/app/custom-elements/code/pretty-printer.service.ts
System.import() is deprecated and will be removed soon. Use import()
instead.
```

Switching to `import()` to get rid of the warning.

Fixes #30365
Closes #30419

PR Close #32923
This commit is contained in:
George Kalpakas 2019-10-02 19:09:40 +03:00 committed by atscott
parent ad753d3fa7
commit ea9245446f
1 changed files with 3 additions and 6 deletions

View File

@ -5,10 +5,6 @@ import { first, map, share } from 'rxjs/operators';
import { Logger } from 'app/shared/logger.service';
declare const System: {
import(name: string): Promise<any>;
};
type PrettyPrintOne = (code: string, language?: string, linenums?: number | boolean) => string;
/**
@ -26,8 +22,9 @@ export class PrettyPrinter {
private getPrettyPrintOne(): Promise<PrettyPrintOne> {
const ppo = (window as any)['prettyPrintOne'];
return ppo ? Promise.resolve(ppo) :
// prettify.js is not in window global; load it with webpack loader
System.import('assets/js/prettify.js')
// `prettyPrintOne` is not on `window`, which means `prettify.js` has not been loaded yet.
// Import it; ad a side-effect it will add `prettyPrintOne` on `window`.
import('assets/js/prettify.js' as any)
.then(
() => (window as any)['prettyPrintOne'],
err => {