| Crates.io | rolldown_plugin_module_preload_polyfill |
| lib.rs | rolldown_plugin_module_preload_polyfill |
| version | 0.1.0 |
| created_at | 2025-10-18 04:35:20.975807+00 |
| updated_at | 2025-10-18 04:35:20.975807+00 |
| description | Rolldown plugin for module preload polyfill |
| homepage | https://rolldown.rs/ |
| repository | https://github.com/rolldown/rolldown |
| max_upload_size | |
| id | 1888812 |
| size | 84,894 |
A plugin for rolldown-vite that injects a modulepreload polyfill for legacy browsers, ported from Vite's modulePreloadPolyfillPlugin.
This plugin is exclusive to rolldown-vite and is currently considered unstable for external use.
This plugin resolves the special import:
import 'vite/modulepreload-polyfill';
By default, it injects a polyfill for rel="modulepreload" into each entry module, ensuring compatibility with browsers that don't support modulepreload natively.
import { defineConfig } from 'rolldown';
import { modulePreloadPolyfillPlugin } from 'rolldown/experimental';
export default defineConfig({
input: {
entry: './index.ts',
},
plugins: [modulePreloadPolyfillPlugin()],
});
Unlike Vite, which uses __VITE_IS_MODERN__ to control the polyfill, this plugin automatically applies the polyfill only when output.format is esm, matching Viteโs behavior.
The module-preload-polyfill.js polyfill code is based on
es-module-shims by Guy Bedford:
MIT License
Copyright (C) 2018-2021 Guy Bedford
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE