MCPcopy
hub / github.com/rollup/rollup / getPreserveModulesChunkNameFromModule

Method getPreserveModulesChunkNameFromModule

src/Chunk.ts:1155–1179  ·  view source on GitHub ↗
(module: Module)

Source from the content-addressed store, hash-verified

1153 }
1154
1155 private getPreserveModulesChunkNameFromModule(module: Module): string {
1156 const predefinedChunkName = getPredefinedChunkNameFromModule(module);
1157 if (predefinedChunkName) return predefinedChunkName;
1158 const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
1159 const sanitizedId = sanitizeFileName(normalize(module.id.split(QUERY_HASH_REGEX, 1)[0]));
1160 const extensionName = extname(sanitizedId);
1161 const idWithoutExtension = NON_ASSET_EXTENSIONS.has(extensionName)
1162 ? sanitizedId.slice(0, -extensionName.length)
1163 : sanitizedId;
1164 if (isAbsolute(idWithoutExtension)) {
1165 if (preserveModulesRoot && resolve(idWithoutExtension).startsWith(preserveModulesRoot)) {
1166 return idWithoutExtension.slice(preserveModulesRoot.length).replace(/^[/\\]/, '');
1167 } else {
1168 // handle edge case in Windows
1169 if (this.inputBase === '/' && idWithoutExtension[0] !== '/') {
1170 return relative(this.inputBase, idWithoutExtension.replace(/^[a-zA-Z]:[/\\]/, '/'));
1171 }
1172 return relative(this.inputBase, idWithoutExtension);
1173 }
1174 } else {
1175 return (
1176 this.outputOptions.virtualDirname.replace(/\/$/, '') + '/' + basename(idWithoutExtension)
1177 );
1178 }
1179 }
1180
1181 private getReexportSpecifiers(): Map<Chunk | ExternalChunk, ReexportSpecifier[]> {
1182 const { externalLiveBindings, interop } = this.outputOptions;

Callers 1

assignFacadeNameMethod · 0.95

Calls 9

normalizeFunction · 0.90
extnameFunction · 0.90
isAbsoluteFunction · 0.90
resolveFunction · 0.90
relativeFunction · 0.90
basenameFunction · 0.90
hasMethod · 0.65
sanitizeFileNameFunction · 0.50

Tested by

no test coverage detected