Skip to content

Commit

Permalink
fix(utils): [fillModules] dot.case specifier support
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Feb 11, 2023
1 parent f9e1371 commit 2be2adb
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/utils/fill-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import type { FillModuleOptions } from '#src/interfaces'
import regexp from '#src/internal/escape-reg-exp'
import isFunction from '#src/internal/is-function'
import { ERR_UNKNOWN_FILE_EXTENSION } from '@flex-development/errnode'
import pathe, { type Ext } from '@flex-development/pathe'
import type { EmptyString } from '@flex-development/tutils'
import pathe from '@flex-development/pathe'
import type { URL } from 'node:url'
import CONDITIONS from './conditions'
import extractStatements from './extract-statements'
Expand Down Expand Up @@ -72,15 +71,11 @@ const fillModules = async (
* @return {Promise<string | undefined>} New file extension or `undefined`
*/
async ext(specifier: string, url: URL): Promise<string | undefined> {
/**
* Current file extension of {@linkcode specifier}.
*
* @const {EmptyString | Ext} extname
*/
const extname: EmptyString | Ext = pathe.extname(specifier)
// skip replacement for bare specifiers
if (isBareSpecifier(specifier)) return void 0

// skip replacement for bare and already fully specified specifiers
if (isBareSpecifier(specifier) || extname.length > 1) return undefined
// skip replacement for specifiers that are already fully specified
if (pathe.extname(specifier) === pathe.extname(url.href)) return void 0

/**
* Replacement file extension.
Expand Down

0 comments on commit 2be2adb

Please sign in to comment.