full site update

This commit is contained in:
2025-07-24 18:46:24 +02:00
parent bfe2b90d8d
commit 37a6e0ab31
6912 changed files with 540482 additions and 361712 deletions

View File

@@ -223,6 +223,22 @@ export default function myPlugin(options = {}) {
}
```
### exactRegex
Constructs a RegExp that matches the exact string specified. This is useful for plugin hook filters.
Parameters: `(str: String, flags?: String)`<br>
Returns: `RegExp`
#### Usage
```js
import { exactRegex } from '@rollup/pluginutils';
exactRegex('foobar'); // /^foobar$/
exactRegex('foo(bar)', 'i'); // /^foo\(bar\)$/i
```
### makeLegalIdentifier
Constructs a bundle-safe identifier from a `String`.
@@ -255,6 +271,22 @@ normalizePath('foo\\bar'); // 'foo/bar'
normalizePath('foo/bar'); // 'foo/bar'
```
### prefixRegex
Constructs a RegExp that matches a value that has the specified prefix. This is useful for plugin hook filters.
Parameters: `(str: String, flags?: String)`<br>
Returns: `RegExp`
#### Usage
```js
import { prefixRegex } from '@rollup/pluginutils';
prefixRegex('foobar'); // /^foobar/
prefixRegex('foo(bar)', 'i'); // /^foo\(bar\)/i
```
## Meta
[CONTRIBUTING](/.github/CONTRIBUTING.md)

View File

@@ -354,15 +354,28 @@ const dataToEsm = function dataToEsm(data, options = {}) {
return `${namedExportCode}${arbitraryExportCode}${defaultExportCode}`;
};
function exactRegex(str, flags) {
return new RegExp(`^${escapeRegex(str)}$`, flags);
}
function prefixRegex(str, flags) {
return new RegExp(`^${escapeRegex(str)}`, flags);
}
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
function escapeRegex(str) {
return str.replace(escapeRegexRE, '\\$&');
}
// TODO: remove this in next major
var index = {
addExtension,
attachScopes,
createFilter,
dataToEsm,
exactRegex,
extractAssignedNames,
makeLegalIdentifier,
normalizePath
normalizePath,
prefixRegex
};
exports.addExtension = addExtension;
@@ -370,8 +383,10 @@ exports.attachScopes = attachScopes;
exports.createFilter = createFilter;
exports.dataToEsm = dataToEsm;
exports.default = index;
exports.exactRegex = exactRegex;
exports.extractAssignedNames = extractAssignedNames;
exports.makeLegalIdentifier = makeLegalIdentifier;
exports.normalizePath = normalizePath;
exports.prefixRegex = prefixRegex;
module.exports = Object.assign(exports.default, exports);
//# sourceMappingURL=index.js.map

View File

@@ -350,16 +350,29 @@ const dataToEsm = function dataToEsm(data, options = {}) {
return `${namedExportCode}${arbitraryExportCode}${defaultExportCode}`;
};
function exactRegex(str, flags) {
return new RegExp(`^${escapeRegex(str)}$`, flags);
}
function prefixRegex(str, flags) {
return new RegExp(`^${escapeRegex(str)}`, flags);
}
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
function escapeRegex(str) {
return str.replace(escapeRegexRE, '\\$&');
}
// TODO: remove this in next major
var index = {
addExtension,
attachScopes,
createFilter,
dataToEsm,
exactRegex,
extractAssignedNames,
makeLegalIdentifier,
normalizePath
normalizePath,
prefixRegex
};
export { addExtension, attachScopes, createFilter, dataToEsm, index as default, extractAssignedNames, makeLegalIdentifier, normalizePath };
export { addExtension, attachScopes, createFilter, dataToEsm, index as default, exactRegex, extractAssignedNames, makeLegalIdentifier, normalizePath, prefixRegex };
//# sourceMappingURL=index.js.map

View File

@@ -1,6 +1,6 @@
{
"name": "@rollup/pluginutils",
"version": "5.1.4",
"version": "5.2.0",
"publishConfig": {
"access": "public"
},

View File

@@ -62,6 +62,13 @@ export function createFilter(
*/
export function dataToEsm(data: unknown, options?: DataToEsmOptions): string;
/**
* Constructs a RegExp that matches the exact string specified.
* @param str the string to match.
* @param flags flags for the RegExp.
*/
export function exactRegex(str: string, flags?: string): RegExp;
/**
* Extracts the names of all assignment targets based upon specified patterns.
* @param param An `acorn` AST Node.
@@ -78,21 +85,32 @@ export function makeLegalIdentifier(str: string): string;
*/
export function normalizePath(filename: string): string;
/**
* Constructs a RegExp that matches a value that has the specified prefix.
* @param str the string to match.
* @param flags flags for the RegExp.
*/
export function prefixRegex(str: string, flags?: string): RegExp;
export type AddExtension = typeof addExtension;
export type AttachScopes = typeof attachScopes;
export type CreateFilter = typeof createFilter;
export type ExactRegex = typeof exactRegex;
export type ExtractAssignedNames = typeof extractAssignedNames;
export type MakeLegalIdentifier = typeof makeLegalIdentifier;
export type NormalizePath = typeof normalizePath;
export type DataToEsm = typeof dataToEsm;
export type PrefixRegex = typeof prefixRegex;
declare const defaultExport: {
addExtension: AddExtension;
attachScopes: AttachScopes;
createFilter: CreateFilter;
dataToEsm: DataToEsm;
exactRegex: ExactRegex;
extractAssignedNames: ExtractAssignedNames;
makeLegalIdentifier: MakeLegalIdentifier;
normalizePath: NormalizePath;
prefixRegex: PrefixRegex;
};
export default defaultExport;