Skip to content

Instantly share code, notes, and snippets.

@cedeber
Created November 1, 2021 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cedeber/83e5900085db1f61f940939d05f845ee to your computer and use it in GitHub Desktop.
Save cedeber/83e5900085db1f61f940939d05f845ee to your computer and use it in GitHub Desktop.
Vite.js commonJS default export
// 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