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

Add global jsonrpc ref for umd bundle and fix webpack warning #17

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,20 @@ test.js

npm-debug.log
.DS_Store
.esm-cache
.esm-cache

# Bundle
target

# Typescript
*.tsbuildinfo
.tsbuildinfo
buildcache
.buildcache
.rts2_cache_cjs
.rts2_cache_es
.rts2_cache_umd

# Yarn
yarn.lock
yarn-error.log
16 changes: 15 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
language: node_js
sudo: false

node_js:
- "6"
- "8"
- "10"
sudo: false
- "12"
- "13"

cache:
directories:
- node_modules

before_install:
- sudo apt-get install moreutils

install:
- yarn install
- yarn build

script:
- yarn test
26 changes: 26 additions & 0 deletions browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Browser AMD Polyfill
(function (cxt) {
const window = cxt.window
if (typeof window !== 'undefined') {
if (window.define) {
return
}
window.define = function(name, required, moduleFn) {
if (typeof name !== 'string') {
return window.define('anonymous' + Math.random(), name, required)
}
var modules = window.define.modules
var require = function() { throw new Error("AMD require not supported!")}
var exports = modules[name] = {}
var resolved = [require, exports]
for (var i = 2; i < required.length; i++) {
var m = modules[required[i]]
if (!m) throw new Error("AMD module `" + required[i] + "` not found!")
resolved.push(m)
}
moduleFn.apply(null, resolved)
}
window.define.modules = {}
window.define.amd = true
}
})(this)
2 changes: 1 addition & 1 deletion example/jsonrpc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

const jsonrpc = require('../jsonrpc');
const jsonrpc = require('../target/umd/jsonrpc');

const requestObj = jsonrpc.request('123', 'update', {list: [1, 2, 3]});
const notificationObj = jsonrpc.notification('update', {list: [1, 2, 3]})
Expand Down
203 changes: 0 additions & 203 deletions jsonrpc.d.ts

This file was deleted.

Loading