Ошибка с отложенной загрузкой после обновления до angular cli 7.3 от 7.2 - PullRequest
0 голосов
/ 28 февраля 2019

У меня было angular-cli@7.2, поэтому я обновился до ng update -all После обновления я не могу запустить ng serve У меня ошибка:

ERROR in ./src/app/utils/lazy-loading.ts 57:49
Module parse failed: Unexpected token (57:49)
You may need an appropriate loader to handle this file type.
|             return __generator(this, function (_a) {
|                 switch (_a.label) {
>                     case 0: return [4 /*yield*/, import('@amcharts/amcharts4/core')];
|                     case 1:
|                         am4core = _a.sent();

Речь идет о моих лениво загруженных библиотеках с таким кодом:

export class LazyLoading {
  /**
   * Usage
   *
   LazyLoading.loadAmcharts()
   .then((
   {
            am4core,
            am4charts,
            am4themesAnimated,
          }
   ) => {});
   *
   */
  static async loadAmcharts(): Promise<any> {
    const am4core = await import('@amcharts/amcharts4/core');
    const am4charts = await import('@amcharts/amcharts4/charts');
    const am4themesAnimated = await import('@amcharts/amcharts4/themes/animated').then(resp => {
      return resp.default;
    });
    return {
      am4core: am4core,
      am4charts: am4charts,
      am4themesAnimated: am4themesAnimated,
    };
  }

  static async loadAmchartsMaps(): Promise<any> {
    const am4core = await import('@amcharts/amcharts4/core');
    const am4maps = await import('@amcharts/amcharts4/maps');
    const world = await import('@amcharts/amcharts4-geodata/worldLow').then(resp => {
      return resp.default;
    });
    const poland = await import('@amcharts/amcharts4-geodata/polandHigh').then(resp => {
      return resp.default;
    });
    const europe = await import('@amcharts/amcharts4-geodata/region/world/europeLow').then(resp => {
      return resp.default;
    });

    return {
      am4core: am4core,
      am4maps: am4maps,
      world: world,
      europe: europe,
      poland: poland,
    };
  }

  static async loadZXCVBN(): Promise<any> {
    const zxcvbn = await import ('zxcvbn').then(resp => {
      return resp.default;
    });
    return zxcvbn;
  }

  static async loadRrule(): Promise<any> {
    const Rrule = await import ('rrule/dist/esm/src/rrule')
      .then(resp => {
        return resp.default;
      });
    return Rrule;
  }
}

Я не знаю, что изменилось.

Вот мой tsconfig файл:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    //    "module": "es2015",
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "resolveJsonModule": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ],
    "paths": {
      "@app/*": [
        "src/app/*"
      ],
      "@mocks/*": [
        "src/mocks/*"
      ],
      "@decorators/*": [
        "src/app/utils/decorators/*"
      ]
    }
  }
}
...