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

Build tooling: Singletons across bundles #5453

Closed
flashbackzoo opened this issue May 4, 2016 · 1 comment
Closed

Build tooling: Singletons across bundles #5453

flashbackzoo opened this issue May 4, 2016 · 1 comment

Comments

@flashbackzoo
Copy link
Contributor

We're currently assigning instances we wish to use as singletons to the ss namespace.
This is because singletons (exported by ES6 modules) only work within the context of a
single Browserify bundle.

For context this is what I mean by an ES6 singleton.

singleton.js

class Singleton {
  ...
}

const singleton = new Singleton();

export default singleton;

Let's assume the lib bundle exposes singleton so other bundles can require it, as an external, at runtime. If the framework bundle imports the external singleton dependency, then all modules in the framework bundle will have access the same copy of singleton if they import it.

Likewise if the custom bundle imports singleton as an external dependency, all modules in
custom will get the same copy of singleton.

This works as expected within the context of one bundle but does not work across bundles. The copy of singleton that framework gets is not the same copy of singleton that custom gets.

Possible solutions:

@tractorcow
Copy link
Contributor

tractorcow commented May 16, 2016

@chillu do you understand this issue? I'd need to invest a bit more time before I could hope to address this. :)

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