@@ -19,22 +19,22 @@ const PLACEHOLDER_SUFFIX = "__//!!##";
1919/**
2020 * Import specifiers must have forward slashes
2121 */
22- function toImportSpecifier ( file : string ) {
22+ const toImportSpecifier = ( file : string ) => {
2323 const specifier = posix . normalize ( file ) . replace ( / \\ / g, "/" ) ;
2424
2525 if ( ! specifier . startsWith ( "." ) ) {
2626 return `./${ specifier } ` ;
2727 }
2828
2929 return specifier ;
30- }
30+ } ;
3131
3232// Create a valid JS identifier out of the project relative specifier.
3333// Note that we only need to deal with strings that _must_ have been
3434// valid file names in Windows, macOS and Linux and every identifier we
3535// create here will be prefixed with at least one "$". This greatly
3636// simplifies the invalid characters we have to account for.
37- export function specifierToIdentifier ( specifier : string , used : Set < string > ) {
37+ export const specifierToIdentifier = ( specifier : string , used : Set < string > ) => {
3838 // specifier = specifier.replace(/^(?:\.\/pkg)\//, "");
3939 const ext = path . extname ( specifier ) ;
4040 if ( ext ) {
@@ -62,29 +62,32 @@ export function specifierToIdentifier(specifier: string, used: Set<string>) {
6262 if ( used . has ( ident ) ) {
6363 let check = ident ;
6464 let i = 1 ;
65+
6566 while ( used . has ( check ) ) {
6667 check = `${ ident } _${ i ++ } ` ;
6768 }
69+
6870 ident = check ;
6971 }
7072
7173 used . add ( ident ) ;
74+
7275 return ident ;
73- }
76+ } ;
7477
75- const getSortFn = function ( ) {
78+ const getSortFn = ( ) => {
7679 const naturalCollator = new Intl . Collator ( undefined , { numeric : true } ) ;
7780
7881 return naturalCollator . compare ;
7982} ;
8083
81- const placeholder = function ( text : string ) {
84+ const placeholder = ( text : string ) => {
8285 return `${ PLACEHOLDER_PREFIX } ${ text } ${ PLACEHOLDER_SUFFIX } ` ;
8386} ;
8487
85- export async function writeManifestToString (
88+ export const writeManifestToString = async (
8689 collection : Array < [ string , Array < [ string , unknown ] > ] > ,
87- ) {
90+ ) => {
8891 const sortFn = getSortFn ( ) ;
8992
9093 const used = new Set < string > ( ) ;
@@ -102,7 +105,7 @@ export async function writeManifestToString(
102105 `import * as ${ IMPORT_PREFIX } ${ identifier } from "${ specifier } ";` ,
103106 ) ;
104107
105- const ref = function ( target : unknown ) {
108+ const ref = ( target : unknown ) => {
106109 const name = ( target as { name : string } ) . name ;
107110
108111 return placeholder ( `${ IMPORT_PREFIX } ${ identifier } .${ name } ` ) ;
@@ -132,9 +135,11 @@ export const manifest = ${manifestSerialized};
132135 const manifestStr = await formatter . format ( output ) ;
133136
134137 return manifestStr ;
135- }
138+ } ;
136139
137- export async function buildManifest ( options : collector . CollectExportsOptions ) {
140+ export const buildManifest = async (
141+ options : collector . CollectExportsOptions ,
142+ ) => {
138143 const collection = await collector . collectExports ( options ) ;
139144
140145 const manifestStr = await writeManifestToString ( collection ) ;
@@ -152,4 +157,4 @@ export async function buildManifest(options: collector.CollectExportsOptions) {
152157 `%cThe manifest file has been generated for ${ exportCount } exports in ${ exportModules . length } modules.` ,
153158 "color: blue" ,
154159 ) ;
155- }
160+ } ;
0 commit comments