Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rollup config #72

Merged
merged 2 commits into from
Apr 26, 2022
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ jobs:
registry-url: https://registry.npmjs.org
- name: Install
run: yarn install
- name: Bundle
- name: Bundle Browser
run: yarn bundle:browser
- name: Bundle Highlight
run: yarn bundle:highlight
- name: Confirm new version
run: python3 compare.py
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@highlight-run/rrweb",
"version": "1.1.20",
"version": "1.2.0",
"description": "record and replay the web",
"scripts": {
"test": "npm run bundle:browser && cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register -r ignore-styles -r jsdom-global/register test/**.test.ts",
Expand All @@ -23,6 +23,7 @@
"rrweb"
],
"main": "dist/index.js",
"unpkg": "dist/rrweb.js",
"sideEffects": false,
"files": [
"dist"
Expand All @@ -34,6 +35,7 @@
},
"homepage": "https://github.com/rrweb-io/rrweb#readme",
"devDependencies": {
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/chai": "^4.1.6",
"@types/inquirer": "0.0.43",
"@types/jsdom": "^16.2.12",
Expand All @@ -60,7 +62,8 @@
"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-typescript2": "^0.31.2",
"rollup-plugin-web-worker-loader": "^1.6.1",
"style-loader": "^2.0.0",
"ts-loader": "^8.0.14",
"ts-node": "^7.0.1",
Expand Down
81 changes: 50 additions & 31 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import typescript from 'rollup-plugin-typescript';
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
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 webWorkerLoader from 'rollup-plugin-web-worker-loader';
import pkg from './package.json';

function toRecordPath(path) {
Expand All @@ -13,20 +14,20 @@ function toRecordPath(path) {

function toRecordPackPath(path) {
return path
.replace(/^([\w]+)\//, '$1/record/')
.replace('rrweb', 'rrweb-record-pack');
.replace(/^([\w]+)\//, '$1/record/')
.replace('rrweb', 'rrweb-record-pack');
}

function toReplayPath(path) {
return path
.replace(/^([\w]+)\//, '$1/replay/')
.replace('rrweb', 'rrweb-replay');
.replace(/^([\w]+)\//, '$1/replay/')
.replace('rrweb', 'rrweb-replay');
}

function toReplayUnpackPath(path) {
return path
.replace(/^([\w]+)\//, '$1/replay/')
.replace('rrweb', 'rrweb-replay-unpack');
.replace(/^([\w]+)\//, '$1/replay/')
.replace('rrweb', 'rrweb-replay-unpack');
}

function toAllPath(path) {
Expand All @@ -35,16 +36,23 @@ function toAllPath(path) {

function toPluginPath(pluginName, stage) {
return (path) =>
path
.replace(/^([\w]+)\//, '$1/plugins/')
.replace('rrweb', `${pluginName}-${stage}`);
path
.replace(/^([\w]+)\//, '$1/plugins/')
.replace('rrweb', `${pluginName}-${stage}`);
}

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

const baseConfigs = [
// all in one
{
input: './src/entries/all.ts',
name: 'rrweb',
pathFn: toAllPath,
esm: true,
},
// record only
{
input: './src/record/index.ts',
Expand Down Expand Up @@ -75,13 +83,6 @@ const baseConfigs = [
name: 'rrweb',
pathFn: (p) => p,
},
// all in one
{
input: './src/entries/all.ts',
name: 'rrweb',
pathFn: toAllPath,
esm: true,
},
// plugins
{
input: './src/plugins/console/record/index.ts',
Expand All @@ -93,17 +94,31 @@ const baseConfigs = [
name: 'rrwebConsoleReplay',
pathFn: toPluginPath('console', 'replay'),
},
{
input: './src/plugins/sequential-id/record/index.ts',
name: 'rrwebSequentialIdRecord',
pathFn: toPluginPath('sequential-id', 'record'),
},
{
input: './src/plugins/sequential-id/replay/index.ts',
name: 'rrwebSequentialIdReplay',
pathFn: toPluginPath('sequential-id', 'replay'),
},
];

let configs = [];

for (const c of baseConfigs) {
const basePlugins = [resolve({ browser: true }), typescript()];
const basePlugins = [
resolve({ browser: true }),
webWorkerLoader(),
typescript({tsconfig: 'tsconfig.rollup.json'}),
];
const plugins = basePlugins.concat(
postcss({
extract: false,
inject: false,
}),
postcss({
extract: false,
inject: false,
}),
);
// browser
configs.push({
Expand All @@ -121,12 +136,12 @@ for (const c of baseConfigs) {
configs.push({
input: c.input,
plugins: basePlugins.concat(
postcss({
extract: true,
minimize: true,
sourceMap: true,
}),
terser(),
postcss({
extract: true,
minimize: true,
sourceMap: true,
}),
terser(),
),
output: [
{
Expand Down Expand Up @@ -184,7 +199,11 @@ if (process.env.BROWSER_ONLY) {
for (const c of browserOnlyBaseConfigs) {
const plugins = [
resolve({ browser: true }),
typescript(),
webWorkerLoader(),
typescript({
outDir: null,
tsconfig: 'tsconfig.rollup.json'
}),
postcss({
extract: false,
inject: false,
Expand All @@ -208,4 +227,4 @@ if (process.env.BROWSER_ONLY) {
}
}

export default configs;
export default configs;
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"declarationDir": "dist",
"lib": ["es6", "dom"],
"downlevelIteration": true,
"declaration": true,
"declaration": true
},
"compileOnSave": true,
"exclude": ["test"],
Expand Down
6 changes: 6 additions & 0 deletions tsconfig.rollup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ESNext"
}
}
Loading