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

build: Add size limit action #127

Merged
merged 5 commits into from
Oct 25, 2023
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
38 changes: 38 additions & 0 deletions .github/workflows/size-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Size Check

on:
push:
branches:
- master
- release/**
pull_request:

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
job_size_check:
name: Size Check
timeout-minutes: 15
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js lts/*
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: 'yarn'

- name: Install Dependencies
run: yarn install --frozen-lockfile

- name: Build Project
run: NODE_OPTIONS='--max-old-space-size=4096' yarn build:all
- name: Check bundle sizes
uses: getsentry/size-limit-action@runForBranch
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_step: build
main_branch: sentry-v2

33 changes: 33 additions & 0 deletions .size-limit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = [
// Main browser webpack builds
{
name: 'rrweb - record only (gzipped)',
path: 'packages/rrweb/es/rrweb/packages/rrweb/src/entries/all.js',
import: '{ record }',
gzip: true
},
{
name: 'rrweb - record only (min)',
path: 'packages/rrweb/es/rrweb/packages/rrweb/src/entries/all.js',
import: '{ record }',
gzip: false
},
Comment on lines +3 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you swap the ordering for these two?

{
name: 'rrweb - record with treeshaking flags (gzipped)',
path: 'packages/rrweb/es/rrweb/packages/rrweb/src/entries/all.js',
import: '{ record }',
gzip: true,
modifyWebpackConfig: function (config) {
const webpack = require('webpack');
config.plugins.push(
new webpack.DefinePlugin({
__RRWEB_EXCLUDE_CANVAS__: true,
__RRWEB_EXCLUDE_SHADOW_DOM__: true,
__RRWEB_EXCLUDE_IFRAME__: true,
}),
);
return config;
},
},

];
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",
"@monorepo-utils/workspaces-to-typescript-project-references": "^2.10.2",
"@size-limit/preset-small-lib": "~8.2.6",
"@size-limit/webpack": "~8.2.6",
"@typescript-eslint/eslint-plugin": "^5.25.0",
"@typescript-eslint/parser": "^5.25.0",
"browserslist": "^4.21.4",
Expand All @@ -33,6 +35,7 @@
"markdownlint": "^0.25.1",
"markdownlint-cli": "^0.31.1",
"prettier": "2.8.4",
"size-limit": "~8.2.6",
"turbo": "^1.2.4",
"typescript": "^4.9.5"
},
Expand All @@ -52,7 +55,8 @@
},
"resolutions": {
"**/jsdom/cssom": "https://registry.npmjs.org/rrweb-cssom/-/rrweb-cssom-0.6.0.tgz",
"**/@types/dom-webcodecs": "0.1.5"
"**/@types/dom-webcodecs": "0.1.5",
"**/@types/estree": "^1.0.0"
},
"browserslist": [
"defaults",
Expand Down
1 change: 0 additions & 1 deletion packages/rrweb/src/record/observers/canvas/2d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { Mirror } from '@sentry-internal/rrweb-snapshot';
import {
blockClass,
CanvasContext,
Expand Down
15 changes: 3 additions & 12 deletions packages/rrweb/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,11 @@ import type {
MaskAttributeFn,
} from '@sentry-internal/rrweb-snapshot';
import type { PackFn, UnpackFn } from './packer/base';
import type {
IframeManager,
IframeManagerInterface,
} from './record/iframe-manager';
import type {
ShadowDomManager,
ShadowDomManagerInterface,
} from './record/shadow-dom-manager';
import type { IframeManagerInterface } from './record/iframe-manager';
import type { ShadowDomManagerInterface } from './record/shadow-dom-manager';
import type { Replayer } from './replay';
import type { RRNode } from '@sentry-internal/rrdom';
import type {
CanvasManager,
CanvasManagerInterface,
} from './record/observers/canvas/canvas-manager';
import type { CanvasManagerInterface } from './record/observers/canvas/canvas-manager';
import type { StylesheetManager } from './record/stylesheet-manager';
import type {
addedNodeMutation,
Expand Down
8 changes: 6 additions & 2 deletions packages/web-extension/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ function useSpecialFormat(
return {
name: 'use-special-format',
config(config) {
const shouldUse =
config.build?.lib && entriesToUse.includes(config.build.lib.entry);
const entryOrEntries = config.build?.lib
? config.build.lib.entry
: undefined;
const entry =
typeof entryOrEntries === 'string' ? entryOrEntries : undefined;
const shouldUse = entry && entriesToUse.includes(entry);
if (shouldUse) {
config.build = config.build ?? {};
// @ts-expect-error: lib needs to be an object, forcing it.
Expand Down
Loading