Skip to content

Commit

Permalink
rename from standalone-analyzer --> bundle-analyzer 2
Browse files Browse the repository at this point in the history
  • Loading branch information
suejung-sentry committed Sep 5, 2024
1 parent a2ced1d commit 06191aa
Show file tree
Hide file tree
Showing 48 changed files with 183 additions and 1,261 deletions.
4 changes: 2 additions & 2 deletions .changeset/eleven-deers-divide.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
"@codecov/standalone-analyzer": minor
"@codecov/bundle-analyzer": minor
---

Add support for no-bundler through new Standalone Analyzer library and CLI
Add support for no-bundler through new Bundle Analyzer library and CLI
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const config = {
"./packages/remix-vite-plugin/tsconfig.json",
"./packages/rollup-plugin/tsconfig.json",
"./packages/solidstart-plugin/tsconfig.json",
"./packages/standalone-analyzer/tsconfig.json",
"./packages/bundle-analyzer/tsconfig.json",
"./packages/sveltekit-plugin/tsconfig.json",
"./packages/vite-plugin/tsconfig.json",
"./packages/webpack-plugin/tsconfig.json",
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ jobs:
ROLLUP_API_URL: ${{ secrets.CODECOV_API_URL }}
SOLIDSTART_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
SOLIDSTART_API_URL: ${{ secrets.CODECOV_API_URL }}
STANDALONE_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
STANDALONE_API_URL: ${{ secrets.CODECOV_API_URL }}
BUNDLE_ANALYZER_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
BUNDLE_ANALYZER_API_URL: ${{ secrets.CODECOV_API_URL }}
SVELTEKIT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
SVELTEKIT_API_URL: ${{ secrets.CODECOV_API_URL }}
VITE_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
Expand Down Expand Up @@ -438,8 +438,8 @@ jobs:
ROLLUP_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
SOLIDSTART_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
SOLIDSTART_API_URL: ${{ secrets.CODECOV_API_URL }}
STANDALONE_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
STANDALONE_API_URL: ${{ secrets.CODECOV_API_URL }}
BUNDLE_ANALYZER_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
BUNDLE_ANALYZER_API_URL: ${{ secrets.CODECOV_API_URL }}
SVELTEKIT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
SVELTEKIT_API_URL: ${{ secrets.CODECOV_API_URL }}
VITE_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
Expand Down Expand Up @@ -468,7 +468,7 @@ jobs:
"vite-plugin",
"webpack-plugin",
"solidstart-plugin",
"standalone-analyzer"
"bundle-analyzer",
]
steps:
- name: Checkout
Expand Down Expand Up @@ -537,7 +537,7 @@ jobs:
"vite-plugin",
"webpack-plugin",
"solidstart-plugin",
"standalone-analyzer",
"bundle-analyzer",
]
steps:
- name: Checkout
Expand Down
12 changes: 6 additions & 6 deletions examples/standalone/cli/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Standalone Analyzer CLI Example
# Bundle Analyzer CLI Example

This directory includes an example calling the Codecov CLI for bundle analysis using the standalone-analyzer.
This directory includes an example calling the Codecov CLI for bundle analysis using the bundle-analyzer.

To run:

