diff --git a/scripts/post-build/complete-path.js b/scripts/post-build/complete-path.js index 960b52feb..5e5a447fe 100644 --- a/scripts/post-build/complete-path.js +++ b/scripts/post-build/complete-path.js @@ -105,20 +105,6 @@ module.exports.completePath = async (formats) => { ) } -const splitSource = (() => { - const splitRegex = /^([\w-]+|@[\w-]+\/[\w-]+)(?:\/(.*))?$/ - /** - * @param {string} source - * @return {[string, string] | null} - */ - return (source) => { - const matched = splitRegex.exec(source) - if (!matched) - return null - return matched.slice(1) - } -})() - /** * @param {string} source * @param {string} currentDir @@ -134,47 +120,11 @@ function parseSource(source, currentDir, suffix) { : joinPath(source, `index${suffix}`) : source + suffix } - else if ( - source.includes('date-fns') - && source !== 'date-fns-tz/formatInTimeZone' - ) { - // Xxxx date-fns for its poor compatibility - const [pkgName, subpath] = splitSource(source) || [] - return pkgName === null || subpath === null - ? null - : guessFullPath(pkgName, subpath) - } else { return source } } -/** - * @param {string} pkgName - * @param {string} subpath - * @return {string | null} - */ -function guessFullPath(pkgName, subpath) { - const pkgPath = require.resolve(path.posix.join(pkgName, 'package.json')) - const pkgRootPath = path.dirname(pkgPath) - - let parsedSource = null - const sourcePath = path.join(pkgRootPath, subpath) - if (fs.existsSync(`${sourcePath}.js`)) { - parsedSource = joinPath(pkgName, `${subpath}.js`) - } - else if (fs.existsSync(`${sourcePath}.mjs`)) { - parsedSource = joinPath(pkgName, `${subpath}.mjs`) - } - else if (fs.existsSync(path.join(sourcePath, 'index.js'))) { - parsedSource = joinPath(pkgName, subpath, 'index.js') - } - else if (fs.existsSync(path.join(sourcePath, 'index.mjs'))) { - parsedSource = joinPath(pkgName, subpath, 'index.mjs') - } - return parsedSource -} - function replaceExtname(filePath, ext) { const oldExt = path.extname(filePath) if (!oldExt)