Skip to content
Merged

rrdom #613

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"workspaces": [
"packages/rrweb",
"packages/rrweb-snapshot",
"packages/rrweb-player"
"packages/rrweb-player",
"packages/rrdom"
],
"devDependencies": {
"lerna": "^4.0.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/rrdom/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist
es
lib
typings
3 changes: 3 additions & 0 deletions packages/rrdom/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["orta.vscode-jest"]
}
15 changes: 15 additions & 0 deletions packages/rrdom/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": [
{
"type": "node",
"name": "vscode-jest-tests",
"request": "launch",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"cwd": "${workspaceFolder}",
"runtimeExecutable": "yarn",
"args": ["test", "--runInBand", "--watchAll=false"]
}
]
}
3 changes: 3 additions & 0 deletions packages/rrdom/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"jest.jestCommandLine": "yarn test"
}
5 changes: 5 additions & 0 deletions packages/rrdom/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
};
44 changes: 44 additions & 0 deletions packages/rrdom/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "rrdom",
"version": "0.0.0",
"scripts": {
"dev": "rollup -c -w",
"bundle": "rollup --config",
"bundle:es-only": "cross-env ES_ONLY=true rollup --config",
"test": "jest",
"prepublish": "npm run bundle"
},
"keywords": [
"rrweb",
"rrdom"
],
"license": "MIT",
"main": "lib/rrdom.js",
"module": "es/rrdom.js",
"typings": "es",
"unpkg": "dist/rrdom.js",
"files": [
"dist",
"lib",
"es",
"typings"
],
"devDependencies": {
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@types/cssom": "^0.4.1",
"@types/jest": "^27.0.1",
"@types/nwsapi": "^2.2.2",
"jest": "^27.1.1",
"rollup": "^2.56.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"rrweb-snapshot": "^1.1.8",
"ts-jest": "^27.0.5",
"typescript": "^3.9.5"
},
"dependencies": {
"cssom": "^0.5.0",
"nwsapi": "^2.2.0"
}
}
103 changes: 103 additions & 0 deletions packages/rrdom/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import pkg from './package.json';

function toMinPath(path) {
return path.replace(/\.js$/, '.min.js');
}

const basePlugins = [
resolve({ browser: true }),
commonjs(),
typescript({
tsconfigOverride: { compilerOptions: { module: 'ESNext' } },
}),
];

const baseConfigs = [
{
input: './src/index.ts',
name: pkg.name,
path: pkg.name,
},
{
input: './src/document-nodejs.ts',
name: 'RRDocument',
path: 'document-nodejs',
},
];

let configs = [];
let extraConfigs = [];
for (let config of baseConfigs) {
configs.push(
// ES module
{
input: config.input,
plugins: basePlugins,
output: [
{
format: 'esm',
file: pkg.module.replace(pkg.name, config.path),
},
],
},
);
extraConfigs.push(
// browser
{
input: config.input,
plugins: basePlugins,
output: [
{
name: config.name,
format: 'iife',
file: pkg.unpkg.replace(pkg.name, config.path),
},
],
},
{
input: config.input,
plugins: basePlugins.concat(terser()),
output: [
{
name: config.name,
format: 'iife',
file: toMinPath(pkg.unpkg).replace(pkg.name, config.path),
sourcemap: true,
},
],
},
// CommonJS
{
input: config.input,
plugins: basePlugins,
output: [
{
format: 'cjs',
file: pkg.main.replace(pkg.name, config.path),
},
],
},
// ES module (packed)
{
input: config.input,
plugins: basePlugins.concat(terser()),
output: [
{
format: 'esm',
file: toMinPath(pkg.module).replace(pkg.name, config.path),
sourcemap: true,
},
],
},
);
}

if (!process.env.ES_ONLY) {
configs.push(...extraConfigs);
}

export default configs;
Loading