rollup 4.37.0 → 4.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +2 -2
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +152 -19
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +2 -2
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.d.ts +24 -1
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +11013 -10880
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +33 -31
package/dist/bin/rollup
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/*
|
|
3
3
|
@license
|
|
4
|
-
Rollup.js v4.
|
|
5
|
-
|
|
4
|
+
Rollup.js v4.38.0
|
|
5
|
+
Sat, 29 Mar 2025 06:28:32 GMT - commit 22b64bcc511dfc40ce463e3f662a928915908713
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
8
8
|
|
package/dist/es/getLogFilter.js
CHANGED
package/dist/es/parseAst.js
CHANGED
package/dist/es/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.38.0
|
|
4
|
+
Sat, 29 Mar 2025 06:28:32 GMT - commit 22b64bcc511dfc40ce463e3f662a928915908713
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -15,7 +15,7 @@ import process$1, { env } from 'node:process';
|
|
|
15
15
|
import { performance } from 'node:perf_hooks';
|
|
16
16
|
import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
17
17
|
|
|
18
|
-
var version = "4.
|
|
18
|
+
var version = "4.38.0";
|
|
19
19
|
|
|
20
20
|
const comma = ','.charCodeAt(0);
|
|
21
21
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -11144,7 +11144,7 @@ function requirePicomatch () {
|
|
|
11144
11144
|
}
|
|
11145
11145
|
|
|
11146
11146
|
var picomatchExports = /*@__PURE__*/ requirePicomatch();
|
|
11147
|
-
const
|
|
11147
|
+
const picomatch = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
|
|
11148
11148
|
|
|
11149
11149
|
const extractors = {
|
|
11150
11150
|
ArrayPattern(names, param) {
|
|
@@ -11198,7 +11198,7 @@ const normalizePath = function normalizePath(filename) {
|
|
|
11198
11198
|
return filename.replace(normalizePathRegExp, posix.sep);
|
|
11199
11199
|
};
|
|
11200
11200
|
|
|
11201
|
-
function getMatcherString(id, resolutionBase) {
|
|
11201
|
+
function getMatcherString$1(id, resolutionBase) {
|
|
11202
11202
|
if (resolutionBase === false || isAbsolute(id) || id.startsWith('**')) {
|
|
11203
11203
|
return normalizePath(id);
|
|
11204
11204
|
}
|
|
@@ -11212,15 +11212,15 @@ function getMatcherString(id, resolutionBase) {
|
|
|
11212
11212
|
// otherwise Node will force backslash (\) on windows
|
|
11213
11213
|
return posix.join(basePath, normalizePath(id));
|
|
11214
11214
|
}
|
|
11215
|
-
const createFilter = function createFilter(include, exclude, options) {
|
|
11215
|
+
const createFilter$1 = function createFilter(include, exclude, options) {
|
|
11216
11216
|
const resolutionBase = options && options.resolve;
|
|
11217
11217
|
const getMatcher = (id) => id instanceof RegExp
|
|
11218
11218
|
? id
|
|
11219
11219
|
: {
|
|
11220
11220
|
test: (what) => {
|
|
11221
11221
|
// this refactor is a tad overly verbose but makes for easy debugging
|
|
11222
|
-
const pattern = getMatcherString(id, resolutionBase);
|
|
11223
|
-
const fn =
|
|
11222
|
+
const pattern = getMatcherString$1(id, resolutionBase);
|
|
11223
|
+
const fn = picomatch(pattern, { dot: true });
|
|
11224
11224
|
const result = fn(what);
|
|
11225
11225
|
return result;
|
|
11226
11226
|
}
|
|
@@ -21814,6 +21814,127 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
|
|
|
21814
21814
|
};
|
|
21815
21815
|
}
|
|
21816
21816
|
|
|
21817
|
+
function ensureArray(items) {
|
|
21818
|
+
if (Array.isArray(items)) {
|
|
21819
|
+
return items.filter(Boolean);
|
|
21820
|
+
}
|
|
21821
|
+
if (items) {
|
|
21822
|
+
return [items];
|
|
21823
|
+
}
|
|
21824
|
+
return [];
|
|
21825
|
+
}
|
|
21826
|
+
|
|
21827
|
+
const FALLBACK_TRUE = 1;
|
|
21828
|
+
const FALLBACK_FALSE = 0;
|
|
21829
|
+
function getMatcherString(glob, cwd) {
|
|
21830
|
+
if (glob.startsWith('**') || isAbsolute$1(glob)) {
|
|
21831
|
+
return normalize(glob);
|
|
21832
|
+
}
|
|
21833
|
+
const resolved = resolve$1(cwd, glob);
|
|
21834
|
+
return normalize(resolved);
|
|
21835
|
+
}
|
|
21836
|
+
function patternToIdFilter(pattern) {
|
|
21837
|
+
if (pattern instanceof RegExp) {
|
|
21838
|
+
return (id) => {
|
|
21839
|
+
const normalizedId = normalize(id);
|
|
21840
|
+
const result = pattern.test(normalizedId);
|
|
21841
|
+
pattern.lastIndex = 0;
|
|
21842
|
+
return result;
|
|
21843
|
+
};
|
|
21844
|
+
}
|
|
21845
|
+
const cwd = process.cwd();
|
|
21846
|
+
const glob = getMatcherString(pattern, cwd);
|
|
21847
|
+
const matcher = picomatch(glob, { dot: true });
|
|
21848
|
+
return (id) => {
|
|
21849
|
+
const normalizedId = normalize(id);
|
|
21850
|
+
return matcher(normalizedId);
|
|
21851
|
+
};
|
|
21852
|
+
}
|
|
21853
|
+
function patternToCodeFilter(pattern) {
|
|
21854
|
+
if (pattern instanceof RegExp) {
|
|
21855
|
+
return (code) => {
|
|
21856
|
+
const result = pattern.test(code);
|
|
21857
|
+
pattern.lastIndex = 0;
|
|
21858
|
+
return result;
|
|
21859
|
+
};
|
|
21860
|
+
}
|
|
21861
|
+
return (code) => code.includes(pattern);
|
|
21862
|
+
}
|
|
21863
|
+
function createFilter(exclude, include) {
|
|
21864
|
+
if (!exclude && !include) {
|
|
21865
|
+
return;
|
|
21866
|
+
}
|
|
21867
|
+
return input => {
|
|
21868
|
+
if (exclude?.some(filter => filter(input))) {
|
|
21869
|
+
return false;
|
|
21870
|
+
}
|
|
21871
|
+
if (include?.some(filter => filter(input))) {
|
|
21872
|
+
return true;
|
|
21873
|
+
}
|
|
21874
|
+
return !!include && include.length > 0 ? FALLBACK_FALSE : FALLBACK_TRUE;
|
|
21875
|
+
};
|
|
21876
|
+
}
|
|
21877
|
+
function normalizeFilter(filter) {
|
|
21878
|
+
if (typeof filter === 'string' || filter instanceof RegExp) {
|
|
21879
|
+
return {
|
|
21880
|
+
include: [filter]
|
|
21881
|
+
};
|
|
21882
|
+
}
|
|
21883
|
+
if (Array.isArray(filter)) {
|
|
21884
|
+
return {
|
|
21885
|
+
include: ensureArray(filter)
|
|
21886
|
+
};
|
|
21887
|
+
}
|
|
21888
|
+
return {
|
|
21889
|
+
exclude: filter.exclude ? ensureArray(filter.exclude) : undefined,
|
|
21890
|
+
include: filter.include ? ensureArray(filter.include) : undefined
|
|
21891
|
+
};
|
|
21892
|
+
}
|
|
21893
|
+
function createIdFilter(filter) {
|
|
21894
|
+
if (!filter)
|
|
21895
|
+
return;
|
|
21896
|
+
const { exclude, include } = normalizeFilter(filter);
|
|
21897
|
+
const excludeFilter = exclude?.map(patternToIdFilter);
|
|
21898
|
+
const includeFilter = include?.map(patternToIdFilter);
|
|
21899
|
+
return createFilter(excludeFilter, includeFilter);
|
|
21900
|
+
}
|
|
21901
|
+
function createCodeFilter(filter) {
|
|
21902
|
+
if (!filter)
|
|
21903
|
+
return;
|
|
21904
|
+
const { exclude, include } = normalizeFilter(filter);
|
|
21905
|
+
const excludeFilter = exclude?.map(patternToCodeFilter);
|
|
21906
|
+
const includeFilter = include?.map(patternToCodeFilter);
|
|
21907
|
+
return createFilter(excludeFilter, includeFilter);
|
|
21908
|
+
}
|
|
21909
|
+
function createFilterForId(filter) {
|
|
21910
|
+
const filterFunction = createIdFilter(filter);
|
|
21911
|
+
return filterFunction ? id => !!filterFunction(id) : undefined;
|
|
21912
|
+
}
|
|
21913
|
+
function createFilterForTransform(idFilter, codeFilter) {
|
|
21914
|
+
if (!idFilter && !codeFilter)
|
|
21915
|
+
return;
|
|
21916
|
+
const idFilterFunction = createIdFilter(idFilter);
|
|
21917
|
+
const codeFilterFunction = createCodeFilter(codeFilter);
|
|
21918
|
+
return (id, code) => {
|
|
21919
|
+
let fallback = true;
|
|
21920
|
+
if (idFilterFunction) {
|
|
21921
|
+
const idResult = idFilterFunction(id);
|
|
21922
|
+
if (typeof idResult === 'boolean') {
|
|
21923
|
+
return idResult;
|
|
21924
|
+
}
|
|
21925
|
+
fallback &&= !!idResult;
|
|
21926
|
+
}
|
|
21927
|
+
if (codeFilterFunction) {
|
|
21928
|
+
const codeResult = codeFilterFunction(code);
|
|
21929
|
+
if (typeof codeResult === 'boolean') {
|
|
21930
|
+
return codeResult;
|
|
21931
|
+
}
|
|
21932
|
+
fallback &&= !!codeResult;
|
|
21933
|
+
}
|
|
21934
|
+
return fallback;
|
|
21935
|
+
};
|
|
21936
|
+
}
|
|
21937
|
+
|
|
21817
21938
|
// This will make sure no input hook is omitted
|
|
21818
21939
|
const inputHookNames = {
|
|
21819
21940
|
buildEnd: 1,
|
|
@@ -21838,6 +21959,10 @@ class PluginDriver {
|
|
|
21838
21959
|
this.pluginCache = pluginCache;
|
|
21839
21960
|
this.sortedPlugins = new Map();
|
|
21840
21961
|
this.unfulfilledActions = new Set();
|
|
21962
|
+
this.compiledPluginFilters = {
|
|
21963
|
+
idOnlyFilter: new WeakMap(),
|
|
21964
|
+
transformFilter: new WeakMap()
|
|
21965
|
+
};
|
|
21841
21966
|
this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
|
|
21842
21967
|
this.emitFile = this.fileEmitter.emitFile.bind(this.fileEmitter);
|
|
21843
21968
|
this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter);
|
|
@@ -21964,6 +22089,24 @@ class PluginDriver {
|
|
|
21964
22089
|
// We always filter for plugins that support the hook before running it
|
|
21965
22090
|
const hook = plugin[hookName];
|
|
21966
22091
|
const handler = typeof hook === 'object' ? hook.handler : hook;
|
|
22092
|
+
if (typeof hook === 'object' && 'filter' in hook && hook.filter) {
|
|
22093
|
+
if (hookName === 'transform') {
|
|
22094
|
+
const filter = hook.filter;
|
|
22095
|
+
const hookParameters = parameters;
|
|
22096
|
+
const compiledFilter = getOrCreate(this.compiledPluginFilters.transformFilter, filter, () => createFilterForTransform(filter.id, filter.code));
|
|
22097
|
+
if (compiledFilter && !compiledFilter(hookParameters[1], hookParameters[0])) {
|
|
22098
|
+
return Promise.resolve();
|
|
22099
|
+
}
|
|
22100
|
+
}
|
|
22101
|
+
else if (hookName === 'resolveId' || hookName === 'load') {
|
|
22102
|
+
const filter = hook.filter;
|
|
22103
|
+
const hookParameters = parameters;
|
|
22104
|
+
const compiledFilter = getOrCreate(this.compiledPluginFilters.idOnlyFilter, filter, () => createFilterForId(filter.id));
|
|
22105
|
+
if (compiledFilter && !compiledFilter(hookParameters[0])) {
|
|
22106
|
+
return Promise.resolve();
|
|
22107
|
+
}
|
|
22108
|
+
}
|
|
22109
|
+
}
|
|
21967
22110
|
let context = this.pluginContexts.get(plugin);
|
|
21968
22111
|
if (replaceContext) {
|
|
21969
22112
|
context = replaceContext(context, plugin);
|
|
@@ -22375,16 +22518,6 @@ function getLogger(plugins, onLog, watchMode, logLevel) {
|
|
|
22375
22518
|
return logger;
|
|
22376
22519
|
}
|
|
22377
22520
|
|
|
22378
|
-
function ensureArray(items) {
|
|
22379
|
-
if (Array.isArray(items)) {
|
|
22380
|
-
return items.filter(Boolean);
|
|
22381
|
-
}
|
|
22382
|
-
if (items) {
|
|
22383
|
-
return [items];
|
|
22384
|
-
}
|
|
22385
|
-
return [];
|
|
22386
|
-
}
|
|
22387
|
-
|
|
22388
22521
|
async function normalizeInputOptions(config, watchMode) {
|
|
22389
22522
|
// These are options that may trigger special warnings or behaviour later
|
|
22390
22523
|
// if the user did not select an explicit value
|
|
@@ -23441,4 +23574,4 @@ async function watchInternal(configs, emitter) {
|
|
|
23441
23574
|
new Watcher(watchOptionsList, emitter);
|
|
23442
23575
|
}
|
|
23443
23576
|
|
|
23444
|
-
export { createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, getDefaultExportFromCjs, rollup, rollupInternal, version, watch };
|
|
23577
|
+
export { createFilter$1 as createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, getDefaultExportFromCjs, rollup, rollupInternal, version, watch };
|
package/dist/es/shared/watch.js
CHANGED
package/dist/getLogFilter.js
CHANGED
package/dist/loadConfigFile.js
CHANGED
package/dist/parseAst.js
CHANGED
package/dist/rollup.d.ts
CHANGED
|
@@ -272,6 +272,20 @@ export interface PluginContextMeta {
|
|
|
272
272
|
watchMode: boolean;
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
export type StringOrRegExp = string | RegExp;
|
|
276
|
+
|
|
277
|
+
export type StringFilter<Value = StringOrRegExp> =
|
|
278
|
+
| MaybeArray<Value>
|
|
279
|
+
| {
|
|
280
|
+
include?: MaybeArray<Value>;
|
|
281
|
+
exclude?: MaybeArray<Value>;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export interface HookFilter {
|
|
285
|
+
id?: StringFilter;
|
|
286
|
+
code?: StringFilter;
|
|
287
|
+
}
|
|
288
|
+
|
|
275
289
|
export interface ResolvedId extends ModuleOptions {
|
|
276
290
|
external: boolean | 'absolute';
|
|
277
291
|
id: string;
|
|
@@ -526,11 +540,20 @@ type MakeAsync<Function_> = Function_ extends (
|
|
|
526
540
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
527
541
|
export type ObjectHook<T, O = {}> = T | ({ handler: T; order?: 'pre' | 'post' | null } & O);
|
|
528
542
|
|
|
543
|
+
export type HookFilterExtension<K extends keyof FunctionPluginHooks> = K extends 'transform'
|
|
544
|
+
? { filter?: HookFilter }
|
|
545
|
+
: K extends 'load'
|
|
546
|
+
? { filter?: Pick<HookFilter, 'id'> }
|
|
547
|
+
: K extends 'resolveId'
|
|
548
|
+
? { filter?: { id: StringFilter<RegExp> } }
|
|
549
|
+
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
550
|
+
{};
|
|
551
|
+
|
|
529
552
|
export type PluginHooks = {
|
|
530
553
|
[K in keyof FunctionPluginHooks]: ObjectHook<
|
|
531
554
|
K extends AsyncPluginHooks ? MakeAsync<FunctionPluginHooks[K]> : FunctionPluginHooks[K],
|
|
532
555
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
533
|
-
K extends ParallelPluginHooks ? { sequential?: boolean } : {}
|
|
556
|
+
HookFilterExtension<K> & (K extends ParallelPluginHooks ? { sequential?: boolean } : {})
|
|
534
557
|
>;
|
|
535
558
|
};
|
|
536
559
|
|
package/dist/rollup.js
CHANGED
package/dist/shared/index.js
CHANGED
package/dist/shared/parseAst.js
CHANGED