Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundling yields error source has multiple anonymous System.register calls. #1859

Closed
born2net opened this issue May 27, 2016 · 10 comments
Closed

Comments

@born2net
Copy link

I switched over from cjs to system and now when I run:

jspm bundle src/App.js ./dist/index.js --skip-source-maps

I get

err  Source StudioDashboard/App.js has multiple anonymous System.register calls.

this is my config:
https://github.com/born2net/studioDashboard/blob/hot-reload/jspm.config.js
and project:
https://github.com/born2net/studioDashboard/tree/hot-reload

any suggestions?

tx

Sean

@born2net
Copy link
Author

born2net commented May 27, 2016

my App.js (TS generated) only has one System.register call

err

I even tried to keep things to minimum with a simple app as:

import { Component } from '@angular/core';
import { bootstrap } from '@angular/platform-browser-dynamic';

@Component({
    selector: 'app',
    template: '<h1>My First Angular 2 App</h1>'
})
export class AppComponent { }


bootstrap(AppComponent);

and same error...

I am using

jspm 0.17.0-beta.14

@guybedford
Copy link
Member

What does your App.js file look like here? It doesn't seem to be in the repo, so I take it you're running a compilation first? Can you share the output?

@jakeNiemiec
Copy link
Contributor

jakeNiemiec commented May 31, 2016

@born2net & @guybedford, I have created an example barebones project that will throw the error: https://github.com/jakeNiemiec/jspmsandbox
Here is the path:

 jakeniemiec@Sat  ~/RubymineProjects  git clone git@github.com:jakeNiemiec/jspmsandbox.git
Cloning into 'jspmsandbox'...
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 15 (delta 1), reused 15 (delta 1), pack-reused 0
Receiving objects: 100% (15/15), done.
Resolving deltas: 100% (1/1), done.
Checking connectivity... done.
 jakeniemiec@Sat  ~/RubymineProjects  cd jspmsandbox
 jakeniemiec@Sat  ~/RubymineProjects/jspmsandbox   master  npm i
jspmsandbox@1.0.0 /Users/jakeniemiec/RubymineProjects/jspmsandbox
├─┬ jspm@0.17.0-beta.16
  #(long dep tree excluded)
└── typescript@1.8.10

npm WARN jspmsandbox@1.0.0 No description
npm WARN jspmsandbox@1.0.0 No repository field.
 jakeniemiec@Sat  ~/RubymineProjects/jspmsandbox   master  jspm i
     Updating registry cache...
ok   Installed dev dependency npm:os-browserify@^0.2.0 (0.2.1)
ok   Installed dev dependency os to github:jspm/nodelibs-os@^0.2.0-alpha (0.2.0-alpha)
ok   Installed dev dependency npm:typescript@^1.8.7 (1.8.10)
ok   Installed dev dependency plugin-typescript to github:frankwallis/plugin-typescript@^4.0.16 (4.0.16)
     Install tree has no forks.
     Looking up loader files...
       system-polyfills.js
       system.js.map
       system.js
       system.src.js
       system-polyfills.src.js
       system-polyfills.js.map

     Using loader versions:
       systemjs@0.19.29
ok   Loader files downloaded successfully

ok   Install complete.
 jakeniemiec@Sat  ~/RubymineProjects/jspmsandbox   master  tsc
 jakeniemiec@Sat  ~/RubymineProjects/jspmsandbox   master  jspm bundle jspmsandbox
     Building the bundle tree for jspmsandbox...

err  Source jspmsandbox/jspmsandbox.js has multiple anonymous System.register calls.

Files:
src/jspmsandbox.ts

import {test} from './otherfile';

This transpiles to:

System.register([], function(exports_1, context_1) {
    "use strict";
    var __moduleName = context_1 && context_1.id;
    return {
        setters:[],
        execute: function() {
        }
    }
});
//# sourceMappingURL=jspmsandbox.js.map

src/otherfile.ts

export function test() {
  return true;
}

This transpiles to:

System.register([], function(exports_1, context_1) {
    "use strict";
    var __moduleName = context_1 && context_1.id;
    function test() {
        return true;
    }
    exports_1("test", test);
    return {
        setters:[],
        execute: function() {
        }
    }
});
//# sourceMappingURL=otherfile.js.map
0.17.0-beta.16 #jspm -v (*will also happen on jspm@0.17.0-beta.17*)
Running against local jspm install.

