Skip to content

Commit

Permalink
Bundles (rrweb-io#199)
Browse files Browse the repository at this point in the history
* provide more bundle outputs

* update commonJS and es module entry to boot file
  • Loading branch information
Yuyz0112 authored Apr 15, 2020
1 parent 877e2ce commit 7a0fbae
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"keywords": [
"rrweb"
],
"main": "lib/rrweb.js",
"module": "es/rrweb/src/index.js",
"main": "lib/rrweb-boost.js",
"module": "es/rrweb/src/boost.js",
"unpkg": "dist/rrweb.js",
"sideEffects": false,
"typings": "typings/index.d.ts",
Expand Down
25 changes: 25 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ function toPackPath(path) {
.replace('rrweb', 'rrweb-pack');
}

function toPackerPath(path) {
return path
.replace(/^([\w]+)\//, '$1/packer/')
.replace('rrweb', 'rrweb-packer');
}

function toBoostPath(path) {
return path.replace('rrweb', 'rrweb-boost');
}

function toMinPath(path) {
return path.replace(/\.js$/, '.min.js');
}
Expand All @@ -28,21 +38,36 @@ const namedExports = {
};

const baseConfigs = [
// record only
{
input: './src/record/index.ts',
name: 'rrwebRecord',
pathFn: toRecordPath,
},
// pack only
{
input: './src/packer/pack.ts',
name: 'rrwebPack',
pathFn: toPackPath,
},
// packer only
{
input: './src/packer/index.ts',
name: 'rrwebPacker',
pathFn: toPackerPath,
},
// record and replay
{
input: './src/index.ts',
name: 'rrweb',
pathFn: (p) => p,
},
// all in one
{
input: './src/boost.ts',
name: 'rrwebBoost',
pathFn: toBoostPath,
},
];

let configs = [];
Expand Down
2 changes: 2 additions & 0 deletions src/boost.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './index';
export * from './packer';
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export {
MouseInteractions,
ReplayerEvents,
} from './types';
export { pack, unpack } from './packer';

const { addCustomEvent } = record;

Expand Down

0 comments on commit 7a0fbae

Please sign in to comment.