rolldown_plugin_module_preload_polyfill

Crates.iorolldown_plugin_module_preload_polyfill
lib.rsrolldown_plugin_module_preload_polyfill
version0.1.0
created_at2025-10-18 04:35:20.975807+00
updated_at2025-10-18 04:35:20.975807+00
descriptionRolldown plugin for module preload polyfill
homepagehttps://rolldown.rs/
repositoryhttps://github.com/rolldown/rolldown
max_upload_size
id1888812
size84,894
Boshen (Boshen)

documentation

README

Maintenance Guide

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.

๐Ÿ“ฆ What it does

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.

๐Ÿš€ Debug Usage

import { defineConfig } from 'rolldown';
import { modulePreloadPolyfillPlugin } from 'rolldown/experimental';

export default defineConfig({
  input: {
    entry: './index.ts',
  },
  plugins: [modulePreloadPolyfillPlugin()],
});

๐Ÿงช Porting Differences

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.

๐Ÿ“„ License

Polyfill License

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
Commit count: 6097

cargo fmt