Created
November 1, 2021 07:57
-
-
Save cedeber/83e5900085db1f61f940939d05f845ee to your computer and use it in GitHub Desktop.
Vite.js commonJS default export
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 function is used for Vite.js build in use with badly exported CommonJS modules | |
// @see https://github.com/vitejs/vite/issues/2139 | |
function interopDefault<T>(value: T): T { | |
// all "vite build" modes (preview mode is in DEV mode) | |
return import.meta.env.PROD || import.meta.env.MODE === "preview" ? (value as any).default : value; | |
} | |
export { interopDefault }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment