Skip to content

Conversation

@jonoliver
Copy link
Member

@jonoliver jonoliver commented Nov 18, 2025

  • Add function to calculate emissions from Google PageSpeed results
  • Install @tgwf/co2

TODO

Validation

  1. Load the extension in the browser
  2. Navigate to https://sparkbox.com/ and open the devtools js console
  3. Open the extension and click "Analyze this page"
  4. Wait for the page scan to complete. Verify that you see the calculation results in the js console: Emissions Calculation Results: {bytesTransferred: 1899035, totalCO2: 0.28143698699999997}

@jonoliver jonoliver force-pushed the feat--calculate-emissions branch from f569f90 to caddabd Compare November 18, 2025 19:08
@github-actions
Copy link

github-actions bot commented Nov 18, 2025

📦 Extension packages built successfully!

Download your Chrome and Firefox extension packages

@jonoliver jonoliver force-pushed the feat--calculate-emissions branch from caddabd to a6d43f8 Compare November 18, 2025 19:12
@jonoliver jonoliver force-pushed the feat--calculate-emissions branch from a6d43f8 to 1af9ab6 Compare December 2, 2025 19:29
- adds esbuild to bundle carbon calculator dependencies
- calls carbon calculator function from welcome panel with page speed results
@jonoliver jonoliver force-pushed the feat--calculate-emissions branch from 1af9ab6 to 17fbcdc Compare December 2, 2025 21:13
}

module.exports = { bundleCarbonCalculator };

Copy link
Member Author

Choose a reason for hiding this comment

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

We didn't have anything bundling our js for the browser, and this is the first time that we're importing a 3rd party npm package @tgwf/co, e.g:
import { co2 } from "@tgwf/co2";

Since deps from node_modules weren't being bundled, trying to import resulted in this error when running the extension in the browser: TypeError: Failed to resolve module specifier "@tgwf/co2".

This is kind of a quick and dirty solution that just bundles the carbon calculator with the underlying dependency. We could probably improve this by bundling each entry point js file along with their underlying deps, but that's bigger than the scope of this PR.

@jonoliver jonoliver marked this pull request as ready for review December 2, 2025 21:32
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.

2 participants