rollup-plugin-corejs
Version:
⚡ include core-js polyfills when bundling with rollup
28 lines (27 loc) • 1.13 kB
TypeScript
/**
* The module is responsible for detecting usage of to-be-polyfilled APIs
* It analyses the AST and filters a list of given polyfills to only include the needed ones.
* Warning: Not all polyfills can be detected correct, meaning some polyfills might be included even if not really needed.
* E.g. detecting member functions is hard, imaging you import `foo` from a third party module and call `foo.catch()`.
* Is `catch` the `Promise.catch` method which needs to be polyfilled or is it some different `catch` function?
*
* @author Ferdinand Thiessen <rpm@fthiessen.de>
* @license EUPL-1.2
*
* SPDX-FileCopyrightText: 2023 Ferdinand Thiessen <rpm@fthiessen.de>
* SPDX-License-Identifier: EUPL-1.2
*
*/
declare enum PolyfillType {
CallWithArguments = 0,
StaticMember = 1,
GenericMethod = 2,
GenericProperty = 3,
Global = 4
}
type ModuleName = string;
type Arguments = any[];
type ModuleEntry = [ModuleName, PolyfillType, string, ...Arguments];
export declare const detectableModules: ModuleEntry[];
export declare function filterModules(modules: readonly string[], ast: any): string[];
export {};