15

I am building a bundle using the SystemJS builder that I'd like to include in another project. The problem I'm running into is that bundle A and bundle B might both contain a 'main' module, and when I bundle them and include them in another project, they collide and everything breaks.

Does SystemJS builder have a better way of namespacing? Or from preventing bundled modules from being exported at all? Or is there another tool I should be using?

Khaled Awad
  • 1,644
  • 11
  • 24
Matthew James Davis
  • 12,134
  • 7
  • 61
  • 90
  • 2
    I would think that's a clue there's a design issue. In my opinion, bundles that aren't "app bundles" should not have main module, and app bundles should not be co-loaded with each other. – Jared Farrish Mar 20 '16 at 00:49
  • 5
    main was an example dude, its possible to have other name collisions. – Matthew James Davis Mar 21 '16 at 19:37
  • Shouldn't `a/main` and `b/main` already be different modules? Unless you are using global module identifiers, this shouldn't be a problem. – Bergi Mar 21 '16 at 21:27
  • 1
    they are being developed separately. module a is a project and module b is a project, and they are built and included in the parent app. so when i build and include them using system js, both modulea.built.js and moduleb.built.js have things like `system.register("main")` – Matthew James Davis Mar 22 '16 at 00:54

1 Answers1

1

SystemJS does not have an easy way to do what you want.

You could import the module by path instead of by name.

import x1 from "folder1/x.js"
import x2 from "folder2/x.js"

You could also try to have two instances of SystemJS.

https://stackoverflow.com/a/30954312/6101582

https://github.com/systemjs/systemjs/issues/982

You could also rename the modules.