-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Repair module loading logic and have cosmiconfig support ESM+TS
- Loading branch information
Showing
9 changed files
with
94 additions
and
48 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,3 +1,3 @@ | ||
module.exports = { | ||
cosmiconfigSync: jest.fn(), | ||
cosmiconfig: jest.fn(), | ||
} |
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,4 +1,4 @@ | ||
export type { VueTransformation } from '~/types/VueTransformation' | ||
export type { Config as SfcmodConfig } from '~/config.schema' | ||
|
||
export { default as runTransformation } from '~/runTransformation' | ||
export { runTransformation } from '~/runTransformation' |
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
import type { TransformationModule } from '~/types/TransformationModule' | ||
import debug from '~/utils/debug' | ||
|
||
export function loadModuleFromPath(nameOrPath: string): Promise<TransformationModule> { | ||
debug(`Loading transformation module ${nameOrPath}`) | ||
|
||
const customModulePath = path.resolve(process.cwd(), nameOrPath) | ||
debug(`Resolved to ${customModulePath}`) | ||
|
||
if (fs.existsSync(customModulePath)) { | ||
debug('Module exists on filesystem') | ||
|
||
return import(customModulePath) | ||
} | ||
|
||
throw new Error(`Cannot find transformation module ${nameOrPath}`) | ||
} |
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