Skip to content

Add es6 module#46

Open
kristinn93 wants to merge 1 commit intojimexist:masterfrom
getsling:include-es6-bindings
Open

Add es6 module#46
kristinn93 wants to merge 1 commit intojimexist:masterfrom
getsling:include-es6-bindings

Conversation

@kristinn93
Copy link
Copy Markdown
Contributor

Currently I'm maintaining my own fork of these bindings since I use es6 in all of my projects.

// bsconfig.json
...
  "package-specs": {
    "module": "es6",
    "in-source": true
  },
...

A lot of the changes are refmt changes, but in line 312 I added a ES6 module.
This is backwards compatible and won't affect anyone.

This allows people who have es6 setup to instantiate a Moment object like this:

MomentRe.ES6.momentNow()

because

MomentRe.momentNow()

crashes my bundler

@TravisBuddy
Copy link
Copy Markdown

Hey @kristinn93,
Your changes look good to me!

View build log

TravisBuddy Request Identifier: 07013380-65c6-11e9-aafa-87f824428b00

@mlms13
Copy link
Copy Markdown

mlms13 commented Apr 23, 2019

This probably affects (and hopefully resolves?) #31.

@kristinn93
Copy link
Copy Markdown
Contributor Author

kristinn93 commented Apr 24, 2019

@mlms13 Yes this will solve that. I had the same issue.

By doing this

Js.log2("moment", MomentRe.momentNow());

The following code is generated:

import * as Moment from "moment";
console.log("moment", Moment());

@kristinn93
Copy link
Copy Markdown
Contributor Author

Also if you were wondering it's not possible to use the ES6 module with a commonjs project.
I setup a small commonjs project and by using the ES6 module I got moment.default is not a function

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