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

Moment is not a function when using ES6 modules in bsconfig #31

Open
praveenperera opened this issue Oct 25, 2018 · 1 comment
Open

Comments

@praveenperera
Copy link

praveenperera commented Oct 25, 2018

When using es6 module "module": "es6" in bsconfig I get Moment is not a function.

But it works normally if I switch to "module": "commonjs"

Uncaught TypeError: Moment is not a function
    at NewObjective.bs.js:75
    at Object._1 (curry.js:69)
    at Object.render (ReasonReact.js:313)
    at finishClassComponent (react-dom.development.js:13538)
    at updateClassComponent (react-dom.development.js:13501)
    at beginWork (react-dom.development.js:14090)
    at performUnitOfWork (react-dom.development.js:16416)
    at workLoop (react-dom.development.js:16454)
    at HTMLUnknownElement.callCallback (react-dom.development.js:145)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:195)
@praveenperera praveenperera changed the title Moment is not a function when using module: es6 in bsconfig Moment is not a function when using ES6 modules in bsconfig Oct 25, 2018
@praveenperera
Copy link
Author

praveenperera commented Oct 25, 2018

Edit I had to change the bindings to use the default

include MomentRe;

[@bs.module "moment"]
external momentNow: unit => MomentRe.Moment.t = "default";

[@bs.module "moment"]
external momentDefaultFormat: string => MomentRe.Moment.t = "default";

[@bs.module "moment"]
external momentWithFormat: (string, string) => MomentRe.Moment.t = "default";

[@bs.module "moment"]
external momentWithDate: Js.Date.t => MomentRe.Moment.t = "default";

[@bs.module "moment"]
external momentWithFormats: (string, list(string)) => MomentRe.Moment.t =
  "default";

[@bs.module "moment"]
external momentWithTimestampMS: float => MomentRe.Moment.t = "default";

[@bs.module "moment"]
external momentWithComponents: list(int) => MomentRe.Moment.t = "default";

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

1 participant