-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
50 additions
and
23 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
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,39 @@ | ||
export type SSRTarget = 'node' | 'webworker' | ||
export type SSRFormat = 'esm' | 'cjs' | ||
|
||
export interface SSROptions { | ||
external?: string[] | ||
noExternal?: string | RegExp | (string | RegExp)[] | true | ||
/** | ||
* Define the target for the ssr build. The browser field in package.json | ||
* is ignored for node but used if webworker is the target | ||
* Default: 'node' | ||
*/ | ||
target?: SSRTarget | ||
/** | ||
* Define the format for the ssr build. Since Vite v3 the SSR build generates ESM by default. | ||
* `'cjs'` can be selected to generate a CJS build, but it isn't recommended. This option is | ||
* left marked as experimental to give users more time to update to ESM. CJS builds requires | ||
* complex externalization heuristics that aren't present in the ESM format. | ||
* @experimental | ||
*/ | ||
format?: SSRFormat | ||
} | ||
|
||
export interface ResolvedSSROptions extends SSROptions { | ||
target: SSRTarget | ||
format: SSRFormat | ||
} | ||
|
||
export function resolveSSROptions( | ||
ssr: SSROptions | undefined | ||
): ResolvedSSROptions | undefined { | ||
if (ssr === undefined) { | ||
return undefined | ||
} | ||
return { | ||
format: 'esm', | ||
target: 'node', | ||
...ssr | ||
} | ||
} |