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

feat: Create Astro integration #216

Merged
merged 23 commits into from
Dec 4, 2024

Conversation

nicholas-codecov
Copy link
Collaborator

Description

This PR introduces a new package, that adds in an Astro integration, bringing BA support to Astro applications. For this integration (plugin), we followed the same pattern as we did with the Nuxt module utilizing Astro's integration system so users have an easier time integrating BA into their projects.

Closes #93

Code Example

Installation:

pnpm astro add @codecov/astro-integration

Will generate something like the following, however the user will have to configure the options such as enabling BA, the bundle name, the upload token, and other options depending on their setup.

import { defineConfig } from "astro/config";
import { codecovAstroIntegration } from "@codecov/astro-integration";

// https://astro.build/config
export default defineConfig({
  // other config settings
  integrations: [
    // place this after all other integrations
    codecovAstroIntegration({
      enableBundleAnalysis: true,
      bundleName: "example-astro-bundle",
      uploadToken: process.env.CODECOV_TOKEN,
    }),
  ],
});

Notable Changes

  • Add in @codecov/astro-integration package
  • Add in example Astro app
  • Add in integration tests

@codecov-notifications
Copy link

codecov-notifications bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 28.04878% with 118 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/astro-plugin/src/index.ts 0.00% 94 Missing and 1 partial ⚠️
...astro-bundle-analysis/astroBundleAnalysisPlugin.ts 59.61% 21 Missing ⚠️
packages/bundler-plugin-core/src/index.ts 0.00% 2 Missing ⚠️
Components Coverage Δ
Plugin core 96.98% <0.00%> (-0.05%) ⬇️
Rollup plugin 10.76% <ø> (ø)
Vite plugin 10.93% <ø> (ø)
Webpack plugin 52.09% <ø> (ø)

📢 Thoughts on this report? Let us know!

Copy link

codecov bot commented Nov 27, 2024

Codecov Report

Attention: Patch coverage is 28.04878% with 118 lines in your changes missing coverage. Please review.

Project coverage is 77.81%. Comparing base (6f2bebc) to head (1260bda).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/astro-plugin/src/index.ts 0.00% 94 Missing and 1 partial ⚠️
...astro-bundle-analysis/astroBundleAnalysisPlugin.ts 59.61% 21 Missing ⚠️
packages/bundler-plugin-core/src/index.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
Components Coverage Δ
Plugin core 96.98% <0.00%> (-0.05%) ⬇️
Rollup plugin 10.76% <ø> (ø)
Vite plugin 10.93% <ø> (ø)
Webpack plugin 52.09% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@codecov-staging
Copy link

codecov-staging bot commented Nov 27, 2024

Bundle Report

