change index.js to use es6 modules. Use rollup to generate an index.js
ADD
index-commonjs.js
+'use strict';
+
+// Copyright (C) 2011 Google Inc.
+// Copyright (C) 2018 Agoric
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * Is allegedNum a number in the contiguous range of exactly and
+ * unambiguously representable natural numbers (non-negative integers)?
+ *
+ * <p>See <a href=
+ * "https://code.google.com/p/google-caja/issues/detail?id=1801"
+ * >Issue 1801: Nat must include at most (2**53)-1</a>
+ * and <a href=
+ * "https://mail.mozilla.org/pipermail/es-discuss/2013-July/031716.html"
+ * >Allen Wirfs-Brock's suggested phrasing</a> on es-discuss.
+ */
+
+function Nat(allegedNum) {
+ if (!Number.isSafeInteger(allegedNum)) {
+ throw new RangeError('not a safe integer');
+ }
+
+ if (allegedNum < 0) {
+ throw new RangeError('negative');
+ }
+
+ return allegedNum;
+}
+
+module.exports = Nat;

MODIFY
index.js
index.js
@@ -37,4 +37,4 @@ function Nat(allegedNum) {
return allegedNum;
}
-module.exports = { Nat };
+export default Nat;

MODIFY
package-lock.json
package-lock.json
"any-observable": "^0.3.0"
}
},
+ "@types/estree": {
+ "version": "0.0.39",
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
+ "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
+ "dev": true
+ },
+ "@types/node": {
+ "version": "11.9.1",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-11.9.1.tgz",
+ "integrity": "sha512-XJHvu7fvycZ7ORTyThXiKCtld+R4Y1GGerYRrVSf/GhaNahRBIf/Nx+7Xh3AvI5nudOVt/L671CxHGkJt1/+hQ==",
+ "dev": true
+ },
"acorn": {
"version": "6.0.7",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.7.tgz",
"glob": "^7.1.3"
}
},
+ "rollup": {
+ "version": "1.1.2",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.1.2.tgz",
+ "integrity": "sha512-OkdMxqMl8pWoQc5D8y1cIinYQPPLV8ZkfLgCzL6SytXeNA2P7UHynEQXI9tYxuAjAMsSyvRaWnyJDLHMxq0XAg==",
+ "dev": true,
+ "requires": {
+ "@types/estree": "0.0.39",
+ "@types/node": "*",
+ "acorn": "^6.0.5"
+ }
+ },
"run-async": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz",

MODIFY
package.json
package.json
"name": "@agoric/nat",
"version": "1.0.1",
"description": "Ensures that a number is within the natural numbers (0, 1, 2...) or throws a RangeError",
- "main": "index.js",
+ "main": "index-commonjs.js",
+ "module": "index.js",
"scripts": {
"test": "node test/test.js",
"format": "prettier --write '**/*.{js,jsx}'",
- "lint": "eslint '**/*.{js,jsx}'"
+ "lint": "eslint '**/*.{js,jsx}'",
+ "create-cjs": "rollup index.js --file index-commonjs.js --format cjs"
},
"repository": {
"type": "git",
"husky": "^1.3.1",
"lint-staged": "^8.1.3",
"prettier": "1.16.4",
+ "rollup": "^1.1.2",
"tape": "^4.9.2"
},
"lint-staged": {

change index.js to use es6 modules. Use rollup to generate an index.js