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

Add better interop for importing modules with default exports #803

Merged
merged 1 commit into from
Aug 15, 2017
Merged

Add better interop for importing modules with default exports #803

merged 1 commit into from
Aug 15, 2017

Conversation

DylanPiercey
Copy link
Contributor

Description

Currently when using the import tag to import es6 modules with default exports you instead get the entire exports object like { default: ..., }.

This change checks to see if the default export is set and tries to use it if possible like so:

import myThing from './myfile.js'

becomes

var module_myThing = require('./myfile.js')
var myThing = module_myThing.default || module_myThing

Motivation and Context

Resolves #802.
Currently users have to manually access the default export which is not in line with the modules spec.

Checklist:

  • My code follows the code style of this project.
  • I have updated/added documentation affected by my changes.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@coveralls
Copy link

coveralls commented Aug 15, 2017

Coverage Status

Coverage increased (+0.002%) to 89.615% when pulling 472bf3b on DylanPiercey:import-default-interop into 76eaaf9 on marko-js:master.

Copy link
Member

@austinkelleher austinkelleher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice changes. Looks good to me. I will let @mlrawlings and at @patrick-steele-idem review as well.

@mlrawlings mlrawlings merged commit f37c622 into marko-js:master Aug 15, 2017
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.

4 participants