Update rollup
With rollup's preserveModules option and the sideEffects flag in package.json, now we have the power of tree shaking.
This commit is contained in:
@@ -18,8 +18,9 @@
|
|||||||
"rrweb"
|
"rrweb"
|
||||||
],
|
],
|
||||||
"main": "lib/rrweb.js",
|
"main": "lib/rrweb.js",
|
||||||
"module": "es/rrweb.js",
|
"module": "es/rrweb/src/index.js",
|
||||||
"unpkg": "dist/rrweb.js",
|
"unpkg": "dist/rrweb.js",
|
||||||
|
"sideEffects": false,
|
||||||
"typings": "typings/index.d.ts",
|
"typings": "typings/index.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
"dist",
|
"dist",
|
||||||
@@ -45,7 +46,7 @@
|
|||||||
"jest-snapshot": "^23.6.0",
|
"jest-snapshot": "^23.6.0",
|
||||||
"mocha": "^5.2.0",
|
"mocha": "^5.2.0",
|
||||||
"puppeteer": "^1.11.0",
|
"puppeteer": "^1.11.0",
|
||||||
"rollup": "^0.66.6",
|
"rollup": "^2.3.3",
|
||||||
"rollup-plugin-commonjs": "^9.2.0",
|
"rollup-plugin-commonjs": "^9.2.0",
|
||||||
"rollup-plugin-node-resolve": "^3.4.0",
|
"rollup-plugin-node-resolve": "^3.4.0",
|
||||||
"rollup-plugin-postcss": "^1.6.2",
|
"rollup-plugin-postcss": "^1.6.2",
|
||||||
|
|||||||
@@ -98,22 +98,11 @@ for (const c of baseConfigs) {
|
|||||||
configs.push({
|
configs.push({
|
||||||
input: c.input,
|
input: c.input,
|
||||||
plugins,
|
plugins,
|
||||||
|
preserveModules: true,
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
file: c.pathFn(pkg.module),
|
dir: 'es/rrweb',
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
// ES module + minify
|
|
||||||
configs.push({
|
|
||||||
input: c.input,
|
|
||||||
plugins: minifyPlugins,
|
|
||||||
output: [
|
|
||||||
{
|
|
||||||
format: 'esm',
|
|
||||||
file: toMinPath(c.pathFn(pkg.module)),
|
|
||||||
sourcemap: true,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import * as path from 'path';
|
|||||||
import * as puppeteer from 'puppeteer';
|
import * as puppeteer from 'puppeteer';
|
||||||
import { assertSnapshot, launchPuppeteer } from './utils';
|
import { assertSnapshot, launchPuppeteer } from './utils';
|
||||||
import { Suite } from 'mocha';
|
import { Suite } from 'mocha';
|
||||||
import { recordOptions } from '../src/types';
|
import { recordOptions, eventWithTime } from '../src/types';
|
||||||
|
|
||||||
interface ISuite extends Suite {
|
interface ISuite extends Suite {
|
||||||
code: string;
|
code: string;
|
||||||
@@ -13,7 +13,10 @@ interface ISuite extends Suite {
|
|||||||
describe('record integration tests', function (this: ISuite) {
|
describe('record integration tests', function (this: ISuite) {
|
||||||
this.timeout(10_000);
|
this.timeout(10_000);
|
||||||
|
|
||||||
const getHtml = (fileName: string, options: recordOptions = {}): string => {
|
const getHtml = (
|
||||||
|
fileName: string,
|
||||||
|
options: recordOptions<eventWithTime> = {},
|
||||||
|
): string => {
|
||||||
const filePath = path.resolve(__dirname, `./html/${fileName}`);
|
const filePath = path.resolve(__dirname, `./html/${fileName}`);
|
||||||
const html = fs.readFileSync(filePath, 'utf8');
|
const html = fs.readFileSync(filePath, 'utf8');
|
||||||
return html.replace(
|
return html.replace(
|
||||||
|
|||||||
@@ -24,7 +24,9 @@ interface ISuite extends Suite {
|
|||||||
|
|
||||||
interface IWindow extends Window {
|
interface IWindow extends Window {
|
||||||
rrweb: {
|
rrweb: {
|
||||||
record: (options: recordOptions) => listenerHandler | undefined;
|
record: (
|
||||||
|
options: recordOptions<eventWithTime>,
|
||||||
|
) => listenerHandler | undefined;
|
||||||
addCustomEvent<T>(tag: string, payload: T): void;
|
addCustomEvent<T>(tag: string, payload: T): void;
|
||||||
};
|
};
|
||||||
emit: (e: eventWithTime) => undefined;
|
emit: (e: eventWithTime) => undefined;
|
||||||
@@ -58,7 +60,7 @@ describe('record', function(this: ISuite) {
|
|||||||
this.events.push(e);
|
this.events.push(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
page.on('console', msg => console.log('PAGE LOG:', msg.text()));
|
page.on('console', (msg) => console.log('PAGE LOG:', msg.text()));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
@@ -223,14 +225,14 @@ describe('record', function(this: ISuite) {
|
|||||||
});
|
});
|
||||||
await this.page.waitFor(10);
|
await this.page.waitFor(10);
|
||||||
const styleSheetRuleEvents = this.events.filter(
|
const styleSheetRuleEvents = this.events.filter(
|
||||||
e =>
|
(e) =>
|
||||||
e.type === EventType.IncrementalSnapshot &&
|
e.type === EventType.IncrementalSnapshot &&
|
||||||
e.data.source === IncrementalSource.StyleSheetRule,
|
e.data.source === IncrementalSource.StyleSheetRule,
|
||||||
);
|
);
|
||||||
const addRuleCount = styleSheetRuleEvents.filter(e =>
|
const addRuleCount = styleSheetRuleEvents.filter((e) =>
|
||||||
Boolean((e.data as styleSheetRuleData).adds),
|
Boolean((e.data as styleSheetRuleData).adds),
|
||||||
).length;
|
).length;
|
||||||
const removeRuleCount = styleSheetRuleEvents.filter(e =>
|
const removeRuleCount = styleSheetRuleEvents.filter((e) =>
|
||||||
Boolean((e.data as styleSheetRuleData).removes),
|
Boolean((e.data as styleSheetRuleData).removes),
|
||||||
).length;
|
).length;
|
||||||
// sync insert/delete should be ignored
|
// sync insert/delete should be ignored
|
||||||
|
|||||||
Reference in New Issue
Block a user