Changes will increase total bundle size by 1.99kB (0.07%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@codecov/bundler-plugin-core-esm 12.43kB 113 bytes (0.92%) ⬆️
@codecov/webpack-plugin-cjs 4.64kB 57 bytes (-1.21%) ⬇️
@codecov/sveltekit-plugin-esm 891 bytes 198 bytes (-18.18%) ⬇️
@codecov/remix-vite-plugin-esm 1.09kB 133 bytes (13.9%) ⬆️
@codecov/webpack-plugin-esm 3.39kB 209 bytes (-5.81%) ⬇️
@codecov/astro-plugin-cjs 1.35kB 1.35kB (100%) ⬆️
@codecov/astro-plugin-esm 862 bytes 862 bytes (100%) ⬆️

Copy link

codecov bot commented Nov 27, 2024

Bundle Report

Changes will increase total bundle size by 189.04kB (3.28%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
@codecov/vite-plugin-esm 2.37kB 1.13kB (91.04%) ⬆️
@codecov/bundler-plugin-core-esm 53.15kB 40.83kB (331.35%) ⬆️
@codecov/nuxt-plugin-esm 830 bytes 397 bytes (-32.36%) ⬇️
@codecov/sveltekit-plugin-esm 1.09kB 198 bytes (22.22%) ⬆️
@codecov/webpack-plugin-cjs 4.64kB 57 bytes (-1.21%) ⬇️
@codecov/webpack-plugin-esm 3.6kB 209 bytes (6.17%) ⬆️
@codecov/example-sveltekit-app-client-esm 715.09kB 2 bytes (-0.0%) ⬇️
@codecov/example-sveltekit-app-server-esm 974.29kB 1 bytes (-0.0%) ⬇️
@codecov/bundle-analyzer-esm 3.45kB 347 bytes (11.17%) ⬆️
@codecov/example-astro-app-client-esm 144.27kB 144.27kB (100%) ⬆️
@codecov/astro-plugin-esm 1.17kB 1.17kB (100%) ⬆️
@codecov/astro-plugin-cjs 1.35kB 1.35kB (100%) ⬆️

Copy link
Contributor

@suejung-sentry suejung-sentry left a comment

Choose a reason for hiding this comment

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

Approved this - thanks for all the work!

As an aside, do we have a good place we document the quirks of each of these technologies as a launching point for those unfamiliar. Like "astro is a layer on top of vite so we use our internal vite plugin for all except assigning the bundle name". Or "astro may support other tools like svelte (here) which means it uses the svelte compiler before being bundled by vite". (btw I probably fudged some of the above, based on my short reading).
Just any peculiarities uncovered during development.

.changeset/nine-boxes-help.md Show resolved Hide resolved
@@ -0,0 +1,15 @@
---
"@codecov/bundler-plugin-core": minor
"@codecov/astro-integration": minor
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we using new naming convention of <technology>-integration instead of -plugin in certain circumstances?

Edit - Oh I see that astro calls it "integration" instead of "plugin". My personal preference is to keep the terminology consistent in this repo, with "plugin" being a generic term for "custom behavior during the build." Could go either way on that though.

Copy link
Collaborator Author

@nicholas-codecov nicholas-codecov Dec 3, 2024

Choose a reason for hiding this comment

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

Yea that makes sense, i'll make the change

packages/astro-integration/src/index.ts Outdated Show resolved Hide resolved
packages/astro-integration/package.json Outdated Show resolved Hide resolved
version: output.version,
name: PLUGIN_NAME,
pluginVersion: PLUGIN_VERSION,
vite: {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can cross this bridge if/when it comes, but will we end up with any tricky dependency issues where we expect a certain version of vite to be used with astro? I guess that is more just up to astro to maintain that compatibility

@nicholas-codecov nicholas-codecov force-pushed the gh-cjbp-93-create-astro-integration branch from 6d6a5e8 to 3e9c979 Compare December 3, 2024 11:40
Copy link
Contributor

@suejung-sentry suejung-sentry left a comment

Choose a reason for hiding this comment

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

Nice, looks amazing! 🚀

@@ -18,6 +18,5 @@ export default defineProject({
}),
enforce: "pre",
},
...plugins,
Copy link
Contributor

Choose a reason for hiding this comment

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

I see we remove these ...plugins in the vitest.config.ts files now - what's the impact/purpose of that just for my understanding?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There was only one plugin being used ts config path, which i removed because it was causing issues with the example apps while trying to run the test runners. The only impact is that we import things in the core tests slightly differently with relative imports rather than a @ for the test utils.

@nicholas-codecov nicholas-codecov force-pushed the gh-cjbp-93-create-astro-integration branch from fac13e8 to b4e0035 Compare December 4, 2024 17:09
@nicholas-codecov nicholas-codecov force-pushed the gh-cjbp-93-create-astro-integration branch from aed77bb to 1260bda Compare December 4, 2024 17:41
@nicholas-codecov nicholas-codecov merged commit 90901a5 into main Dec 4, 2024
62 of 66 checks passed
@nicholas-codecov nicholas-codecov deleted the gh-cjbp-93-create-astro-integration branch December 4, 2024 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Astro
2 participants