systemjs复制没有“ .js”扩展名的库调用

时间:2019-05-14 15:02:30

标签: angular typescript angular7 systemjs rxjs6

我正在将旧的角度4项目迁移到角度7。 我使用systemjs进行模块加载。但是我对rxjs加载有问题,因为systemjs毫无理由地加载了它。

我尝试使用新版本的systemjs,但这根本没有帮助。

我的package.json依赖项看起来像这样

"dependencies": {
    "@angular-devkit/architect": {
      "version": "0.13.9",
      "resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.13.9.tgz",
      "integrity": "sha512-EAFtCs9dsGhpMRC45PoYsrkiExpWz9Ax15qXfzwdDRacz5DmdOVt+QpkLW1beUOwiyj/bhFyj23eaONK2RTn/w==",
      "requires": {
        "@angular-devkit/core": "7.3.9",
        "rxjs": "6.3.3"
      },
      "dependencies": {
        "rxjs": {
          "version": "6.3.3",
          "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz",
          "integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==",
          "requires": {
            "tslib": "^1.9.0"
          }
        }
      }
    }

下面列出了我的sytemjs config.js:

...
System.config( {
        baseURL: "",
        defaultExtension: '.js',
        paths: {
            // Paths serve as alias
            "npm:": "node_modules/",
            "libs:": "libs/"
        },
        // Map tells the System loader where to look for things
        map: {
            // Our app is within the app folder
            app: "app",

            // Angular bundles
            "@angular/core": "npm:@angular/core/bundles/core.umd.js",
            "@angular/common": "npm:@angular/common/bundles/common.umd.js",
            "@angular/compiler": "npm:@angular/compiler/bundles/compiler.umd.js",
            "@angular/platform-browser": "npm:@angular/platform-browser/bundles/platform-browser.umd.js",
            "@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js",
            "@angular/common/http": "npm:@angular/common/bundles/common-http.umd.js",
            "@angular/router": "npm:@angular/router/bundles/router.umd.js",
            "@angular/router/upgrade": "npm:@angular/router/bundles/router-upgrade.umd.js",
            "@angular/forms": "npm:@angular/forms/bundles/forms.umd.js",

            // Other Core libraries
            "core-js": "npm:core-js",
            "classlist.js": "npm:classlist.js",
            "whatwg-fetch": "npm:whatwg-fetch",
            "zone.js": "npm:zone.js",

            "rxjs": "npm:rxjs",
            "rxjs/operators": "npm:rxjs.operators",

            // Project libraries
            "events": "npm:events/events.js",
            "echarts": "npm:echarts/dist/echarts.js",
            "moment": "npm:moment/moment.js",

            // Custom libraries
            "typescript": "npm:typescript/lib/typescript.js",
            "angular2-text-mask": "npm:angular2-text-mask/dist/angular2TextMask.js",
            "text-mask-core": "npm:text-mask-core"
        },
        // Packages tells the System loader how to load when no filename and/or no extension
        packages: {
            "core-js": {
                defaultExtension: "js"
            },
            "classlist.js": {
                defaultExtension: "js"
            },
            "whatwg-fetch": {
                defaultExtension: "js"
            },
            "zone.js": {
                defaultExtension: "js"
            },
            rxjs: {
                defaultExtension: "js"
            },
            "rxjs/operators": {
                defaultExtension: "js"
            },
            events: {
                defaultExtension: "js"
            },
            echarts: {
                defaultExtension: "js"
            },
            moment: {
                defaultExtension: "js"
            },
            "angular2-text-mask": {
                defaultExtension: "js"
            },
            "text-mask-core": {
                defaultExtension: "js"
            },
            app: {
                main: "app/main.js",
                defaultExtension: "js"
            }
        },
        transpiler: "typescript"
    } );
})( this );

当页面加载时,我看到不带.js扩展名的请求。 不带.js扩展名的请求的响应为html页面。这就是为什么我的应用程序崩溃的原因。

0 个答案:

没有答案