From ea9245446fad475190e980c81b5806809c14a75e Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Wed, 2 Oct 2019 19:09:40 +0300 Subject: [PATCH] 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 --- .../app/custom-elements/code/pretty-printer.service.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/aio/src/app/custom-elements/code/pretty-printer.service.ts b/aio/src/app/custom-elements/code/pretty-printer.service.ts index 63b6fa69b3..24538d8702 100644 --- a/aio/src/app/custom-elements/code/pretty-printer.service.ts +++ b/aio/src/app/custom-elements/code/pretty-printer.service.ts @@ -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; -}; - type PrettyPrintOne = (code: string, language?: string, linenums?: number | boolean) => string; /** @@ -26,8 +22,9 @@ export class PrettyPrinter { private getPrettyPrintOne(): Promise { 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 => {