```
cd packages/standalone-analyzer
cd packages/bundle-analyzer
pnpm install
pnpm run build
cd examples/standalone/cli
cd examples/bundle-analyzer/cli
pnpm install
pnpm run build
pnpm run analyze
Expand All @@ -20,11 +20,11 @@ This will call the CLI. Note a Codecov API server (e.g., that at `test-api`) nee
For example:

```
pnpm standalone-analyzer ./dist --bundle-name=test-cli --upload-token=abcd --dry-run
pnpm bundle-analyzer ./dist --bundle-name=test-cli --upload-token=abcd --dry-run
```

Generates a bundle stats report and prints to console:

```
{"version":"2","builtAt":1725365190149,"duration":7,"bundleName":"test-cli","plugin":{"name":"@codecov/standalone-analyzer","version":"0.0.1-beta.12"},"assets":[{"name":"main.js","size":511,"gzipSize":301,"normalized":"main.js"},{"name":"main.js.map","size":732,"gzipSize":null,"normalized":"main.js.map"}],"chunks":[],"modules":[]}
{"version":"2","builtAt":1725365190149,"duration":7,"bundleName":"test-cli","plugin":{"name":"@codecov/bundle-analyzer","version":"0.0.1-beta.12"},"assets":[{"name":"main.js","size":511,"gzipSize":301,"normalized":"main.js"},{"name":"main.js.map","size":732,"gzipSize":null,"normalized":"main.js.map"}],"chunks":[],"modules":[]}
```
6 changes: 3 additions & 3 deletions examples/standalone/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@codecov/example-standalone-analyzer-cli",
"name": "@codecov/example-bundle-analyzer-cli",
"version": "1.0.0",
"private": true,
"main": "src/main.js",
Expand All @@ -18,10 +18,10 @@
},
"scripts": {
"build": "rollup -c",
"analyze": "pnpm standalone-analyzer ./dist --bundle-name=test-cli --upload-token=abcd --dry-run"
"analyze": "pnpm bundle-analyzer ./dist --bundle-name=test-cli --upload-token=abcd --dry-run"
},
"devDependencies": {
"@codecov/standalone-analyzer": "workspace:^",
"@codecov/bundle-analyzer": "workspace:^",
"@codecov/rollup-plugin": "workspace:^",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
Expand Down
12 changes: 6 additions & 6 deletions examples/standalone/library-import-cjs/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Standalone Analyzer Library Import (CJS) Example
# Bundle Analyzer Library Import (CJS) Example

This directory includes an example calling the standalone-analyzer exported library for bundle analysis.
This directory includes an example calling the bundle-analyzer exported library for bundle analysis.

This example runs in a CJS environment.

To run:

```
# build the library
cd packages/standalone-analyzer
cd packages/bundle-analyzer
pnpm install
pnpm run build
# create an example build to analyze
cd examples/standalone/cli
cd examples/bundle-analyzer/cli
pnpm install
pnpm run build
# run the node program
cd examples/standalone/library-import
cd examples/bundle-analyzer/library-import
pnpm install
pnpm run start
```
Expand All @@ -34,6 +34,6 @@ pnpm run start
Generates a bundle stats report and prints to console:

```
Dry run output: {"version":"2","builtAt":1725381817642,"duration":6,"bundleName":"my-bundle","plugin":{"name":"@codecov/standalone-analyzer","version":"0.0.1-beta.12"},"assets":[{"name":"main.js","size":511,"gzipSize":301,"normalized":"main.js"},{"name":"main.js.map","size":732,"gzipSize":null,"normalized":"main.js.map"}],"chunks":[],"modules":[]}
Dry run output: {"version":"2","builtAt":1725381817642,"duration":6,"bundleName":"my-bundle","plugin":{"name":"@codecov/bundle-analyzer","version":"0.0.1-beta.12"},"assets":[{"name":"main.js","size":511,"gzipSize":301,"normalized":"main.js"},{"name":"main.js.map","size":732,"gzipSize":null,"normalized":"main.js.map"}],"chunks":[],"modules":[]}
Report successfully generated and uploaded.
```
8 changes: 4 additions & 4 deletions examples/standalone/library-import-cjs/analyze.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { createAndUploadReport } = require("@codecov/standalone-analyzer");
const { createAndUploadReport } = require("@codecov/bundle-analyzer");

const buildDir = "../../../examples/standalone/cli/dist";
const buildDir = "../../../examples/bundle-analyzer/cli/dist";

const coreOpts = {
dryRun: true,
Expand All @@ -12,11 +12,11 @@ const coreOpts = {
debug: true,
};

const standaloneOpts = {
const bundleAnalyzerOpts = {
beforeReportUpload: async (original) => original,
};

createAndUploadReport(buildDir, coreOpts, standaloneOpts)
createAndUploadReport(buildDir, coreOpts, bundleAnalyzerOpts)
.then((reportAsJson) =>
console.log(`Report successfully generated and uploaded: ${reportAsJson}`),
)
Expand Down
4 changes: 2 additions & 2 deletions examples/standalone/library-import-cjs/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@codecov/example-standalone-analyzer-library",
"name": "@codecov/example-bundle-analyzer-library-cjs",
"version": "1.0.0",
"private": true,
"main": "analyze.js",
"scripts": {
"start": "node analyze.js"
},
"devDependencies": {
"@codecov/standalone-analyzer": "workspace:^"
"@codecov/bundle-analyzer": "workspace:^"
},
"volta": {
"extends": "../../package.json"
Expand Down
12 changes: 6 additions & 6 deletions examples/standalone/library-import-esm/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Standalone Analyzer Library Import (ESM) Example
# Bundle Analyzer Library Import (ESM) Example

This directory includes an example calling the standalone-analyzer exported library for bundle analysis.
This directory includes an example calling the bundle-analyzer exported library for bundle analysis.

This example runs in an ESM environment.

To run:

```
# build the library
cd packages/standalone-analyzer
cd packages/bundle-analyzer
pnpm install
pnpm run build
# create an example build to analyze
cd examples/standalone/cli
cd examples/bundle-analyzer/cli
pnpm install
pnpm run build
# run the node program
cd examples/standalone/library-import
cd examples/bundle-analyzer/library-import
pnpm install
pnpm run start
```
Expand All @@ -34,6 +34,6 @@ pnpm run start
Generates a bundle stats report and prints to console:

```
Dry run output: {"version":"2","builtAt":1725381817642,"duration":6,"bundleName":"my-bundle","plugin":{"name":"@codecov/standalone-analyzer","version":"0.0.1-beta.12"},"assets":[{"name":"main.js","size":511,"gzipSize":301,"normalized":"main.js"},{"name":"main.js.map","size":732,"gzipSize":null,"normalized":"main.js.map"}],"chunks":[],"modules":[]}
Dry run output: {"version":"2","builtAt":1725381817642,"duration":6,"bundleName":"my-bundle","plugin":{"name":"@codecov/bundle-analyzer","version":"0.0.1-beta.12"},"assets":[{"name":"main.js","size":511,"gzipSize":301,"normalized":"main.js"},{"name":"main.js.map","size":732,"gzipSize":null,"normalized":"main.js.map"}],"chunks":[],"modules":[]}
Report successfully generated and uploaded.
```
8 changes: 4 additions & 4 deletions examples/standalone/library-import-esm/analyze.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createAndUploadReport } from "@codecov/standalone-analyzer";
import { createAndUploadReport } from "@codecov/bundle-analyzer";

const buildDir = "../../../examples/standalone/cli/dist";
const buildDir = "../../../examples/bundle-analyzer/cli/dist";

const coreOpts = {
dryRun: true,
Expand All @@ -12,11 +12,11 @@ const coreOpts = {
debug: true,
};

const standaloneOpts = {
const bundleAnalyzerOpts = {
reportOverrider: async (original) => original,
};

createAndUploadReport(buildDir, coreOpts, standaloneOpts)
createAndUploadReport(buildDir, coreOpts, bundleAnalyzerOpts)
.then((reportAsJson) =>
console.log(`Report successfully generated and uploaded: ${reportAsJson}`),
)
Expand Down
4 changes: 2 additions & 2 deletions examples/standalone/library-import-esm/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@codecov/example-standalone-analyzer-library",
"name": "@codecov/example-bundle-analyzer-library-mjs",
"version": "1.0.0",
"private": true,
"main": "analyze.js",
Expand All @@ -8,7 +8,7 @@
"start": "node analyze.js"
},
"devDependencies": {
"@codecov/standalone-analyzer": "workspace:^"
"@codecov/bundle-analyzer": "workspace:^"
},
"volta": {
"extends": "../../package.json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP

exports[`Standalone Analyzer Integration Tests should generate a report and match the snapshot 1`] = `
exports[`Bundle Analyzer Integration Tests should generate a report and match the snapshot 1`] = `
{
"assets": ExpectArrayContaining {},
"builtAt": Any<Number>,
"bundleName": StringContaining "standalone",
"bundleName": StringContaining "bundle-analyzer",
"chunks": ExpectArrayContaining {},
"duration": Any<Number>,
"modules": ExpectArrayContaining {},
"plugin": {
"name": StringMatching "@codecov/standalone-analyzer",
"name": StringMatching "@codecov/bundle-analyzer",
"version": Any<String>,
},
"version": "2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import { $ } from "bun";
import { describe, it, expect, afterEach, beforeEach } from "bun:test";

const standaloneAnalyzerApp = "test-apps/standalone/dotenv-vercel";
const BUILD_DIR = `${standaloneAnalyzerApp}/build`;
const bundleAnalyzerApp = "test-apps/bundle-analyzer/dotenv-vercel";
const BUILD_DIR = `${bundleAnalyzerApp}/build`;

describe("Standalone Analyzer Integration Tests", () => {
describe("Bundle Analyzer Integration Tests", () => {
beforeEach(async () => {
await $`rm -rf ${BUILD_DIR}`;
await $`mkdir -p ${BUILD_DIR}`;
Expand All @@ -16,13 +16,13 @@ describe("Standalone Analyzer Integration Tests", () => {
});

it("should generate a report and match the snapshot", async () => {
const id = `standalone-analyzer-${Date.now()}`;
const id = `bundle-analyzer-${Date.now()}`;
const API_URL = `http://localhost:8000/test-url/${id}/200/false`;

