upgrade rollup and rollup plugins

This commit is contained in:
Yanzhen Yu
2021-10-06 12:13:55 +08:00
parent 333ba18239
commit 2afd4a27e6
14 changed files with 93 additions and 224 deletions

View File

@@ -40,6 +40,7 @@
},
"homepage": "https://github.com/rrweb-io/rrweb#readme",
"devDependencies": {
"@rollup/plugin-typescript": "^8.2.5",
"@types/chai": "^4.1.6",
"@types/inquirer": "0.0.43",
"@types/jsdom": "^16.2.12",
@@ -58,13 +59,11 @@
"mocha": "^5.2.0",
"prettier": "2.2.1",
"puppeteer": "^9.1.1",
"rollup": "^2.3.3",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup": "^2.45.2",
"@rollup/plugin-node-resolve": "^7.0.0",
"rollup-plugin-postcss": "^3.1.1",
"rollup-plugin-rename-node-modules": "^1.1.0",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-typescript": "^1.0.0",
"rollup-plugin-terser": "^7.0.2",
"ts-node": "^7.0.1",
"tslib": "^1.9.3",
"tslint": "^4.5.1",

View File

@@ -1,9 +1,10 @@
import typescript from 'rollup-plugin-typescript';
import resolve from 'rollup-plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import renameNodeModules from 'rollup-plugin-rename-node-modules';
import pkg from './package.json';
const tsConfig = require('./tsconfig.json');
function toRecordPath(path) {
return path
@@ -46,35 +47,35 @@ function toMinPath(path) {
const baseConfigs = [
// record only
{
input: './src/record/index.ts',
name: 'rrwebRecord',
pathFn: toRecordPath,
},
// record and pack
{
input: './src/entries/record-pack.ts',
name: 'rrwebRecord',
pathFn: toRecordPackPath,
},
// replay only
{
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
{
input: './src/index.ts',
name: 'rrweb',
pathFn: (p) => p,
},
// {
// input: './src/record/index.ts',
// name: 'rrwebRecord',
// pathFn: toRecordPath,
// },
// // record and pack
// {
// input: './src/entries/record-pack.ts',
// name: 'rrwebRecord',
// pathFn: toRecordPackPath,
// },
// // replay only
// {
// 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
// {
// input: './src/index.ts',
// name: 'rrweb',
// pathFn: (p) => p,
// },
// all in one
{
input: './src/entries/all.ts',
@@ -83,22 +84,28 @@ const baseConfigs = [
esm: true,
},
// plugins
{
input: './src/plugins/console/record/index.ts',
name: 'rrwebConsoleRecord',
pathFn: toPluginPath('console', 'record'),
},
{
input: './src/plugins/console/replay/index.ts',
name: 'rrwebConsoleReplay',
pathFn: toPluginPath('console', 'replay'),
},
// {
// input: './src/plugins/console/record/index.ts',
// name: 'rrwebConsoleRecord',
// pathFn: toPluginPath('console', 'record'),
// },
// {
// input: './src/plugins/console/replay/index.ts',
// name: 'rrwebConsoleReplay',
// pathFn: toPluginPath('console', 'replay'),
// },
];
let configs = [];
for (const c of baseConfigs) {
const basePlugins = [resolve({ browser: true }), typescript()];
const basePlugins = [
resolve({ browser: true }),
typescript({
// a trick to avoid @rollup/plugin-typescript error
outDir: 'es/rrweb',
}),
];
const plugins = basePlugins.concat(
postcss({
extract: false,
@@ -184,7 +191,9 @@ if (process.env.BROWSER_ONLY) {
for (const c of browserOnlyBaseConfigs) {
const plugins = [
resolve({ browser: true }),
typescript(),
typescript({
outDir: null,
}),
postcss({
extract: false,
inject: false,

View File

@@ -1,18 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"module": "ESNext",
"moduleResolution": "Node",
"target": "ES5",
"noImplicitAny": true,
"strictNullChecks": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"rootDir": "src",
"outDir": "build",
"lib": ["es6", "dom"],
"downlevelIteration": true
},
"compileOnSave": true,
"exclude": ["test"],
"include": [
"src",

View File

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

View File

@@ -8,7 +8,7 @@ declare type LogRecordOptions = {
level?: LogLevel[];
lengthThreshold?: number;
stringifyOptions?: StringifyOptions;
logger?: Logger | string;
logger?: Logger | 'console';
};
export declare type LogData = {
level: LogLevel;

View File

@@ -1,4 +0,0 @@
import { removedNodeMutation } from '../types';
export declare function deepDelete(addsSet: Set<Node>, n: Node): void;
export declare function isParentRemoved(removes: removedNodeMutation[], n: Node): boolean;
export declare function isAncestorInSet(set: Set<Node>, n: Node): boolean;

View File

@@ -1,37 +0,0 @@
export declare class StackFrame {
private fileName;
private functionName;
private lineNumber?;
private columnNumber?;
constructor(obj: {
fileName?: string;
functionName?: string;
lineNumber?: number;
columnNumber?: number;
});
toString(): string;
}
export declare const ErrorStackParser: {
parse: (error: Error) => StackFrame[];
extractLocation: (urlLike: string) => (string | undefined)[];
parseV8OrIE: (error: {
stack: string;
}) => StackFrame[];
parseFFOrSafari: (error: {
stack: string;
}) => StackFrame[];
parseOpera: (e: {
stacktrace?: string;
message: string;
stack?: string;
}) => StackFrame[];
parseOpera9: (e: {
message: string;
}) => StackFrame[];
parseOpera10: (e: {
stacktrace: string;
}) => StackFrame[];
parseOpera11: (error: {
stack: string;
}) => StackFrame[];
};

View File

@@ -1,2 +0,0 @@
import { StringifyOptions } from '../types';
export declare function stringify(obj: any, stringifyOptions?: StringifyOptions): string;

View File

@@ -126,7 +126,7 @@ export declare type SamplingStrategy = Partial<{
}>;
export declare type RecordPlugin<TOptions = unknown> = {
name: string;
observer: (cb: Function, win: Window, options: TOptions) => listenerHandler;
observer: (cb: Function, win: IWindow, options: TOptions) => listenerHandler;
options: TOptions;
};
export declare type recordOptions<T> = {
@@ -450,4 +450,10 @@ export declare type ElementState = {
scroll?: [number, number];
};
export declare type KeepIframeSrcFn = (src: string) => boolean;
declare global {
interface Window {
FontFace: typeof FontFace;
}
}
export declare type IWindow = Window & typeof globalThis;
export {};

View File

@@ -1,6 +1,6 @@
import { Mirror, throttleOptions, listenerHandler, hookResetter, blockClass, addedNodeMutation, removedNodeMutation, textMutation, attributeMutation, mutationData, scrollData, inputData, DocumentDimension } from './types';
import { Mirror, throttleOptions, listenerHandler, hookResetter, blockClass, addedNodeMutation, removedNodeMutation, textMutation, attributeMutation, mutationData, scrollData, inputData, DocumentDimension, IWindow } from './types';
import { INode, serializedNodeWithId } from 'rrweb-snapshot';
export declare function on(type: string, fn: EventListenerOrEventListenerObject, target?: Document | Window): listenerHandler;
export declare function on(type: string, fn: EventListenerOrEventListenerObject, target?: Document | IWindow): listenerHandler;
export declare function createMirror(): Mirror;
export declare let _mirror: Mirror;
export declare function throttle<T>(func: (arg: T) => void, wait: number, options?: throttleOptions): (arg: T) => void;