* provide more bundle outputs

* update commonJS and es module entry to boot file
This commit is contained in:
yz-yu
2020-04-15 22:54:12 +08:00
committed by GitHub
parent 877e2ce958
commit 7a0fbaecd5
4 changed files with 29 additions and 3 deletions

View File

@@ -17,8 +17,8 @@
"keywords": [ "keywords": [
"rrweb" "rrweb"
], ],
"main": "lib/rrweb.js", "main": "lib/rrweb-boost.js",
"module": "es/rrweb/src/index.js", "module": "es/rrweb/src/boost.js",
"unpkg": "dist/rrweb.js", "unpkg": "dist/rrweb.js",
"sideEffects": false, "sideEffects": false,
"typings": "typings/index.d.ts", "typings": "typings/index.d.ts",

View File

@@ -17,6 +17,16 @@ function toPackPath(path) {
.replace('rrweb', 'rrweb-pack'); .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) { function toMinPath(path) {
return path.replace(/\.js$/, '.min.js'); return path.replace(/\.js$/, '.min.js');
} }
@@ -28,21 +38,36 @@ const namedExports = {
}; };
const baseConfigs = [ const baseConfigs = [
// record only
{ {
input: './src/record/index.ts', input: './src/record/index.ts',
name: 'rrwebRecord', name: 'rrwebRecord',
pathFn: toRecordPath, pathFn: toRecordPath,
}, },
// pack only
{ {
input: './src/packer/pack.ts', input: './src/packer/pack.ts',
name: 'rrwebPack', name: 'rrwebPack',
pathFn: toPackPath, pathFn: toPackPath,
}, },
// packer only
{
input: './src/packer/index.ts',
name: 'rrwebPacker',
pathFn: toPackerPath,
},
// record and replay
{ {
input: './src/index.ts', input: './src/index.ts',
name: 'rrweb', name: 'rrweb',
pathFn: (p) => p, pathFn: (p) => p,
}, },
// all in one
{
input: './src/boost.ts',
name: 'rrwebBoost',
pathFn: toBoostPath,
},
]; ];
let configs = []; let configs = [];

2
src/boost.ts Normal file
View File

@@ -0,0 +1,2 @@
export * from './index';
export * from './packer';

View File

@@ -8,7 +8,6 @@ export {
MouseInteractions, MouseInteractions,
ReplayerEvents, ReplayerEvents,
} from './types'; } from './types';
export { pack, unpack } from './packer';
const { addCustomEvent } = record; const { addCustomEvent } = record;