Monday, March 28, 2016

How can I namespace a SystemJS bundle

Leave a Comment

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?

1 Answers

Answers 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.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment