0

I'm getting a wrong bundle file when I execute the command:

jspm bundle src/main.js main-bundle.js

Files like npm:@angular/animations@4.1.3.json are not include, no .json files are included, only .js files, however, if I launch the same command from OSX those fields are included

From OSX (valid bundle file content):

   npm:@angular/animations@4.1.3.json
   npm:@angular/animations@4.1.3/bundles/animations-browser.umd.min.js
   npm:@angular/animations@4.1.3/bundles/animations.umd.js
   npm:@angular/common@4.1.3.json
   npm:@angular/common@4.1.3/bundles/common.umd.js
   npm:@angular/compiler@4.1.3.json
   npm:@angular/compiler@4.1.3/bundles/compiler.umd.js
   npm:@angular/core@4.1.3.json
   npm:@angular/core@4.1.3/bundles/core.umd.js
   npm:@angular/forms@4.1.3.json
   npm:@angular/forms@4.1.3/bundles/forms.umd.js
   npm:@angular/http@4.1.3.json
   npm:@angular/http@4.1.3/bundles/http.umd.js
   npm:@angular/material@2.0.0-beta.6.json
   npm:@angular/material@2.0.0-beta.6/bundles/material.umd.js
   npm:@angular/platform-browser-dynamic@4.1.3.json
   npm:@angular/platform-browser-dynamic@4.1.3/bundles/platform-browser-dynamic.umd.js
   npm:@angular/platform-browser@4.1.3.json
   npm:@angular/platform-browser@4.1.3/bundles/platform-browser-animations.umd.min.js
   npm:@angular/platform-browser@4.1.3/bundles/platform-browser.umd.js
   npm:@angular/router@4.1.3.json
   npm:@angular/router@4.1.3/bundles/router.umd.js
   npm:core-js@2.4.1.json
   npm:core-js@2.4.1/client/shim.js
   npm:core-js@2.4.1/es6/reflect.js
   npm:core-js@2.4.1/es7/reflect.js

From Linux (wrong bundle file, missing json package definitions):

   npm:@angular/animations@4.1.3/bundles/animations-browser.umd.min.js
   npm:@angular/animations@4.1.3/bundles/animations.umd.js
   npm:@angular/common@4.1.3/bundles/common.umd.js
   npm:@angular/compiler@4.1.3/bundles/compiler.umd.js
   npm:@angular/core@4.1.3/bundles/core.umd.js
   npm:@angular/forms@4.1.3/bundles/forms.umd.js
   npm:@angular/http@4.1.3/bundles/http.umd.js
   npm:@angular/material@2.0.0-beta.6/bundles/material.umd.js
   npm:@angular/platform-browser-dynamic@4.1.3/bundles/platform-browser-dynamic.umd.js
   npm:@angular/platform-browser@4.1.3/bundles/platform-browser-animations.umd.min.js
   npm:@angular/platform-browser@4.1.3/bundles/platform-browser.umd.js
   npm:@angular/router@4.1.3/bundles/router.umd.js
   npm:core-js@2.4.1/client/shim.js
   npm:core-js@2.4.1/es6/reflect.js
   npm:core-js@2.4.1/es7/reflect.js
   npm:core-js@2.4.1/modules/_a-function.js

Both are using the same version of jspm (0.17.0-beta.41), systemjs (0.20.10) and systemjs-builder (0.16.4), I suppose that there is something different in both environments that is affecting, but I've removed the ~/.jspm directory for a clean env with the same results, and I'm not sure what else could be affecting.

The jspm.config.js file is the same in both cases:

SystemJS.config({
  nodeConfig: {
    "paths": {
      "github:": "jspm_packages/github/",
      "npm:": "jspm_packages/npm/"
    }
  },
  devConfig: {
    "map": {
      "plugin-typescript": "github:frankwallis/plugin-typescript@7.0.6",
      "typescript": "npm:typescript@2.3.4",
      "child_process": "npm:jspm-nodelibs-child_process@0.2.1",
      "module": "npm:jspm-nodelibs-module@0.2.1",
      "net": "npm:jspm-nodelibs-net@0.2.1"
    },
    "packages": {
      "npm:source-map-support@0.4.14": {
        "map": {
          "source-map": "npm:source-map@0.5.6"
        }
      },
      "npm:typescript@2.3.4": {
        "map": {
          "source-map-support": "npm:source-map-support@0.4.14"
        }
      }
    }
  },
  transpiler: false,
  packages: {
    "environments": {
      "defaultExtension": "js"
    },
    "src": {
      "defaultExtension": "js"
    }
  },
  map: {
    "@angular/animations/browser": "npm:@angular/animations@4.1.3/bundles/animations-browser.umd.min.js",
    "@angular/platform-browser/animations": "npm:@angular/platform-browser@4.1.3/bundles/platform-browser-animations.umd.min.js",
    "app": "src/app"
  }
});

