update bundle configs

This commit is contained in:
Yanzhen Yu
2018-10-11 16:46:34 +08:00
parent 40f29e5353
commit 215b2b319b
4 changed files with 31 additions and 3 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
node_modules
package-lock.json
build
dist

View File

@@ -4,7 +4,8 @@
"description": "record and replay the web",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"bundle": "rollup --config"
},
"repository": {
"type": "git",
@@ -20,6 +21,10 @@
},
"homepage": "https://github.com/rrweb-io/rrweb#readme",
"devDependencies": {
"rollup": "^0.66.6",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-typescript": "^1.0.0",
"tslib": "^1.9.3",
"tslint": "^4.5.1",
"typescript": "^3.1.1"
},

22
rollup.config.js Normal file
View File

@@ -0,0 +1,22 @@
import typescript from 'rollup-plugin-typescript';
import resolve from 'rollup-plugin-node-resolve';
export default {
input: './src/index.ts',
plugins: [typescript(), resolve()],
output: [
{
format: 'cjs',
file: './dist/index.js',
},
{
format: 'esm',
file: './dist/module.js',
},
{
name: 'rrweb',
format: 'iife',
file: './dist/browser.js',
},
],
};

View File

@@ -48,13 +48,13 @@ export function throttle<T>(
let args = arguments;
if (remaining <= 0 || remaining > wait) {
if (timeout) {
clearTimeout(timeout);
window.clearTimeout(timeout);
timeout = null;
}
previous = now;
func.apply(context, args);
} else if (!timeout && options.trailing !== false) {
timeout = setTimeout(() => {
timeout = window.setTimeout(() => {
previous = options.leading === false ? 0 : Date.now();
timeout = null;
func.apply(context, args);