rollup 4.37.0 → 4.39.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 CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  /*
3
3
  @license
4
- Rollup.js v4.37.0
5
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
4
+ Rollup.js v4.39.0
5
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
6
6
 
7
7
  https://github.com/rollup/rollup
8
8
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/es/rollup.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
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.37.0";
18
+ var version = "4.39.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 pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
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 = pm(pattern, { dot: true });
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
  }
@@ -17964,6 +17964,8 @@ class Chunk {
17964
17964
  this.renderedModules = Object.create(null);
17965
17965
  this.sortedExportNames = null;
17966
17966
  this.strictFacade = false;
17967
+ /** Modules with 'allow-extension' that should have preserved exports within the chunk */
17968
+ this.allowExtensionModules = new Set();
17967
17969
  this.execIndex = orderedModules.length > 0 ? orderedModules[0].execIndex : Infinity;
17968
17970
  const chunkModules = new Set(orderedModules);
17969
17971
  for (const module of orderedModules) {
@@ -18069,6 +18071,16 @@ class Chunk {
18069
18071
  remainingExports.delete(variable);
18070
18072
  }
18071
18073
  }
18074
+ for (const module of this.allowExtensionModules) {
18075
+ const exportNamesByVariable = module.getExportNamesByVariable();
18076
+ for (const [variable, exportNames] of exportNamesByVariable) {
18077
+ this.exportNamesByVariable.set(variable, [...exportNames]);
18078
+ for (const exportName of exportNames) {
18079
+ this.exportsByName.set(exportName, variable);
18080
+ }
18081
+ remainingExports.delete(variable);
18082
+ }
18083
+ }
18072
18084
  if (this.outputOptions.minifyInternalExports) {
18073
18085
  assignExportsToMangledNames(remainingExports, this.exportsByName, this.exportNamesByVariable);
18074
18086
  }
