mozilla / nimbus-shared

Shared data and schemas for Project Nimbus
https://mozilla.github.io/nimbus-shared
Mozilla Public License 2.0
6 stars 15 forks source link

Inconsistent key case in npm 'data' object #66

Open pdehaan opened 4 years ago

pdehaan commented 4 years ago

Nothing major, but interesting... Note the data.Audiences vs data.features (and I guess the ExperimentDesignPresets vs experiment-recipe-samples casing differences):

const shared = require('@mozilla/nimbus-shared'); // 175.6K
const {name, version} = require("@mozilla/nimbus-shared/package.json"); // 2.8K

console.log(`${name}@${version}`); // @mozilla/nimbus-shared@0.0.5
console.log(Object.keys(shared.data));
/* [
  'Audiences',
  'ExperimentDesignPresets',
  'experiment-recipe-samples',
  'features',
  'test-data'
] */
pdehaan commented 4 years ago

For anybody else mildly curious why the published @mozilla/nimbus-shared npm module is 175 KB, I slapped this garbage script together:

const fs = require("fs");
const glob = require("fast-glob");

glob("./node_modules/@mozilla/nimbus-shared/**")
  .then((files) => {
    for (const file of files.sort()) {
      const filename = file.replace("./node_modules/@mozilla/nimbus-shared/", "");
      const sizeKb = fs.statSync(file).size / 1024;
      console.log(`${filename} | ${Number(sizeKb).toFixed(1)} KB | ${sizeKb > 50 ? "⚠️".repeat(sizeKb / 50) : ""}`);
    }
  });
Output | FILENAME | SIZE | ⚠️ | |:---------|-----:|:-------:| CHANGELOG.md | 1.1 KB | README.md | 0.6 KB | dist/data.json | 4.8 KB | dist/data/Audiences.d.ts | 0.1 KB | dist/data/Audiences.js | 1.4 KB | dist/data/ExperimentDesignPresets.d.ts | 0.4 KB | dist/data/ExperimentDesignPresets.js | 0.6 KB | dist/index.d.ts | 0.3 KB | dist/index.js | 1.6 KB | dist/src/_generated/data.d.ts | 2.7 KB | dist/src/_generated/data.js | 4.8 KB | dist/src/_generated/schemas.d.ts | 103.8 KB | ⚠️⚠️ dist/src/_generated/schemas.js | 146.0 KB | ⚠️⚠️ dist/src/_generated/typeGuardHelpers.d.ts | 6.5 KB | dist/src/_generated/typeGuardHelpers.js | 14.6 KB | dist/src/typeGuards.d.ts | 0.4 KB | dist/src/typeGuards.js | 3.0 KB | dist/src/utils.d.ts | 0.7 KB | dist/src/utils.js | 1.2 KB | dist/types/experiments.d.ts | 3.0 KB | dist/types/experiments.js | 0.1 KB | dist/types/features.d.ts | 1.1 KB | dist/types/features.js | 0.1 KB | dist/types/index.d.ts | 0.2 KB | dist/types/index.js | 1.2 KB | dist/types/messaging.d.ts | 7.2 KB | dist/types/messaging.js | 0.1 KB | dist/types/normandy.d.ts | 9.5 KB | dist/types/normandy.js | 0.1 KB | dist/types/targeting.d.ts | 0.4 KB | dist/types/targeting.js | 0.1 KB | dist/types/test.d.ts | 0.1 KB | dist/types/test.js | 0.1 KB | index.ts | 0.3 KB | package.json | 2.3 KB | schemas/experiments/EmptyAAExperiment.json | 4.7 KB | schemas/experiments/Experiment.json | 4.8 KB | schemas/experiments/ExperimentDesign.json | 4.8 KB | schemas/experiments/ExperimentRecipe.json | 5.8 KB | schemas/features/Feature.json | 2.7 KB | schemas/messaging/SimpleCFRMessage.json | 67.7 KB | ⚠️ schemas/normandy/AddonRollbackArguments.json | 0.5 KB | schemas/normandy/AddonRolloutArguments.json | 0.7 KB | schemas/normandy/BranchedAddonStudyArguments.json | 2.0 KB | schemas/normandy/ConsoleLogArguments.json | 0.5 KB | schemas/normandy/MessagingExperimentArguments.json | 2.5 KB | schemas/normandy/MultiPreferenceExperimentArguments.json | 4.1 KB | schemas/normandy/NormandyRecipe.json | 18.5 KB | schemas/normandy/OptOutStudyArguments.json | 1.2 KB | schemas/normandy/PreferenceExperimentArguments.json | 3.0 KB | schemas/normandy/PreferenceRollbackArguments.json | 0.5 KB | schemas/normandy/PreferenceRolloutArguments.json | 1.3 KB | schemas/normandy/ShowHeartbeatArguments.json | 2.1 KB | schemas/targeting/Audience.json | 0.8 KB | schemas/test/FoodColors.json | 0.5 KB | src/_generated/data.ts | 4.7 KB | src/_generated/schemas.ts | 145.8 KB | ⚠️⚠️ src/_generated/typeGuardHelpers.ts | 9.7 KB | src/typeGuards.ts | 1.9 KB | src/utils.ts | 1.1 KB | types/experiments.ts | 2.9 KB | types/features.ts | 1.0 KB | types/index.ts | 0.2 KB | types/messaging.ts | 7.1 KB | types/normandy.ts | 9.0 KB | types/targeting.ts | 0.4 KB | types/test.ts | 0.1 KB |

Most of the files are pretty small, but we have 4 files over 50 KB and 3 of those are over 100 KB. Not that it is wrong or a bug, just FYI.