Skip to content

Commit 6afa82c

Browse files
authored
fix(commonjs)!: use safe default value for ignoreTryCatch (#1005)
BREAKING CHANGES: changed the default value of ignoreTryCatch to true fix fix
1 parent 540767b commit 6afa82c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/commonjs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Sometimes you have to leave require statements unconverted. Pass an array contai
123123
### `ignoreTryCatch`
124124

125125
Type: `boolean | 'remove' | string[] | ((id: string) => boolean)`<br>
126-
Default: `false`
126+
Default: `true`
127127

128128
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.
129129
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.

packages/commonjs/src/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ export default function commonjs(options = {}) {
8888
? options.ignoreTryCatch(id)
8989
: Array.isArray(options.ignoreTryCatch)
9090
? options.ignoreTryCatch.includes(id)
91-
: options.ignoreTryCatch || false;
91+
: typeof options.ignoreTryCatch !== 'undefined'
92+
? options.ignoreTryCatch
93+
: true;
9294

9395
return {
9496
canConvertRequire: mode !== 'remove' && mode !== true,

0 commit comments

Comments
 (0)