Skip to content

Commit 875be0b

Browse files
feat: Create non-bundler plugin (#169)
1 parent 621ecd3 commit 875be0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2654
-262
lines changed

.changeset/eleven-deers-divide.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@codecov/bundle-analyzer": minor
3+
"@codecov/bundler-plugin-core": minor
4+
"@codecov/nextjs-webpack-plugin": minor
5+
"@codecov/nuxt-plugin": minor
6+
"@codecov/remix-vite-plugin": minor
7+
"@codecov/rollup-plugin": minor
8+
"@codecov/solidstart-plugin": minor
9+
"@codecov/sveltekit-plugin": minor
10+
"@codecov/vite-plugin": minor
11+
"@codecov/webpack-plugin": minor
12+
---
13+
14+
Add support for setups without a standard bundler through new Bundle Analyzer library and CLI

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const config = {
3333
"./packages/remix-vite-plugin/tsconfig.json",
3434
"./packages/rollup-plugin/tsconfig.json",
3535
"./packages/solidstart-plugin/tsconfig.json",
36+
"./packages/bundle-analyzer/tsconfig.json",
3637
"./packages/sveltekit-plugin/tsconfig.json",
3738
"./packages/vite-plugin/tsconfig.json",
3839
"./packages/webpack-plugin/tsconfig.json",

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ jobs:
284284
matrix:
285285
example:
286286
[
287+
"bundle-analyzer-cli",
288+
"bundle-analyzer-lib-cjs",
289+
"bundle-analyzer-lib-esm",
287290
"next-js",
288291
"next-js-15",
289292
"nuxt",
@@ -343,6 +346,8 @@ jobs:
343346
env:
344347
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
345348
BASE_SHA: ${{ github.event.pull_request.base.sha }}
349+
BUNDLE_ANALYZER_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
350+
BUNDLE_ANALYZER_API_URL: ${{ secrets.CODECOV_API_URL }}
346351
NEXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
347352
NEXT_API_URL: ${{ secrets.CODECOV_API_URL }}
348353
NUXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
@@ -373,6 +378,9 @@ jobs:
373378
matrix:
374379
example:
375380
[
381+
"bundle-analyzer-cli",
382+
"bundle-analyzer-lib-cjs",
383+
"bundle-analyzer-lib-esm",
376384
"next-js",
377385
"next-js-15",
378386
"nuxt",
@@ -432,6 +440,8 @@ jobs:
432440
env:
433441
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
434442
BASE_SHA: ${{ github.event.pull_request.base.sha }}
443+
BUNDLE_ANALYZER_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
444+
BUNDLE_ANALYZER_API_URL: ${{ secrets.CODECOV_API_URL }}
435445
NEXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
436446
NEXT_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
437447
NUXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
@@ -462,6 +472,7 @@ jobs:
462472
matrix:
463473
package:
464474
[
475+
"bundle-analyzer",
465476
"bundler-plugin-core",
466477
"nextjs-webpack-plugin",
467478
"nuxt-plugin",
@@ -530,6 +541,7 @@ jobs:
530541
matrix:
531542
package:
532543
[
544+
"bundle-analyzer",
533545
"bundler-plugin-core",
534546
"nextjs-webpack-plugin",
535547
"nuxt-plugin",

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,10 @@ dist
131131
.pnp.*
132132

133133
.DS_Store
134+
135+
# vitest coverage
136+
*.junit.xml
137+
138+
# typedoc generated files
139+
typedoc/*
140+
!typedoc/plugin-remove-references.js
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Bundle Analyzer CLI Example
2+
3+
This directory includes an example calling the Codecov CLI for bundle analysis using the bundle-analyzer.

examples/bundle-analyzer-cli/a.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function a() {
2+
console.log("a");
3+
}
4+
5+
function notExported() {
6+
console.log("notExported");
7+
}
8+
9+
module.exports = {
10+
a,
11+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"gitService": "github",
3+
"oidc": {
4+
"useGitHubOIDC": false
5+
},
6+
"ignorePatterns": ["*.map"]
7+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@codecov/example-bundle-analyzer-cli",
3+
"version": "1.0.0",
4+
"private": true,
5+
"main": "src/main.js",
6+
"exports": {
7+
".": {
8+
"require": "./src/main.js",
9+
"default": "./src/main.js"
10+
},
11+
"./a": "./a.js",
12+
"./a.js": "./a.js",
13+
"./lib/b": "./src/b.js",
14+
"./lib/b.js": "./src/b.js",
15+
"./lib/c": "./src/c.js",
16+
"./lib/c.js": "./src/c.js",
17+
"./package.json": "./package.json"
18+
},
19+
"type": "module",
20+
"scripts": {
21+
"build": "rollup -c && pnpm bundle-analyzer ./dist --bundle-name=@codecov/example-bundle-analyzer-cli --upload-token=$BUNDLE_ANALYZER_UPLOAD_TOKEN --config-file=./baconfig.json"
22+
},
23+
"devDependencies": {
24+
"@codecov/bundle-analyzer": "workspace:^",
25+
"@codecov/rollup-plugin": "workspace:^",
26+
"@rollup/plugin-commonjs": "^25.0.7",
27+
"@rollup/plugin-node-resolve": "^15.2.3",
28+
"npm-run-all": "^4.1.5",
29+
"rollup": "^4.9.6",
30+
"serve": "^14.2.1"
31+
},
32+
"volta": {
33+
"extends": "../../package.json"
34+
},
35+
"engines": {
36+
"node": ">=18.0.0"
37+
}
38+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import resolve from "@rollup/plugin-node-resolve";
2+
import commonjs from "@rollup/plugin-commonjs";
3+
import { defineConfig } from "rollup";
4+
5+
// `npm run build` -> `production` is true
6+
// `npm run dev` -> `production` is false
7+
const production = !process.env.ROLLUP_WATCH;
8+
9+
export default defineConfig({
10+
input: "src/main.js",
11+
output: {
12+
dir: "dist",
13+
format: "iife", // immediately-invoked function expression — suitable for <script> tags
14+
sourcemap: true,
15+
},
16+
plugins: [
17+
resolve(), // tells Rollup how to find date-fns in node_modules
18+
commonjs(), // converts date-fns to ES modules
19+
],
20+
});

examples/bundle-analyzer-cli/src/b.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const { d } = require("./d");
2+
const { common } = require("./common");
3+
4+
function b() {
5+
console.log("b");
6+
d();
7+
common();
8+
}
9+
10+
module.exports = {
11+
b,
12+
};

0 commit comments

Comments
 (0)