Skip to content

Commit

Permalink
fix(commonjs): expose ignoreTryCatch config option (#5555)
Browse files Browse the repository at this point in the history
  • Loading branch information
cassiozen committed Nov 5, 2021
1 parent a960e04 commit d383c2a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/vite/types/commonjs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ export interface RollupCommonJSOptions {
* @default []
*/
ignore?: ReadonlyArray<string> | ((id: string) => boolean)
/**
* In most cases, where `require` calls are inside a `try-catch` clause,
* they should be left unconverted as it requires an optional dependency
* that may or may not be installed beside the rolled up package.
* Due to the conversion of `require` to a static `import` - the call is hoisted
* to the top of the file, outside of the `try-catch` clause.
*
* - `true`: All `require` calls inside a `try` will be left unconverted.
* - `false`: All `require` calls inside a `try` will be converted as if the `try-catch` clause is not there.
* - `remove`: Remove all `require` calls from inside any `try` block.
* - `string[]`: Pass an array containing the IDs to left unconverted.
* - `((id: string) => boolean|'remove')`: Pass a function that control individual IDs.
*
* @default false
*/
ignoreTryCatch?:
| boolean
| 'remove'
| ReadonlyArray<string>
| ((id: string) => boolean | 'remove');
/**
* Controls how to render imports from external dependencies. By default,
* this plugin assumes that all external dependencies are CommonJS. This
Expand Down

0 comments on commit d383c2a

Please sign in to comment.