Skip to content

Commit 1499f23

Browse files
authored
[PREVIEW ONLY] Change default to SWDMv4
2 parents d81bdb8 + 3921d01 commit 1499f23

File tree

6 files changed

+66
-439
lines changed

6 files changed

+66
-439
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121

2222
## Released
2323

24+
### [0.17.0] - 2025-12-02
25+
26+
#### Changes
27+
* Add `data` and `hosting` subpath exports
28+
* Add warning about switching default model to SWDMv4
29+
30+
#### Security
31+
* Bump tar-fs from 2.1.3 to 2.1.4 by @dependabot[bot] in https://github.com/thegreenwebfoundation/co2.js/pull/265
32+
* Bump js-yaml by @dependabot[bot] in https://github.com/thegreenwebfoundation/co2.js/pull/268
33+
2434
### [0.16.8] - 2025-05-12
2535

2636
#### Fixed

dist/iife/index.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tgwf/co2",
3-
"version": "0.16.9",
3+
"version": "0.17.0",
44
"description": "Work out the co2 of your digital services",
55
"main": "dist/cjs/index-node.js",
66
"module": "dist/esm/index.js",

src/co2.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,26 @@ import {
7070

7171
class CO2 {
7272
constructor(options) {
73-
this.model = new SustainableWebDesignV3();
73+
this.model = new SustainableWebDesignV4();
7474
// Using optional chaining allows an empty object to be passed
7575
// in without breaking the code.
7676
if (options?.model === "1byte") {
7777
this.model = new OneByte();
7878
} else if (options?.model === "swd") {
79-
this.model = new SustainableWebDesignV3();
80-
if (options?.version === 4) {
79+
this.model = new SustainableWebDesignV4();
80+
if (options?.version === 3) {
81+
this.model = new SustainableWebDesignV3();
82+
} else if (options?.version === 4) {
8183
this.model = new SustainableWebDesignV4();
8284
}
83-
} else if (!options?.model) {
84-
console.warn(`------
85-
WARNING: We are changing the default estimation model in CO2.js to Sustainable Web Design v4 in the next version (v0.18) of CO2.js. This change will take place in February 2026.
86-
87-
If you would like to keep using Sustainable Web Design v3, please make sure to explicitly set it in your code. See https://developers.thegreenwebfoundation.org/co2js/models/#using-sustainable-web-design-model-version-3 for details.
88-
------
89-
`);
9085
} else if (options?.model) {
9186
throw new Error(
9287
`"${options.model}" is not a valid model. Please use "1byte" for the OneByte model, and "swd" for the Sustainable Web Design model.\nSee https://developers.thegreenwebfoundation.org/co2js/models/ to learn more about the models available in CO2.js.`
9388
);
89+
} else if (!options?.model && options?.version) {
90+
throw new Error(
91+
`"Specified version ${options?.version} but an estimation model is missing. Please specify a model to use for the version you have set.`
92+
);
9493
}
9594

9695
if (options?.rating && typeof options.rating !== "boolean") {

0 commit comments

Comments
 (0)