@@ -18,7 +18,6 @@ import {
1818import { dts } from 'rolldown-plugin-dts' ;
1919import { toPosixPath } from '../../../utils/path' ;
2020import type { NormalizedEntryPoint , NormalizedLibraryOptions } from '../options' ;
21- import { type EntryPointLookup , createEntryDirectoryLookup } from './entry-points' ;
2221import {
2322 FESM_OUTPUT_DIR ,
2423 type MemoryOutputFile ,
@@ -87,15 +86,13 @@ interface MultiBundleOutput {
8786 * @param esmFiles Map of virtual ESM output file paths to their content.
8887 * @param dtsFiles Map of virtual TypeScript declaration file paths to their content.
8988 * @param options The normalized library builder options.
90- * @param findEntryPoint Optional lookup function to find an entry point by file path.
9189 * @returns A promise resolving to the bundled output files and bundle cache results.
9290 */
9391export async function bundleEntryPoints (
9492 items : readonly BundleEntryPointInput [ ] ,
9593 esmFiles : ReadonlyMap < string , string > ,
9694 dtsFiles : ReadonlyMap < string , string > ,
9795 options : NormalizedLibraryOptions ,
98- findEntryPoint : EntryPointLookup = createEntryDirectoryLookup ( options . entryPoints . values ( ) ) ,
9996) : Promise < BundleEntryPointsOutput > {
10097 const bundleResults = new Map < string , BundleResult > ( ) ;
10198 if ( items . length === 0 ) {
@@ -115,8 +112,8 @@ export async function bundleEntryPoints(
115112 }
116113
117114 const [ esmOutput , dtsOutput ] = await Promise . all ( [
118- bundleAllEsm ( esmEntryPoints , esmFiles , options , findEntryPoint ) ,
119- bundleAllDts ( dtsEntryPoints , dtsFiles , options , findEntryPoint ) ,
115+ bundleAllEsm ( esmEntryPoints , esmFiles , options ) ,
116+ bundleAllDts ( dtsEntryPoints , dtsFiles , options ) ,
120117 ] ) ;
121118
122119 for ( const { entryPoint, previousBundleResult } of items ) {
@@ -139,8 +136,6 @@ export async function bundleEntryPoints(
139136 } ;
140137}
141138
142- export { type EntryPointLookup , createEntryDirectoryLookup } ;
143-
144139/**
145140 * Generates the Rolldown input mapping object from the specified entry points.
146141 *
@@ -170,14 +165,12 @@ function resolveEntryInputMap(
170165 * @param files Map of virtual file paths to their content.
171166 * @param extensions Candidate extensions to probe when resolving extensionless module specifiers.
172167 * @param includeMap Whether source map files should also be loaded from the memory map.
173- * @param findEntryPoint Lookup function to identify the entry point owning a file path.
174168 * @returns A Rolldown plugin instance.
175169 */
176170function createMemoryFileLoaderPlugin (
177171 files : ReadonlyMap < string , string > ,
178172 extensions : readonly string [ ] ,
179173 includeMap : boolean ,
180- findEntryPoint : EntryPointLookup ,
181174) : Plugin {
182175 return {
183176 name : 'memory-file-loader' ,
@@ -217,15 +210,6 @@ function createMemoryFileLoaderPlugin(
217210 }
218211 }
219212
220- const importerEp = findEntryPoint ( importerPosix ) ;
221- const targetEp = findEntryPoint ( resolvedCandidate ?? resolved ) ;
222- if ( importerEp && targetEp && importerEp . name !== targetEp . name ) {
223- throw new Error (
224- `Entry point '${ importerEp . name } ' cannot import '${ id } ' from sibling entry point directly. ` +
225- `Import using the entry point package name instead.` ,
226- ) ;
227- }
228-
229213 if ( resolvedCandidate ) {
230214 return { id : resolvedCandidate , external : false } ;
231215 }
@@ -247,27 +231,6 @@ function createMemoryFileLoaderPlugin(
247231 } ;
248232}
249233
250- /**
251- * Resolves the bundle prefix name for a shared chunk based on the entry point owning its modules.
252- *
253- * @param findEntryPoint Lookup function to identify entry points of module IDs.
254- * @param moduleIds List of module IDs contained within the chunk.
255- * @returns The bundle name if a containing entry point was found, otherwise undefined.
256- */
257- function resolveChunkBundleName (
258- findEntryPoint : EntryPointLookup ,
259- moduleIds : readonly string [ ] ,
260- ) : string | undefined {
261- for ( const modId of moduleIds ) {
262- const ep = findEntryPoint ( modId ) ;
263- if ( ep ) {
264- return ep . bundleName ;
265- }
266- }
267-
268- return undefined ;
269- }
270-
271234/**
272235 * Processes Rolldown output assets and chunks, extracting emitted files and computing
273236 * the transitive set of module IDs belonging to each entry point bundle.
@@ -352,7 +315,6 @@ async function executeMultiBundle(
352315 preserveSymlinks : boolean ,
353316 extension : 'mjs' | 'd.ts' ,
354317 sourcemap : boolean ,
355- findEntryPoint : EntryPointLookup ,
356318) : Promise < MultiBundleOutput > {
357319 const isDts = extension === 'd.ts' ;
358320 const dir = isDts ? TYPES_OUTPUT_DIR : FESM_OUTPUT_DIR ;
@@ -373,12 +335,7 @@ async function executeMultiBundle(
373335 format : 'es' ,
374336 dir,
375337 entryFileNames : `[name].${ extension } ` ,
376- chunkFileNames : ( chunk ) => {
377- const bundleName = resolveChunkBundleName ( findEntryPoint , chunk . moduleIds ) ;
378- const prefix = bundleName ? `${ bundleName } -` : '' ;
379-
380- return `${ prefix } [name]-[hash].${ extension } ` ;
381- } ,
338+ chunkFileNames : `[name]-[hash].${ extension } ` ,
382339 sourcemap,
383340 hoistTransitiveImports : false ,
384341 comments : { jsdoc : isDts , legal : true , annotation : true } ,
@@ -396,26 +353,23 @@ async function executeMultiBundle(
396353 * @param entryPoints The entry points to bundle.
397354 * @param esmFiles Map of virtual ESM output file paths to contents.
398355 * @param options The normalized library options.
399- * @param findEntryPoint Lookup function to resolve entry point ownership.
400356 * @returns A promise resolving to the multi-bundle output.
401357 */
402358async function bundleAllEsm (
403359 entryPoints : readonly NormalizedEntryPoint [ ] ,
404360 esmFiles : ReadonlyMap < string , string > ,
405361 options : NormalizedLibraryOptions ,
406- findEntryPoint : EntryPointLookup ,
407362) : Promise < MultiBundleOutput > {
408363 if ( entryPoints . length === 0 ) {
409364 return { filesToEmit : [ ] , moduleIdsByBundle : new Map ( ) } ;
410365 }
411366
412367 return executeMultiBundle (
413368 resolveEntryInputMap ( entryPoints , false ) ,
414- [ createMemoryFileLoaderPlugin ( esmFiles , ESM_EXTENSIONS , true , findEntryPoint ) ] ,
369+ [ createMemoryFileLoaderPlugin ( esmFiles , ESM_EXTENSIONS , true ) ] ,
415370 options . preserveSymlinks ,
416371 'mjs' ,
417372 true ,
418- findEntryPoint ,
419373 ) ;
420374}
421375
@@ -425,14 +379,12 @@ async function bundleAllEsm(
425379 * @param entryPoints The entry points to bundle.
426380 * @param dtsFiles Map of virtual declaration output file paths to contents.
427381 * @param options The normalized library options.
428- * @param findEntryPoint Lookup function to resolve entry point ownership.
429382 * @returns A promise resolving to the multi-bundle output.
430383 */
431384async function bundleAllDts (
432385 entryPoints : readonly NormalizedEntryPoint [ ] ,
433386 dtsFiles : ReadonlyMap < string , string > ,
434387 options : NormalizedLibraryOptions ,
435- findEntryPoint : EntryPointLookup ,
436388) : Promise < MultiBundleOutput > {
437389 if ( entryPoints . length === 0 ) {
438390 return { filesToEmit : [ ] , moduleIdsByBundle : new Map ( ) } ;
@@ -459,13 +411,9 @@ async function bundleAllDts(
459411
460412 return executeMultiBundle (
461413 resolveEntryInputMap ( entryPoints , true ) ,
462- [
463- createMemoryFileLoaderPlugin ( dtsFiles , DTS_EXTENSIONS , dtsSourcemap , findEntryPoint ) ,
464- ...dtsPlugins ,
465- ] ,
414+ [ createMemoryFileLoaderPlugin ( dtsFiles , DTS_EXTENSIONS , dtsSourcemap ) , ...dtsPlugins ] ,
466415 options . preserveSymlinks ,
467416 'd.ts' ,
468417 dtsSourcemap ,
469- findEntryPoint ,
470418 ) ;
471419}
0 commit comments