rollup-plugin-polyfill-inject
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

rollup-plugin-polyfill-inject

auto inject polyfill

Config

import polyfill from "rollup-plugin-polyfill-inject";
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
export default {
	input: "./src/demo.js",
	output: {
		file: "./dist/demo.js",
		format: "iife"
	},
	plugins: [
		nodeResolve(),
		commonjs(),
		polyfill({
			"modules": {
				".includes": ["core-js/modules/es.array.includes", "core-js/modules/es.string.includes"],
				"Set":"core-js/modules/es.set",
				"Map":"core-js/modules/es.map",
			},
			"exclude":["**/node_modules/core-js/**"]
		})
	]
}

Before

console.log(document.head);
console.log([].includes(1));
console.log(localStorage);

var set=new Set();
function Map(){}
var map=new Map();

After

import "core-js/modules/es.array.includes";
import "core-js/modules/es.string.includes";
import "core-js/modules/es.set";

console.log(document.head);
console.log([].includes(1));
console.log(localStorage);

var set=new Set();
function Map(){}
var map=new Map();

core-js Config

import polyfill from "rollup-plugin-polyfill-inject";
import commonjs from "@rollup/plugin-commonjs";
import nodeResolve from "@rollup/plugin-node-resolve";
export default {
	input: "./src/demo.js",
	output: {
		file: "./dist/demo.js",
		format: "iife"
	},
	plugins: [
		nodeResolve(),
		commonjs(),
		polyfill({
			"core-js":{
				"preset":["ES2020"],
				"version":3
			},
			"modules": {
				"document.head":"sky-core/polyfill/document/head",
				"localStorage":"sky-core/polyfill/localStorage"
			},
			"exclude":["**/node_modules/core-js/**"]
		})
	]
}

Package Sidebar

Install

npm i rollup-plugin-polyfill-inject

Weekly Downloads

36

Version

1.0.6

License

MIT

Unpacked Size

30.9 kB

Total Files

6

Last publish

Collaborators

  • linsk