rollup-plugin-handlebars-precompiler
Version:
Rollup plugin to precompile Handlebars templates into JavaScript modules
90 lines • 3.46 kB
TypeScript
export type PartialName = (id: string) => string;
/**
* @module rollup-plugin-handlebars-precompiler/types
*/
/**
* @callback PartialName
* @param {string} id - import identifier of a Handlebars partial template
* @returns {string} - the partial name derived from id
*/
/** @type {PartialName} */
export let PartialName: PartialName;
export type PartialPath = (partialName: string, importerPath: string) => string;
/**
* @callback PartialPath
* @param {string} partialName - name of a partial from which to derive its path
* @param {string} importerPath - path of the module importing the template
* @returns {string} - the path to the partial as derived from the arguments
*/
/** @type {PartialPath} */
export let PartialPath: PartialPath;
export type PluginOptions = {
/**
* - paths to modules containing Handlebars
* helper functions
*/
helpers?: string[];
/**
* - one or more picomatch patterns
* matching Handlebars template files to transform
*/
include?: (string | string[]);
/**
* - one or more picomatch patterns
* matching Handlebars template files to exclude from transformation
*/
exclude?: (string | string[]);
/**
* - one or more picomatch patterns
* matching Handlebars template files containing partials
*/
partials?: (string | string[]);
/**
* - function to transform a partial file
* name into the name used to apply the partial in other templates
*/
partialName?: PartialName;
/**
* - function to transform a partial's
* name and that of the module importing it into its import path
*/
partialPath?: PartialPath;
/**
* - Handlebars compiler options passed
* through to Handlebars.parse() and Handlebars.precompile()
*/
compiler?: CompileOptions;
/**
* - disables source map generation when false
*/
sourcemap?: boolean;
/**
* - disables source map generation when false
*/
sourceMap?: boolean;
};
/**
* @typedef {object} PluginOptions
* @property {string[]} [helpers] - paths to modules containing Handlebars
* helper functions
* @property {(string | string[])} [include] - one or more picomatch patterns
* matching Handlebars template files to transform
* @property {(string | string[])} [exclude] - one or more picomatch patterns
* matching Handlebars template files to exclude from transformation
* @property {(string | string[])} [partials] - one or more picomatch patterns
* matching Handlebars template files containing partials
* @property {PartialName} [partialName] - function to transform a partial file
* name into the name used to apply the partial in other templates
* @property {PartialPath} [partialPath] - function to transform a partial's
* name and that of the module importing it into its import path
* @property {CompileOptions} [compiler] - Handlebars compiler options passed
* through to Handlebars.parse() and Handlebars.precompile()
* @property {boolean} [sourcemap] - disables source map generation when false
* @property {boolean} [sourceMap] - disables source map generation when false
* @see https://handlebarsjs.com/guide/#custom-helpers
* @see https://github.com/micromatch/picomatch#globbing-features
* @see https://handlebarsjs.com/api-reference/compilation.html
*/
/** @type {PluginOptions} */
export let PluginOptions: PluginOptions;
//# sourceMappingURL=types.d.ts.map