Add other targets to rollup config. gitignore the /dist folder. Add the dist folder to `pkg.files` such that it is part of the tarball created by `npm pack`. Fix README and examples.
MODIFY
.gitignore
.gitignore
-node_modules
-yarn.lock
-yarn-error.log
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+
+# nyc test coverage
.nyc_output
+
+# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# TypeScript v1 declaration files
+typings/
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variables file
+.env
+
+# next.js build output
+.next
+
+# dist
+dist/

MODIFY
README.md
README.md
[![License][license-image]][license-url]
-This folder contains a shim implementation of the Realm API specified in this repo.
+This folder contains a shim implementation of the [Realm API Proposal](https://github.com/tc39/proposal-realms/#ecmascript-spec-proposal-for-realms-api).
## Limitations
@@ -19,8 +19,8 @@ The current implementation has 3 main limitations:
## Building the Shim
```bash
-git clone https://github.com/tc39/proposal-realms.git
-cd proposal-realms
+git clone https://github.com/Agoric/realms-shim.git
+cd realms-shim
npm install
npm run shim:build
```
@@ -29,15 +29,17 @@ This will install the necessary dependencies and build the shim locally.
## Playground
-To open the playground example in your default browser.
+To open the playground example in your default browser:
```bash
+npm run shim:build
open examples/simple.html
```
## Usage
-To use the shim in a webpage:
+To use the shim in a webpage, build the shim, then:
+
```html
<script src="../dist/realm-shim.min.js"></script>
<script>
@@ -53,7 +55,7 @@ To use the shim with node:
[...]
```
-To can also use es6 modules on node via package `esm`. To do that, launch node with esm via the "require" option:
+You can also use the ES6 module version of the Realms shim in Node.js via the package `esm`. To do that, launch node with esm via the "require" option:
```bash
npm install esm
@@ -101,13 +103,13 @@ r.global === this; // false
r.global.JSON === JSON; // true
```
-[travis-svg]: https://travis-ci.com/tc39/proposal-realms.svg?branch=master
-[travis-url]: https://travis-ci.com/tc39/proposal-realms
-[coveralls-svg]: https://coveralls.io/repos/github/tc39/proposal-realms/badge.svg
-[coveralls-url]: https://coveralls.io/github/tc39/proposal-realms
-[deps-svg]: https://david-dm.org/tc39/proposal-realms.svg
-[deps-url]: https://david-dm.org/tc39/proposal-realms
-[dev-deps-svg]: https://david-dm.org/tc39/proposal-realms/dev-status.svg
-[dev-deps-url]: https://david-dm.org/tc39/proposal-realms?type=dev
+[travis-svg]: https://travis-ci.com/Agoric/realms-shim.svg?branch=master
+[travis-url]: https://travis-ci.com/Agoric/realms-shim
+[coveralls-svg]: https://coveralls.io/repos/github/Agoric/realms-shim/badge.svg
+[coveralls-url]: https://coveralls.io/github/Agoric/realms-shim
+[deps-svg]: https://david-dm.org/Agoric/realms-shim.svg
+[deps-url]: https://david-dm.org/Agoric/realms-shim
+[dev-deps-svg]: https://david-dm.org/Agoric/realms-shim/dev-status.svg
+[dev-deps-url]: https://david-dm.org/Agoric/realms-shim?type=dev
[license-image]: https://img.shields.io/badge/License-Apache%202.0-blue.svg
[license-url]: LICENSE

MODIFY
examples/simple.html
examples/simple.html
<html>
<header>
- <script src="../dist/realm-shim.js"></script>
+ <script src="../dist/realms-shim.umd.js"></script>
</header>
<body>
<h1>Realm Shim</h1>

MODIFY
package.json
package.json
"name": "realms-shim",
"version": "1.0.0",
"description": "Spec-compliant shim for Realms TC39 Proposal",
- "main": "dist/realm-shim.js",
- "module": "src/main.js",
+ "main": "dist/realms-shim.cjs.js",
+ "module": "dist/realms-shim.esm.js",
+ "browser": "dist/realms-shim.umd.js",
"license": "Apache-2.0",
"author": {
"name": "TC39 Open Source Contributors"
"rollup-plugin-strip-code": "^0.2.6",
"sinon": "^7.2.7",
"tape": "^4.10.1"
- }
+ },
+ "files": [
+ "dist",
+ "LICENSE*"
+ ]
}

MODIFY
rollup.config.js
rollup.config.js
@@ -6,12 +6,24 @@ const isProduction = process.env.NODE_ENV === 'production';
export default {
input: path.resolve('src/main.js'),
- output: {
- file: path.resolve(isProduction ? 'dist/realm-shim.min.js' : 'dist/realm-shim.js'),
+ output: [
+ {
+ file: path.resolve(isProduction ? 'dist/realms-shim.umd.min.js' : 'dist/realms-shim.umd.js'),
name: 'Realm',
format: 'umd',
sourcemap: true
},
+ {
+ file: 'dist/realms-shim.esm.js',
+ format: 'esm',
+ sourcemap: true
+ },
+ {
+ file: 'dist/realms-shim.cjs.js',
+ format: 'cjs',
+ sourcemap: true
+ }
+ ],
plugins: [
stripCode({
start_comment: 'START_TESTS_ONLY',

Add other targets to rollup config. gitignore the /dist folder. Add the dist folder to `pkg.files` such that it is part of the tarball created by `npm pack`. Fix README and examples. (#1)