use rollup to build dist out of es6 modules
ADD
.eslintignore
+/dist
+

MODIFY
.gitignore
.gitignore
@@ -59,3 +59,6 @@ typings/
# next.js build output
.next
+
+# dist
+dist/

MODIFY
package-lock.json
package-lock.json
"js-tokens": "^4.0.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.5",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-11.9.5.tgz",
+ "integrity": "sha512-vVjM0SVzgaOUpflq4GYBvCpozes8OgIIS5gVXVka+OfK3hvnkC1i93U8WiY2OtNE4XUWyyy/86Kf6e0IHTQw1Q==",
+ "dev": true
+ },
"acorn": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.0.tgz",
"integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==",
"dev": true
},
+ "esm": {
+ "version": "3.2.7",
+ "resolved": "https://registry.npmjs.org/esm/-/esm-3.2.7.tgz",
+ "integrity": "sha512-zsyD5gO8CY9dpK3IrdC4WHtvtHGXEFOpYA4zB+6p+Kygf3vv/6kF3YMEQLOArwKPPNvKt8gjI8UYhQW8bXM/YQ==",
+ "dev": true
+ },
"espree": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/espree/-/espree-5.0.1.tgz",
"glob": "^7.1.3"
}
},
+ "rollup": {
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.3.2.tgz",
+ "integrity": "sha512-xU6L5HqOY0sDeFxMTTs/GoYwcLiuKWfxxFWQTlwsZlQinQh1wfoxtDR4F3E2cHLS81nL9yl8LjZzuOWKd19smg==",
+ "dev": true,
+ "requires": {
+ "@types/estree": "0.0.39",
+ "@types/node": "^11.9.5",
+ "acorn": "^6.1.1"
+ },
+ "dependencies": {
+ "acorn": {
+ "version": "6.1.1",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz",
+ "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==",
+ "dev": true
+ }
+ }
+ },
"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/harden",
"version": "0.0.2",
"description": "Create a 'hardener' which freezes the API surface of a set of objects",
- "main": "src/index.js",
+ "main": "dist/harden.cjs.js",
+ "module": "dist/harden.esm.js",
+ "browser": "dist/harden.umd.js",
"scripts": {
- "test": "node test/test.js",
+ "test": "node -r esm test/test.js",
+ "build": "rollup -c",
"lint-fix": "eslint --fix '**/*.{js,jsx}'",
"lint-check": "eslint '**/*.{js,jsx}'"
},
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.12.4",
+ "esm": "^3.2.7",
"prettier": "1.16.4",
+ "rollup": "^1.3.2",
"tape": "^4.9.2"
},
"directories": {
"test": "test"
},
"keywords": [
- "integer",
- "int",
- "overflow"
+ "deepFreeze",
+ "harden",
+ "Object.freeze",
+ "freeze"
+ ],
+ "files": [
+ "dist"
]
}

ADD
rollup.config.js
+export default [
+ {
+ input: 'src/index.js',
+ output: [
+ {
+ file: 'dist/harden.umd.js',
+ format: 'umd',
+ name: 'Harden',
+ globals: {
+ '@agoric/make-hardener': 'makeHardener',
+ },
+ },
+ {
+ file: 'dist/harden.esm.js',
+ format: 'esm',
+ },
+ {
+ file: 'dist/harden.cjs.js',
+ format: 'cjs',
+ },
+ ],
+ external: ['@agoric/make-hardener'],
+ },
+];

MODIFY
src/anonIntrinsics.js
src/anonIntrinsics.js
@@ -284,4 +284,4 @@ function getAnonIntrinsics(global) {
return sampleAnonIntrinsics();
}
-module.exports = getAnonIntrinsics;
+export default getAnonIntrinsics;

MODIFY
src/buildTable.js
src/buildTable.js
// See the License for the specific language governing permissions and
// limitations under the License.
-const getAnonIntrinsics = require('./anonIntrinsics');
-const whitelist = require('./whitelist');
+import getAnonIntrinsics from './anonIntrinsics';
+import whitelist from './whitelist';
function buildTable(global) {
// walk global object, add whitelisted properties to table
@@ -139,4 +139,4 @@ function buildTable(global) {
return table;
}
-module.exports = buildTable;
+export default buildTable;

MODIFY
src/index.js
src/index.js
// See the License for the specific language governing permissions and
// limitations under the License.
-const makeHardener = require('@agoric/make-hardener');
-const buildTable = require('./buildTable');
+import makeHardener from '@agoric/make-hardener';
+import buildTable from './buildTable';
// this use of 'global' is why Harden is a "resource module", whereas
// MakeHardener is "pure".
@@ -23,4 +23,4 @@ const initialRoots = buildTable(global);
const harden = makeHardener(initialRoots);
-module.exports = harden;
+export default harden;

MODIFY
src/whitelist.js
src/whitelist.js
@@ -859,4 +859,4 @@ const whitelist = {
},
};
-module.exports = whitelist;
+export default whitelist;

MODIFY
test/test.js
test/test.js
/* eslint no-undef: "off" */
-const test = require('tape');
-const harden = require('../src/index.js');
+import test from 'tape';
+import harden from '../src/index';
test('harden', t => {
const o = { a: {} };

use rollup to build dist out of es6 modules