3.9.2 #npm -v

Version 1.8.10 #tsc -v (typescript), this will also happen with typescript@next (typescript@1.9.0-dev.20160531-1.0)

tsconfig.json

{
    "compilerOptions": {
        "target": "ES5",
        "module": "system",
        "moduleResolution": "node",
        "declaration": true,
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false,
        "listFiles": false
    },
    "exclude": [
        "node_modules",
        "jspm_packages",
        "dist",
        "typings/*",
        "typings/main",
        "typings/main.d.ts"
    ]
}

I hope this is enough info to diagnose the problem.

@born2net
Copy link
Author

Thanks for doing that...!

@born2net
Copy link
Author

born2net commented May 31, 2016

and @guybedford you were asking about my app.js, it is just a clean js file, the problem is that System.Register is the file (the first line) AND it must appear somewhere in another file (not part of the project as it is the only file in my project) and so I would assume jspm seens the 2 System.registers

@born2net
Copy link
Author

born2net commented May 31, 2016

System.register(["zone.js/dist/zone", "zone.js/dist/long-stack-trace-zone", "reflect-metadata", "@angular/router", "@angular/platform-browser-dynamic", "@angular/core", "platform", "jspm_packages/github/twbs/bootstrap@3.3.6", "twbs/bootstrap/dist/css/bootstrap.css!", "./styles/style.css!", "./styles/StyleService", "./services/AppInjService", "./services/LocalStorage", "./services/AuthService", "./services/StoreService", "./business/BusinessAction", "./reseller/ResellerAction", "./orders/OrdersAction", "./orders/OrdersReducer", "./stations/StationsAction", "./pipes/CharCount", "@angular/http", "../src/comps/app1/App1", "../src/comps/entry/EntryPanel", "../src/comps/appmanager/AppManager", "../src/services/CommBroker", "../src/comps/filemenu/Filemenu", "../src/comps/filemenu/FilemenuItem", "./comps/logo/Logo", "./comps/footer/Footer", "../src/Conts", "@angular/common", "angular2-redux-util", "./Lib", "./services/CreditService", "rxjs/add/operator/map", "rxjs/add/operator/debounceTime", "rxjs/add/observable/fromEvent", "rxjs/add/observable/forkJoin", "rxjs/add/operator/distinctUntilChanged", "rxjs/add/operator/catch", "rxjs/add/operator/finally", "rxjs/add/observable/throw", "rxjs/add/operator/switchMap", "rxjs/add/operator/retry", "rxjs/add/operator/mergeMap", "rxjs/add/operator/merge", "rxjs/add/operator/do", "./appdb/NotifyReducer", "./appdb/AppdbReducer", "./business/BusinessReducer", "./reseller/ResellerReducer", "./stations/StationsReducer", "./appdb/AppdbAction", "./comps/logo/LogoCompany", "rxjs/Rx", "angular2-google-maps/core"], function(exports_1, context_1) {
    "use strict";
    var __moduleName = context_1 && context_1.id;
    var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
        var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
        if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
        else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
        return c > 3 && r && Object.defineProperty(target, key, r), r;
    };
    var __metadata = (this && this.__metadata) || function (k, v) {
        if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
    };
    var router_1, platform_browser_dynamic_1, core_1, platform, StyleService_1, AppInjService_1, LocalStorage_1, AuthService_1, StoreService_1, BusinessAction_1, ResellerAction_1, OrdersAction_1, OrdersReducer_1, StationsAction_1, CharCount_1, http_1, App1_1, EntryPanel_1, AppManager_1, CommBroker_1, Filemenu_1, FilemenuItem_1, Logo_1, Footer_1, Conts_1, common_1, angular2_redux_util_1, Lib_1, CreditService_1, NotifyReducer_1, AppdbReducer_1, BusinessReducer_1, ResellerReducer_1, StationsReducer_1, AppdbAction_1, LogoCompany_1, Rx_1, core_2;
    var ServerMode, App, modules;
    return {
        setters:[
       ...

//# sourceMappingURL=App.js.map

rest of file is just my code... no other System.register([

@born2net
Copy link
Author

seems the bug was tracked down:

jakeNiemiec/jspmsandbox@9fd0f4b

@jakeNiemiec
Copy link
Contributor

From gitter:

It was unrelated, if you remove the line "loader": "plugin-typescript” it will build/bundle
The reason it worked was because packages was set with packages: {} later in the file

Ultimately, it seems like something is wrong between plugin-typescript and jspm-cli

//cc @frankwallis

@born2net
Copy link
Author

tx for clearing it out

@born2net
Copy link
Author

problem solved tx to @jakeNiemiec by changing the jspm.config.js.

"src": {
      "main": "App",
      "defaultExtension": "ts",
      "meta": {
        "*.js": {
          "loader": false
        },
        "*.ts": {
          "loader": "ts"
        },
        "*.css": {
          "loader": "css"
        }
      }
    },

so when using .js will not use a loader.

jakeNiemiec added a commit to jakeNiemiec/jspm-cli that referenced this issue May 31, 2016
- fixed the initialization of typescript projects by loading .ts files into plugin-typescipt instead of *.js files. This eventually resulted in the `err  Source StudioDashboard/App.js has multiple anonymous System.register calls.` error when trying to bundle or build (jspm#1859).

- If the user inputs a typescipt file for the main entry point the 'Select a transpiler' step will default to 'typescript' instead of 'babel'
jakeNiemiec added a commit to jakeNiemiec/jspm-cli that referenced this issue May 31, 2016
- fixed the initialization of typescript projects by loading .ts files into plugin-typescipt instead of *.js files. This eventually resulted in the `err  Source StudioDashboard/App.js has multiple anonymous System.register calls.` error when trying to bundle or build (jspm#1859).

- If the user inputs a typescipt file for the main entry point the 'Select a transpiler' step will default to 'typescript' instead of 'babel'
jakeNiemiec added a commit to jakeNiemiec/jspm-cli that referenced this issue May 31, 2016
- fixed the initialization of typescript projects by loading .ts files into plugin-typescipt instead of *.js files. This eventually resulted in the `err  Source StudioDashboard/App.js has multiple anonymous System.register calls.` error when trying to bundle or build (jspm#1859).

- If the user inputs a typescipt file for the main entry point the 'Select a transpiler' step will default to 'typescript' instead of 'babel'
jakeNiemiec added a commit to jakeNiemiec/jspm-cli that referenced this issue Jun 1, 2016
- fixed the initialization of typescript projects by loading .ts files into plugin-typescipt instead of *.js files. This eventually resulted in the `err  Source StudioDashboard/App.js has multiple anonymous System.register calls.` error when trying to bundle or build (jspm#1859).

- If the user inputs a typescipt file for the main entry point the 'Select a transpiler' step will default to 'typescript' instead of 'babel'
jakeNiemiec added a commit to jakeNiemiec/jspm-cli that referenced this issue Jun 1, 2016
- fixed the initialization of typescript projects by loading .ts files into plugin-typescipt instead of *.js files. This eventually resulted in the `err  Source StudioDashboard/App.js has multiple anonymous System.register calls.` error when trying to bundle or build (jspm#1859).

- If the user inputs a typescipt file for the main entry point the 'Select a transpiler' step will default to 'typescript' instead of 'babel'
guybedford added a commit that referenced this issue Jun 1, 2016
[0.17.0-beta-17] Fixed typescipt support for `jspm init` (fixes #1859)
guybedford pushed a commit that referenced this issue Jun 9, 2016
- fixed the initialization of typescript projects by loading .ts files into plugin-typescipt instead of *.js files. This eventually resulted in the `err  Source StudioDashboard/App.js has multiple anonymous System.register calls.` error when trying to bundle or build (#1859).

- If the user inputs a typescipt file for the main entry point the 'Select a transpiler' step will default to 'typescript' instead of 'babel'
guybedford pushed a commit that referenced this issue Jun 12, 2016
- fixed the initialization of typescript projects by loading .ts files into plugin-typescipt instead of *.js files. This eventually resulted in the `err  Source StudioDashboard/App.js has multiple anonymous System.register calls.` error when trying to bundle or build (#1859).

- If the user inputs a typescipt file for the main entry point the 'Select a transpiler' step will default to 'typescript' instead of 'babel'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants