continue #199: redesign the bundled file structure
According to @eoghanmurray's suggestion, we can support three main scenarios: 1. record only 2. replay only 3. all in one Since we have implemented the packer feature, which has a big influence in bundle size, we provide another three bundles: 1. record and pack 2. replay and unpack 3. all in one with pack and unpack
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
"keywords": [
|
||||
"rrweb"
|
||||
],
|
||||
"main": "lib/rrweb-boost.js",
|
||||
"module": "es/rrweb/src/boost.js",
|
||||
"main": "lib/rrweb-all.js",
|
||||
"module": "es/rrweb/entries/all.js",
|
||||
"unpkg": "dist/rrweb.js",
|
||||
"sideEffects": false,
|
||||
"typings": "typings/index.d.ts",
|
||||
|
||||
@@ -11,20 +11,26 @@ function toRecordPath(path) {
|
||||
.replace('rrweb', 'rrweb-record');
|
||||
}
|
||||
|
||||
function toPackPath(path) {
|
||||
function toRecordPackPath(path) {
|
||||
return path
|
||||
.replace(/^([\w]+)\//, '$1/packer/')
|
||||
.replace('rrweb', 'rrweb-pack');
|
||||
.replace(/^([\w]+)\//, '$1/record/')
|
||||
.replace('rrweb', 'rrweb-record-pack');
|
||||
}
|
||||
|
||||
function toPackerPath(path) {
|
||||
function toReplayPath(path) {
|
||||
return path
|
||||
.replace(/^([\w]+)\//, '$1/packer/')
|
||||
.replace('rrweb', 'rrweb-packer');
|
||||
.replace(/^([\w]+)\//, '$1/replay/')
|
||||
.replace('rrweb', 'rrweb-replay');
|
||||
}
|
||||
|
||||
function toBoostPath(path) {
|
||||
return path.replace('rrweb', 'rrweb-boost');
|
||||
function toReplayUnpackPath(path) {
|
||||
return path
|
||||
.replace(/^([\w]+)\//, '$1/replay/')
|
||||
.replace('rrweb', 'rrweb-replay-unpack');
|
||||
}
|
||||
|
||||
function toAllPath(path) {
|
||||
return path.replace('rrweb', 'rrweb-all');
|
||||
}
|
||||
|
||||
function toMinPath(path) {
|
||||
@@ -44,17 +50,23 @@ const baseConfigs = [
|
||||
name: 'rrwebRecord',
|
||||
pathFn: toRecordPath,
|
||||
},
|
||||
// pack only
|
||||
// record and pack
|
||||
{
|
||||
input: './src/packer/pack.ts',
|
||||
name: 'rrwebPack',
|
||||
pathFn: toPackPath,
|
||||
input: './src/entries/record-pack.ts',
|
||||
name: 'rrwebRecord',
|
||||
pathFn: toRecordPackPath,
|
||||
},
|
||||
// packer only
|
||||
// replay only
|
||||
{
|
||||
input: './src/packer/index.ts',
|
||||
name: 'rrwebPacker',
|
||||
pathFn: toPackerPath,
|
||||
input: './src/replay/index.ts',
|
||||
name: 'rrwebReplay',
|
||||
pathFn: toReplayPath,
|
||||
},
|
||||
// replay and unpack
|
||||
{
|
||||
input: './src/entries/replay-unpack.ts',
|
||||
name: 'rrwebReplay',
|
||||
pathFn: toReplayUnpackPath,
|
||||
},
|
||||
// record and replay
|
||||
{
|
||||
@@ -64,9 +76,9 @@ const baseConfigs = [
|
||||
},
|
||||
// all in one
|
||||
{
|
||||
input: './src/boost.ts',
|
||||
name: 'rrwebBoost',
|
||||
pathFn: toBoostPath,
|
||||
input: './src/entries/all.ts',
|
||||
name: 'rrweb',
|
||||
pathFn: toAllPath,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -119,7 +131,7 @@ for (const c of baseConfigs) {
|
||||
output: [
|
||||
{
|
||||
format: 'cjs',
|
||||
file: c.pathFn(pkg.main),
|
||||
file: c.pathFn('lib/rrweb.js'),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from './index';
|
||||
export * from './packer';
|
||||
2
src/entries/all.ts
Normal file
2
src/entries/all.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from '../index';
|
||||
export * from '../packer';
|
||||
2
src/entries/record-pack.ts
Normal file
2
src/entries/record-pack.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from '../record/index';
|
||||
export * from '../packer/pack';
|
||||
2
src/entries/replay-unpack.ts
Normal file
2
src/entries/replay-unpack.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from '../replay';
|
||||
export * from '../packer/unpack';
|
||||
Reference in New Issue
Block a user