[READ-ONLY] Mirror of https://github.com/danielroe/cross-origin-storage. Load shared dependencies from Cross-Origin Storage (COS).
cross-origin-storage experimental nuxt vite vite-plugin
0

Configure Feed

Select the types of activity you want to include in your feed.

at main 41 lines 3.0 kB View raw View rendered
1# nuxt-cos 2 3> [!WARNING] 4> Experimental. The [Cross-Origin Storage API](https://github.com/WICG/cross-origin-storage) is an early-stage proposal with no native browser support yet, and the chunk format here is not stable. This is a research project, not a production tool. 5 6Load shared dependencies (such as `vue`) from [Cross-Origin Storage (COS)](https://github.com/WICG/cross-origin-storage). 7 8Most sites ship their own copy of common dependencies, and the browser re-downloads them per origin even though the bytes are identical. COS lets a browser keep one shared, content-addressed copy. This project extracts those dependencies into chunks whose filename and inter-chunk references are derived from a SHA-256 of their contents, so two independent sites building the same dependency at the same version produce the same chunk and can share it, with no central registry. 9 10## Packages 11 12| Package | Description | 13| --------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | 14| [`vite-plugin-cross-origin-storage`](./packages/vite-plugin-cross-origin-storage) | The core Vite plugin: content-addressed chunking, bottom-up hashing, and the runtime loader. | 15| [`nuxt-cos`](./packages/nuxt-cos) | A thin Nuxt module wrapping the plugin. | 16 17## Status 18 19This is exploratory. The Cross-Origin Storage API is a [WICG proposal](https://github.com/WICG/cross-origin-storage) with no native browser implementation; today it only works via the [browser extension](https://github.com/web-ai-community/cross-origin-storage-extension). Without COS the loader falls back to ordinary network requests, so builds keep working everywhere. 20 21The plugin builds on [Thomas Steiner](https://github.com/tomayac)'s original [`vite-plugin-cross-origin-storage`](https://github.com/tomayac/vite-plugin-cross-origin-storage) and is intended as an update of it, with the aim of merging back upstream. 22 23## 🚧 Roadmap 24 25- [ ] **Multi-entry / multi-page builds.** 26- [ ] **Opting transitive dependencies out of COS chunking**. 27 28## Development 29 30```bash 31pnpm install 32pnpm build # build all packages 33pnpm test # run unit + e2e tests 34pnpm lint 35``` 36 37The e2e tests will run a real browser with and without the [Cross-Origin Storage extension](https://chromewebstore.google.com/detail/cross-origin-storage/denpnpcgjgikjpoglpjefakmdcbmlgih). The COS-extension tests need a full Chrome for Testing build (`npx playwright-core install chromium`) and clone the extension at test time; set `COS_SKIP_EXTENSION_TEST=1` only in an environment that genuinely cannot run a headed browser. 38 39## License 40 41[MIT](./LICENSE)