Skip to content

Commit

Permalink
Convert package to esm, fix jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
denis-ok committed Nov 8, 2023
1 parent e2a44d4 commit d254fbb
Show file tree
Hide file tree
Showing 6 changed files with 797 additions and 2,152 deletions.
7 changes: 5 additions & 2 deletions dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
;; we start by ignoring node_modules. if you need to consume an OCaml
;; we start by ignoring node_modules. if you need to consume an OCaml
;; project from `node_modules`, this should work:
;; - remove the `dirs` stanza below
;; - add a `(subdir node_modules (dirs only_your_package))`
Expand All @@ -10,4 +10,7 @@
(deps
(alias_rec test))
(action
(run npx jest)))
(setenv
NODE_OPTIONS
--experimental-vm-modules
(run npx jest))))
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
export default {
rootDir: "./_build/default/",
testMatch: ["**/*_test.js"],
};

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "module",
"devDependencies": {
"jest": "^26.0.1",
"@testing-library/jest-dom": "^5.10.0",
"jest": "^29.7.0",
"moment": "^2.26.0"
}
}
10 changes: 5 additions & 5 deletions src/MomentRe.re
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Duration = {
"as";
};

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external duration:
(
float,
Expand All @@ -56,10 +56,10 @@ external duration:
Duration.t =
"duration";

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external durationMillis: float => Duration.t = "duration";

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external durationFormat: string => Duration.t = "duration";

module Moment = {
Expand Down Expand Up @@ -324,10 +324,10 @@ external momentWithFormats: (string, array(string)) => Moment.t = "default";

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

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external momentUtcWithFormats: (string, array(string)) => Moment.t = "utc";

[@mel.module "moment"]
[@mel.module "moment"] [@mel.scope "default"]
external momentUtcDefaultFormat: string => Moment.t = "utc";

let momentWithUnix = (timestamp: int) =>
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
(target test)
(alias test)
(libraries melange-moment melange-jest.jest)
(module_systems es6)
(preprocess
(pps melange.ppx)))
Loading

0 comments on commit d254fbb

Please sign in to comment.