Documentation
Tech Debt

Tech debt

Pinned dependencies

In general we keep dependencies up to date. The following packages, however, need to be pinned to a specific version:

  • [email protected] (a dependency of react-cosmos-plugin-webpack) because 6.0.10+ broke outside CRA's webpack-with-DefinePlugin setup (CRA #11773 (opens in a new tab), Cosmos symptom in #1359 (opens in a new tab)). The regression — an unguarded process.env.NODE_ENV reference in the bundle — is still open as CRA #12064 (opens in a new tab); 6.1.0 (Feb 2025) is just a republish, no code fix. The pin is low-cost: the package has zero runtime dependencies and ships a single ~360KB bundled file. The realistic exit is replacing it altogether — kept for now because it provides a tasteful default error overlay with click-to-open-in-editor, and only burdens the webpack plugin, not Cosmos itself.

Code improvements

  • Enabling noUncheckedIndexedAccess in TypeScript would improve the overall quality of all Cosmos packages. Some research is required to learn common ways of handling mapping and reducing arrays, where TypeScript can't infer that a mapped key isn't undefined. I don't want to add unnecessary checks either because it decreases code conciseness.

Backward compatibility

  • createRendererUrl and createWebRendererUrl (in react-cosmos-core) and useDomRendererConnect (in react-cosmos-dom) still accept the positional arguments they had before 7.5. Cosmos packages up to 7.4 depend on each other with caret ranges, so an older react-cosmos or react-cosmos-next can be installed next to a newer react-cosmos-core or react-cosmos-dom just by regenerating a lockfile. Starting with 7.5 packages depend on exact versions of each other, but the old ranges match any 7.x version, so the deprecated signatures can only be removed in 8.0.

NPM optionalDependencies

When migrating from Yarn 1.x to NPM latest (opens in a new tab) some platform-specific optional dependencies had to be added here (opens in a new tab) and here (opens in a new tab) in order for GitHub Actions to work across Linux & Windows with the versioned package-lock.json. This doesn't affect users as those optional dependencies aren't added to any of the published packages. It's just a minor nuisance. The NPM issue is tracked here (opens in a new tab). Vite discussion here (opens in a new tab).