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

Support ES6 default named exports for Backbone-ES6 #194

Closed
wants to merge 2 commits into from
Closed

Support ES6 default named exports for Backbone-ES6 #194

wants to merge 2 commits into from

Conversation

typhonrt
Copy link

This subtle change takes into account how ES6 modules export default named modules and how they are consumed in the UMD loading code of Backbone.localStorage. backbone-es6 (https://github.com/typhonjs/backbone-es6) is a fork of Backbone using ES6. The ES6 module output export default backbone; found in ModuleRuntime.js (https://github.com/typhonjs/backbone-es6/blob/master/src/ModuleRuntime.js#L39) puts the actual reference under a default named key in the ES5 UMD loading code.

A complete TODOs demo using Backbone-ES6 and Backbone.localStorage can be found here:
http://js.demos.typhonrt.org/backbone-es6-localstorage-todos/

and repo of the demo:
https://github.com/typhonjs-demos/backbone-es6-localstorage-todos

The change in this PR adds a check for the existence of Backbone.default in the resolution of calling factory in the Backbone.localStorage UMD wrapper.

Michael Leahy and others added 2 commits November 20, 2015 06:50
This subtle change takes into account how ES6 modules export default values and how they are consumed in the UMD loading code of Backbone.localStorage. backbone-es6 (https://github.com/typhonjs/backbone-es6) is a fork of Backbone using ES6. The ES6 module output `export default backbone;` found in ModuleRuntime.js (https://github.com/typhonjs/backbone-es6/blob/master/src/ModuleRuntime.js#L39) puts the actual reference under a default key in the ES5 UMD loading code. 

The change above simply adds a check for the existence of `Backbone.default` in the resolution of calling `factory`.
@scott-w
Copy link
Collaborator

scott-w commented Feb 28, 2017

Hi @typhonrt, thanks for this, however I'm going to close it in favour of #207

@scott-w scott-w closed this Feb 28, 2017
@typhonrt
Copy link
Author

typhonrt commented Mar 1, 2017

Oh no worries.. Sounds good. At the time I didn't know what I do now. Back then I just rewrote local storage in ES6; I see #207 does this... Now I just use babel-plugin-add-module-exports with my ES6 modules especially everything released on NPM.

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

Successfully merging this pull request may close these issues.

2 participants