SystemJS.config({
  packageConfigPaths: [
    "github:*/*.json",
    "npm:@angular/*.json",
    "npm:@covalent/*.json",
    "npm:*.json"
  ],
  map: {
    "@angular/animations": "npm:@angular/animations@4.1.3",
    "@angular/common": "npm:@angular/common@4.1.3",
    "@angular/compiler": "npm:@angular/compiler@4.1.3",
    "@angular/core": "npm:@angular/core@4.1.3",
    "@angular/forms": "npm:@angular/forms@4.1.3",
    "@angular/http": "npm:@angular/http@4.1.3",
    "@angular/material": "npm:@angular/material@2.0.0-beta.6",
    "@angular/platform-browser": "npm:@angular/platform-browser@4.1.3",
    "@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@4.1.3",
    "@angular/router": "npm:@angular/router@4.1.3",
    "@covalent/core": "npm:@covalent/core@1.0.0-beta.4",
    "@covalent/dynamic-forms": "npm:@covalent/dynamic-forms@1.0.0-beta.4",
    "@covalent/http": "npm:@covalent/http@1.0.0-beta.4",
    "angular-in-memory-web-api": "npm:angular-in-memory-web-api@0.3.1",
    "angular-safeguard": "npm:angular-safeguard@1.0.1",
    "assert": "npm:jspm-nodelibs-assert@0.2.1",
    "buffer": "npm:jspm-nodelibs-buffer@0.2.2",
    "constants": "npm:jspm-nodelibs-constants@0.2.1",
    "core-js": "npm:core-js@2.4.1",
    "crypto": "npm:jspm-nodelibs-crypto@0.2.1",
    "events": "npm:jspm-nodelibs-events@0.2.2",
    "file-saver": "npm:file-saver@1.3.3",
    "fs": "npm:jspm-nodelibs-fs@0.2.1",
    "hammerjs": "npm:hammerjs@2.0.8",
    "ng2-toastr": "npm:ng2-toastr@4.0.1",
    "os": "npm:jspm-nodelibs-os@0.2.1",
    "path": "npm:jspm-nodelibs-path@0.2.3",
    "process": "npm:jspm-nodelibs-process@0.2.1",
    "rxjs": "npm:rxjs@5.3.0",
    "stream": "npm:jspm-nodelibs-stream@0.2.1",
    "string_decoder": "npm:jspm-nodelibs-string_decoder@0.2.1",
    "timers": "npm:jspm-nodelibs-timers@0.2.1",
    "util": "npm:jspm-nodelibs-util@0.2.2",
    "vm": "npm:jspm-nodelibs-vm@0.2.1",
    "web-animations-js": "npm:web-animations-js@2.2.2",
    "zone.js": "npm:zone.js@0.8.5"
  },
  packages: {
      // SKIPPED //
  }
});

If I understand correctly, the missing json files are processed but not included, the file "npm:@angular/http@4.1.3/bundles/http.umd.js" is included because is defined in "npm:@angular/http@4.1.3.json", however, for some reason the package definition file is skipped in the bundle.

¿ Is there any other file that I should check in both environments ? Any idea is welcome.

UPDATE: After some tests, I suspect that the problem is related with systemjs-builder lib, not jspm

Roberto
  • 8,586
  • 3
  • 42
  • 53
  • Why would you want those files to be included in the bundle? They just tell jspm where to look for actual .js files that contain modules. What's inside them that you need? – Mjh Jun 09 '17 at 13:22
  • The problem is that without those files, when I launch the app, the browser (systemjs) try to download them from server, so an 404 is returned. In other words, with them in the bundle, the libs are "registered" locally and systemjs knows that the implementation is included in the bundle. – Roberto Jun 09 '17 at 14:15
  • Ok, so let's try to approach this problem from a slightly different angle - are you trying to distribute your application as a single file? If yes, you should be using `jspm build`. – Mjh Jun 09 '17 at 14:19
  • I want a single file only for js files, "typical bundle", anyway, the problem is in SystemJS builder, the deps resolution in one env include the .json files but not in the another one. An example got from debug, the lib `@angular/core@4.1.3/bundles/core.umd.js` should include `@angular/core@4.1.3.json` as dependency, but in one of env is not included. – Roberto Jun 09 '17 at 14:47

1 Answers1

0

Finally, I found the problem, the method getPackageConfigPath(...) in utils.js in the lib systemjs-builder fails (returns nothing) if the directory absolute path with the packageConfigPaths contains a "(".

In linux, the jenkins job had a name like "MyProject (angular2)", and this was causing that the building process couldn't find the packageConfigPath for none of the libs in the bundle.

I've opened an issue on the github project: https://github.com/systemjs/builder/issues/811

Roberto
  • 8,586
  • 3
  • 42
  • 53