// prepare, build, and run
await $`cd ${standaloneAnalyzerApp} && pnpm run build`;
await $`cd ${bundleAnalyzerApp} && pnpm run build`;
const { stdout, stderr } =
await $`cd ${standaloneAnalyzerApp} && API_URL=${API_URL} pnpm run analyze`;
await $`cd ${bundleAnalyzerApp} && API_URL=${API_URL} pnpm run analyze`;

expect(stdout.toString()).toContain(
"Report successfully generated and uploaded",
Expand All @@ -31,7 +31,7 @@ describe("Standalone Analyzer Integration Tests", () => {

// fetch stats from the server
const res = await fetch(
`http://localhost:8000/get-stats-by-bundle-name/${id}/standalone`,
`http://localhost:8000/get-stats-by-bundle-name/${id}/bundle-analyzer`,
);
const data = (await res.json()) as { stats: string };
const stats = JSON.parse(data.stats) as unknown;
Expand All @@ -40,9 +40,9 @@ describe("Standalone Analyzer Integration Tests", () => {
expect(stats).toMatchSnapshot({
builtAt: expect.any(Number),
duration: expect.any(Number),
bundleName: expect.stringContaining("standalone"),
bundleName: expect.stringContaining("bundle-analyzer"),
plugin: {
name: expect.stringMatching("@codecov/standalone-analyzer"),
name: expect.stringMatching("@codecov/bundle-analyzer"),
version: expect.any(String),
},
assets: expect.arrayContaining([
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test:e2e:vite": "bun test fixtures/**/vite/*",
"test:e2e:webpack": "bun test fixtures/**/webpack/*",
"test:e2e:solidstart": "bun test fixtures/**/solidstart/*",
"test:e2e:standalone": "bun test fixtures/**/standalone/*",
"test:e2e:bundle-analyzer": "bun test fixtures/**/bundle-analyzer/*",
"type-check": "tsc --noEmit",
"clean": "rm -rf node_modules",
"lint": "eslint . --ext .ts,.tsx",
Expand All @@ -35,7 +35,7 @@
"@codecov/remix-vite-plugin": "workspace:^",
"@codecov/rollup-plugin": "workspace:^",
"@codecov/solidstart-plugin": "workspace:^",
"@codecov/standalone-analyzer": "workspace:^",
"@codecov/bundle-analyzer": "workspace:^",
"@codecov/sveltekit-plugin": "workspace:^",
"@codecov/vite-plugin": "workspace:^",
"@codecov/webpack-plugin": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# dotenv-vercel

This directory "bundle-analyzer" contains an example app on dotenv vite vercel. It generates a build directory at `dist` which we can analyze for stats and upload to Codecov Bundle Analysis.

Example app is from [dotenv.org/docs/frameworks/vite/vercel](https://www.dotenv.org/docs/frameworks/vite/vercel)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createAndUploadReport } from "@codecov/standalone-analyzer";
import { createAndUploadReport } from "@codecov/bundle-analyzer";

const buildDir =
"../../../integration-tests/test-apps/standalone/dotenv-vercel/dist";
"../../../integration-tests/test-apps/bundle-analyzer/dotenv-vercel/dist";

const apiUrl = process.env.API_URL || "https://api.codecov.io";

Expand All @@ -10,16 +10,16 @@ const coreOpts = {
uploadToken: "your-upload-token",
retryCount: 3,
apiUrl: apiUrl,
bundleName: "standalone",
bundleName: "bundle-analyzer",
enableBundleAnalysis: true,
debug: true,
};

const standaloneOpts = {
const bundleAnalyzerOpts = {
beforeReportUpload: async (original) => original,
};

createAndUploadReport(buildDir, coreOpts, standaloneOpts)
createAndUploadReport(buildDir, coreOpts, bundleAnalyzerOpts)
.then((reportAsJson) =>
console.log(`Report successfully generated and uploaded: ${reportAsJson}`),
)
Expand Down
Loading

0 comments on commit 06191aa

Please sign in to comment.