@@ -18083,16 +18095,19 @@ class Chunk {
18083
18095
  const entryModules = new Set([...this.entryModules, ...this.implicitEntryModules]);
18084
18096
  const exposedVariables = new Set(this.dynamicEntryModules.map(({ namespace }) => namespace));
18085
18097
  for (const module of entryModules) {
18086
- if (module.preserveSignature) {
18087
- for (const exportedVariable of module.getExportNamesByVariable().keys()) {
18088
- // We need to expose all entry exports from this chunk
18089
- if (this.chunkByModule.get(exportedVariable.module) === this) {
18090
- exposedVariables.add(exportedVariable);
18098
+ if (module.preserveSignature === 'allow-extension') {
18099
+ const canPreserveExports = this.canPreserveModuleExports(module);
18100
+ if (canPreserveExports) {
18101
+ this.allowExtensionModules.add(module);
18102
+ if (!this.facadeModule) {
18103
+ this.facadeModule = module;
18104
+ this.strictFacade = false;
18105
+ this.assignFacadeName({}, module, this.outputOptions.preserveModules);
18091
18106
  }
18107
+ this.facadeChunkByModule.set(module, this);
18108
+ continue;
18092
18109
  }
18093
18110
  }
18094
- }
18095
- for (const module of entryModules) {
18096
18111
  const requiredFacades = Array.from(new Set(module.chunkNames.filter(({ isUserDefined }) => isUserDefined).map(({ name }) => name)),
18097
18112
  // mapping must run after Set 'name' dedupe
18098
18113
  name => ({
@@ -18147,6 +18162,26 @@ class Chunk {
18147
18162
  }
18148
18163
  return facades;
18149
18164
  }
18165
+ canPreserveModuleExports(module) {
18166
+ const exportNamesByVariable = module.getExportNamesByVariable();
18167
+ // Check for conflicts - an export name is a conflict if it points to a different module or definition
18168
+ for (const [variable, exportNames] of exportNamesByVariable) {
18169
+ for (const exportName of exportNames) {
18170
+ const existingVariable = this.exportsByName.get(exportName);
18171
+ // It's ok if the same export name in two modules references the exact same variable
18172
+ if (existingVariable && existingVariable !== variable) {
18173
+ return false;
18174
+ }
18175
+ }
18176
+ }
18177
+ // No actual conflicts found, add export names for future conflict checks
18178
+ for (const [variable, exportNames] of exportNamesByVariable) {
18179
+ for (const exportName of exportNames) {
18180
+ this.exportsByName.set(exportName, variable);
18181
+ }
18182
+ }
18183
+ return true;
18184
+ }
18150
18185
  getChunkName() {
18151
18186
  return (this.name ??= this.outputOptions.sanitizeFileName(this.getFallbackChunkName()));
18152
18187
  }
@@ -21814,6 +21849,127 @@ function getPluginContext(plugin, pluginCache, graph, options, fileEmitter, exis
21814
21849
  };
21815
21850
  }
21816
21851
 
21852
+ function ensureArray(items) {
21853
+ if (Array.isArray(items)) {
21854
+ return items.filter(Boolean);
21855
+ }
21856
+ if (items) {
21857
+ return [items];
21858
+ }
21859
+ return [];
21860
+ }
21861
+
21862
+ const FALLBACK_TRUE = 1;
21863
+ const FALLBACK_FALSE = 0;
21864
+ function getMatcherString(glob, cwd) {
21865
+ if (glob.startsWith('**') || isAbsolute$1(glob)) {
21866
+ return normalize(glob);
21867
+ }
21868
+ const resolved = resolve$1(cwd, glob);
21869
+ return normalize(resolved);
21870
+ }
21871
+ function patternToIdFilter(pattern) {
21872
+ if (pattern instanceof RegExp) {
21873
+ return (id) => {
21874
+ const normalizedId = normalize(id);
21875
+ const result = pattern.test(normalizedId);
21876
+ pattern.lastIndex = 0;
21877
+ return result;
21878
+ };
21879
+ }
21880
+ const cwd = process.cwd();
21881
+ const glob = getMatcherString(pattern, cwd);
21882
+ const matcher = picomatch(glob, { dot: true });
21883
+ return (id) => {
21884
+ const normalizedId = normalize(id);
21885
+ return matcher(normalizedId);
21886
+ };
21887
+ }
21888
+ function patternToCodeFilter(pattern) {
21889
+ if (pattern instanceof RegExp) {
21890
+ return (code) => {
21891
+ const result = pattern.test(code);
21892
+ pattern.lastIndex = 0;
21893
+ return result;
21894
+ };
21895
+ }
21896
+ return (code) => code.includes(pattern);
21897
+ }
21898
+ function createFilter(exclude, include) {
21899
+ if (!exclude && !include) {
21900
+ return;
21901
+ }
21902
+ return input => {
21903
+ if (exclude?.some(filter => filter(input))) {
21904
+ return false;
21905
+ }
21906
+ if (include?.some(filter => filter(input))) {
21907
+ return true;
21908
+ }
21909
+ return !!include && include.length > 0 ? FALLBACK_FALSE : FALLBACK_TRUE;
21910
+ };
21911
+ }
21912
+ function normalizeFilter(filter) {
21913
+ if (typeof filter === 'string' || filter instanceof RegExp) {
21914
+ return {
21915
+ include: [filter]
21916
+ };
21917
+ }
21918
+ if (Array.isArray(filter)) {
21919
+ return {
21920
+ include: ensureArray(filter)
21921
+ };
21922
+ }
21923
+ return {
21924
+ exclude: filter.exclude ? ensureArray(filter.exclude) : undefined,
21925
+ include: filter.include ? ensureArray(filter.include) : undefined
21926
+ };
21927
+ }
21928
+ function createIdFilter(filter) {
21929
+ if (!filter)
21930
+ return;
21931
+ const { exclude, include } = normalizeFilter(filter);
21932
+ const excludeFilter = exclude?.map(patternToIdFilter);
21933
+ const includeFilter = include?.map(patternToIdFilter);
21934
+ return createFilter(excludeFilter, includeFilter);
21935
+ }
21936
+ function createCodeFilter(filter) {
21937
+ if (!filter)
21938
+ return;
21939
+ const { exclude, include } = normalizeFilter(filter);
21940
+ const excludeFilter = exclude?.map(patternToCodeFilter);
21941
+ const includeFilter = include?.map(patternToCodeFilter);
21942
+ return createFilter(excludeFilter, includeFilter);
21943
+ }
21944
+ function createFilterForId(filter) {
21945
+ const filterFunction = createIdFilter(filter);
21946
+ return filterFunction ? id => !!filterFunction(id) : undefined;
21947
+ }
21948
+ function createFilterForTransform(idFilter, codeFilter) {
21949
+ if (!idFilter && !codeFilter)
21950
+ return;
21951
+ const idFilterFunction = createIdFilter(idFilter);
21952
+ const codeFilterFunction = createCodeFilter(codeFilter);
21953
+ return (id, code) => {
21954
+ let fallback = true;
21955
+ if (idFilterFunction) {
21956
+ const idResult = idFilterFunction(id);
21957
+ if (typeof idResult === 'boolean') {
21958
+ return idResult;
21959
+ }
21960
+ fallback &&= !!idResult;
21961
+ }
21962
+ if (codeFilterFunction) {
21963
+ const codeResult = codeFilterFunction(code);
21964
+ if (typeof codeResult === 'boolean') {
21965
+ return codeResult;
21966
+ }
21967
+ fallback &&= !!codeResult;
21968
+ }
21969
+ return fallback;
21970
+ };
21971
+ }
21972
+
21817
21973
  // This will make sure no input hook is omitted
21818
21974
  const inputHookNames = {
21819
21975
  buildEnd: 1,
@@ -21838,6 +21994,10 @@ class PluginDriver {
21838
21994
  this.pluginCache = pluginCache;
21839
21995
  this.sortedPlugins = new Map();
21840
21996
  this.unfulfilledActions = new Set();
21997
+ this.compiledPluginFilters = {
21998
+ idOnlyFilter: new WeakMap(),
21999
+ transformFilter: new WeakMap()
22000
+ };
21841
22001
  this.fileEmitter = new FileEmitter(graph, options, basePluginDriver && basePluginDriver.fileEmitter);
21842
22002
  this.emitFile = this.fileEmitter.emitFile.bind(this.fileEmitter);
21843
22003
  this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter);
@@ -21964,6 +22124,24 @@ class PluginDriver {
21964
22124
  // We always filter for plugins that support the hook before running it
21965
22125
  const hook = plugin[hookName];
21966
22126
  const handler = typeof hook === 'object' ? hook.handler : hook;
22127
+ if (typeof hook === 'object' && 'filter' in hook && hook.filter) {
22128
+ if (hookName === 'transform') {
22129
+ const filter = hook.filter;
22130
+ const hookParameters = parameters;
22131
+ const compiledFilter = getOrCreate(this.compiledPluginFilters.transformFilter, filter, () => createFilterForTransform(filter.id, filter.code));
22132
+ if (compiledFilter && !compiledFilter(hookParameters[1], hookParameters[0])) {
22133
+ return Promise.resolve();
22134
+ }
22135
+ }
22136
+ else if (hookName === 'resolveId' || hookName === 'load') {
22137
+ const filter = hook.filter;
22138
+ const hookParameters = parameters;
22139
+ const compiledFilter = getOrCreate(this.compiledPluginFilters.idOnlyFilter, filter, () => createFilterForId(filter.id));
22140
+ if (compiledFilter && !compiledFilter(hookParameters[0])) {
22141
+ return Promise.resolve();
22142
+ }
22143
+ }
22144
+ }
21967
22145
  let context = this.pluginContexts.get(plugin);
21968
22146
  if (replaceContext) {
21969
22147
  context = replaceContext(context, plugin);
@@ -22375,16 +22553,6 @@ function getLogger(plugins, onLog, watchMode, logLevel) {
22375
22553
  return logger;
22376
22554
  }
22377
22555
 
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
22556
  async function normalizeInputOptions(config, watchMode) {
22389
22557
  // These are options that may trigger special warnings or behaviour later
22390
22558
  // if the user did not select an explicit value
@@ -23441,4 +23609,4 @@ async function watchInternal(configs, emitter) {
23441
23609
  new Watcher(watchOptionsList, emitter);
23442
23610
  }
23443
23611
 
23444
- export { createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, getDefaultExportFromCjs, rollup, rollupInternal, version, watch };
23612
+ export { createFilter$1 as createFilter, defineConfig, fseventsImporter, getAugmentedNamespace, getDefaultExportFromCjs, rollup, rollupInternal, version, watch };
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
package/dist/parseAst.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
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
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.37.0
4
- Sun, 23 Mar 2025 14:56:38 GMT - commit 8b1c634d945dda9294cf579de68c4b223c618e7f
3
+ Rollup.js v4.39.0
4
+ Wed, 02 Apr 2025 04:49:00 GMT - commit 5c001245779063abac3899aa9d25294ab003581b
5
5
 
6
6
  https://github.com/rollup/rollup
7
7