-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: react/utils build setting update (#709)
- Loading branch information
Showing
2 changed files
with
52 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,42 @@ | ||
const PATH_PREFIX_MAP = { | ||
_internal: '_internal', | ||
utils: 'utils', | ||
components: 'components', | ||
hooks: 'hooks', | ||
}; | ||
|
||
const getEntryFileNames = (name, format, path) => { | ||
const cleanName = name.replace(`${path}-`, ''); | ||
return `${path}/${cleanName}/index.${format}`; | ||
}; | ||
|
||
export const getFormatEntryFileNames = (chunkInfo, format) => { | ||
const prefixMap = { | ||
_internal: '_internal', | ||
utils: 'utils', | ||
components: 'components', | ||
hooks: 'hooks', | ||
}; | ||
|
||
for (const [key, value] of Object.entries(prefixMap)) { | ||
if (chunkInfo.name === `${key}-index`) { | ||
const { name } = chunkInfo; | ||
|
||
for (const [key, value] of Object.entries(PATH_PREFIX_MAP)) { | ||
// 각 모듈의 index | ||
if (name === `${key}-index`) { | ||
return `${key}/index.${format}`; | ||
} | ||
|
||
if (chunkInfo.name.startsWith(value)) { | ||
return getEntryFileNames(chunkInfo.name, format, key); | ||
// 기본 모듈 | ||
if (name.startsWith(value)) { | ||
return getEntryFileNames(name, format, key); | ||
} | ||
} | ||
|
||
return `[name].${format}`; // 기본 파일 이름 | ||
// root index | ||
return `[name].${format}`; | ||
}; | ||
|
||
export const getSubEntryMap = (keys, path) => { | ||
const getEntryExtension = path === 'components' ? 'tsx' : 'ts'; | ||
|
||
return keys.reduce((acc, entry) => { | ||
acc[`${path}-${entry}`] = `./src/${path}/${ | ||
entry === 'index' | ||
? 'index.ts' | ||
: `${entry}/index.${path === 'components' ? 'tsx' : 'ts'}` | ||
}`; | ||
const entryPath = | ||
entry === 'index' ? 'index.ts' : `${entry}/index.${getEntryExtension}`; | ||
|
||
acc[`${path}-${entry}`] = `./src/${path}/${entryPath}`; | ||
return acc; | ||
}, {}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,48 @@ | ||
const PATH_PREFIX_MAP = { | ||
array: 'array', | ||
clipboard: 'clipboard', | ||
common: 'common', | ||
date: 'date', | ||
device: 'device', | ||
file: 'file', | ||
formatter: 'formatter', | ||
math: 'math', | ||
object: 'object', | ||
regex: 'regex', | ||
storage: 'storage', | ||
string: 'string', | ||
style: 'style', | ||
validator: 'validator', | ||
}; | ||
|
||
const getEntryFileNames = (name, format, path) => { | ||
const cleanName = name.replace(`${path}-`, ''); | ||
return `${path}/${cleanName}/index.${format}`; | ||
}; | ||
|
||
export const getFormatEntryFileNames = (chunkInfo, format) => { | ||
const prefixMap = { | ||
array: 'array', | ||
clipboard: 'clipboard', | ||
common: 'common', | ||
date: 'date', | ||
device: 'device', | ||
file: 'file', | ||
formatter: 'formatter', | ||
math: 'math', | ||
object: 'object', | ||
regex: 'regex', | ||
storage: 'storage', | ||
string: 'string', | ||
style: 'style', | ||
validator: 'validator', | ||
}; | ||
const { name } = chunkInfo; | ||
|
||
for (const [key, value] of Object.entries(prefixMap)) { | ||
if (chunkInfo.name === `${key}-index`) { | ||
for (const [key, value] of Object.entries(PATH_PREFIX_MAP)) { | ||
// 각 모듈의 index | ||
if (name === `${key}-index`) { | ||
return `${key}/index.${format}`; | ||
} | ||
|
||
if (chunkInfo.name.startsWith(value)) { | ||
return getEntryFileNames(chunkInfo.name, format, key); | ||
// 기본 모듈 | ||
if (name.startsWith(value)) { | ||
return getEntryFileNames(name, format, key); | ||
} | ||
} | ||
|
||
return `[name].${format}`; // 기본 파일 이름 | ||
// root index | ||
return `[name].${format}`; | ||
}; | ||
|
||
export const getSubEntryMap = (keys, path) => { | ||
return keys.reduce((acc, entry) => { | ||
acc[`${path}-${entry}`] = `./src/${path}/${ | ||
entry === 'index' ? 'index.ts' : `${entry}/index.ts` | ||
}`; | ||
const entryPath = entry === 'index' ? 'index.ts' : `${entry}/index.ts`; | ||
|
||
acc[`${path}-${entry}`] = `./src/${path}/${entryPath}`; | ||
return acc; | ||
}, {}); | ||
}; |