diff --git a/src/Chunk.ts b/src/Chunk.ts index 2f19bd1e7d8..94eab50c2fa 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -450,7 +450,7 @@ export default class Chunk { const extension = extname(sanitizedId); const fileName = renderNamePattern(pattern, 'output.entryFileNames', { assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension), - ext: () => extension.substr(1), + ext: () => extension.substring(1), extname: () => extension, format: () => options.format as string, name: () => this.getChunkName() @@ -466,7 +466,7 @@ export default class Chunk { const extension = extname(sanitizedId); const fileName = renderNamePattern(pattern, 'output.entryFileNames', { assetExtname: () => (NON_ASSET_EXTENSIONS.includes(extension) ? '' : extension), - ext: () => extension.substr(1), + ext: () => extension.substring(1), extname: () => extension, format: () => options.format as string, name: () => getAliasName(sanitizedId) @@ -1161,7 +1161,7 @@ export default class Chunk { let imported: string; let needsLiveBinding = false; if (exportName[0] === '*') { - const id = exportName.substr(1); + const id = exportName.substring(1); if (interop(id) === 'defaultOnly') { this.inputOptions.onwarn(errUnexpectedNamespaceReexport(id)); } diff --git a/src/ast/nodes/MetaProperty.ts b/src/ast/nodes/MetaProperty.ts index e8868968998..5ec993c9bc0 100644 --- a/src/ast/nodes/MetaProperty.ts +++ b/src/ast/nodes/MetaProperty.ts @@ -43,7 +43,7 @@ export default class MetaProperty extends NodeBase { getReferencedFileName(outputPluginDriver: PluginDriver): string | null { const metaProperty = this.metaProperty as string | null; if (metaProperty && metaProperty.startsWith(FILE_PREFIX)) { - return outputPluginDriver.getFileName(metaProperty.substr(FILE_PREFIX.length)); + return outputPluginDriver.getFileName(metaProperty.substring(FILE_PREFIX.length)); } return null; } @@ -91,7 +91,7 @@ export default class MetaProperty extends NodeBase { let chunkReferenceId: string | null = null; let fileName: string; if (metaProperty.startsWith(FILE_PREFIX)) { - referenceId = metaProperty.substr(FILE_PREFIX.length); + referenceId = metaProperty.substring(FILE_PREFIX.length); fileName = outputPluginDriver.getFileName(referenceId); } else if (metaProperty.startsWith(ASSET_PREFIX)) { warnDeprecation( @@ -99,7 +99,7 @@ export default class MetaProperty extends NodeBase { true, this.context.options ); - assetReferenceId = metaProperty.substr(ASSET_PREFIX.length); + assetReferenceId = metaProperty.substring(ASSET_PREFIX.length); fileName = outputPluginDriver.getFileName(assetReferenceId); } else { warnDeprecation( @@ -107,7 +107,7 @@ export default class MetaProperty extends NodeBase { true, this.context.options ); - chunkReferenceId = metaProperty.substr(CHUNK_PREFIX.length); + chunkReferenceId = metaProperty.substring(CHUNK_PREFIX.length); fileName = outputPluginDriver.getFileName(chunkReferenceId); } const relativePath = normalize(relative(dirname(chunkId), fileName)); diff --git a/src/utils/FileEmitter.ts b/src/utils/FileEmitter.ts index a71b5b0060d..dcb4579edf2 100644 --- a/src/utils/FileEmitter.ts +++ b/src/utils/FileEmitter.ts @@ -42,16 +42,17 @@ function generateAssetFileName( : outputOptions.assetFileNames, 'output.assetFileNames', { - ext: () => extname(emittedName).substr(1), + ext: () => extname(emittedName).substring(1), extname: () => extname(emittedName), hash() { - const hash = createHash(); - hash.update(emittedName); - hash.update(':'); - hash.update(source); - return hash.digest('hex').substr(0, 8); + return createHash() + .update(emittedName) + .update(':') + .update(source) + .digest('hex') + .substring(0, 8); }, - name: () => emittedName.substr(0, emittedName.length - extname(emittedName).length) + name: () => emittedName.substring(0, emittedName.length - extname(emittedName).length) } ), bundle diff --git a/src/utils/relativeId.ts b/src/utils/relativeId.ts index 0502c5563d0..743f6a27ef2 100644 --- a/src/utils/relativeId.ts +++ b/src/utils/relativeId.ts @@ -2,7 +2,7 @@ import { basename, extname, isAbsolute, relative, resolve } from './path'; export function getAliasName(id: string): string { const base = basename(id); - return base.substr(0, base.length - extname(id).length); + return base.substring(0, base.length - extname(id).length); } export default function relativeId(id: string): string { diff --git a/src/utils/renderNamePattern.ts b/src/utils/renderNamePattern.ts index 0bf89b563b7..cccff7f8de5 100644 --- a/src/utils/renderNamePattern.ts +++ b/src/utils/renderNamePattern.ts @@ -35,7 +35,7 @@ export function makeUnique(name: string, existingNames: Record) if (!existingNamesLowercase.has(name.toLocaleLowerCase())) return name; const ext = extname(name); - name = name.substr(0, name.length - ext.length); + name = name.substring(0, name.length - ext.length); let uniqueName: string, uniqueIndex = 1; while (existingNamesLowercase.has((uniqueName = name + ++uniqueIndex + ext).toLowerCase()));