forked from orval-labs/orval
-
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.
feat(build): move from tsc and rollup to tsup
- Loading branch information
Showing
11 changed files
with
217 additions
and
147 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
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 @@ | ||
* | ||
!lib/**/* | ||
!dist/**/* | ||
!README.md | ||
!package.json |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,28 @@ | ||
import { join } from 'upath'; | ||
import { resolve } from 'upath'; | ||
import { isObject, isString } from './is'; | ||
|
||
export const dynamicImport = async <T>( | ||
toImport: T | string, | ||
from = process.cwd(), | ||
): Promise<T> => { | ||
if (isString(toImport)) { | ||
const data = await import(join(from, toImport)); | ||
if (!toImport) { | ||
return toImport as T; | ||
} | ||
|
||
const path = resolve(from, toImport); | ||
|
||
if (isObject(data)) { | ||
return (data as any).default as T; | ||
try { | ||
if (isString(toImport)) { | ||
const data = await import(path); | ||
if (isObject(data) && data.default) { | ||
return (data as any).default as T; | ||
} | ||
|
||
return data; | ||
} | ||
|
||
return data; | ||
return Promise.resolve<T>(toImport); | ||
} catch (error) { | ||
throw `Oups... 🍻. Path: ${path} => ${error}`; | ||
} | ||
|
||
return Promise.resolve<T>(toImport); | ||
}; |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.