File tree 2 files changed +15
-3
lines changed
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ export default function commonjs(options = {}) {
47
47
ignoreGlobal,
48
48
ignoreDynamicRequires,
49
49
requireReturnsDefault : requireReturnsDefaultOption ,
50
+ defaultIsModuleExports : defaultIsModuleExportsOption ,
50
51
esmExternals
51
52
} = options ;
52
53
const getRequireReturnsDefault =
@@ -60,8 +61,11 @@ export default function commonjs(options = {}) {
60
61
: Array . isArray ( esmExternals )
61
62
? ( ( esmExternalIds = new Set ( esmExternals ) ) , ( id ) => esmExternalIds . has ( id ) )
62
63
: ( ) => esmExternals ;
63
- const defaultIsModuleExports =
64
- typeof options . defaultIsModuleExports === 'boolean' ? options . defaultIsModuleExports : 'auto' ;
64
+ const getDefaultIsModuleExports =
65
+ typeof defaultIsModuleExportsOption === 'function'
66
+ ? defaultIsModuleExportsOption
67
+ : ( ) =>
68
+ typeof defaultIsModuleExportsOption === 'boolean' ? defaultIsModuleExportsOption : 'auto' ;
65
69
66
70
const { dynamicRequireModuleSet, dynamicRequireModuleDirPaths } = getDynamicRequirePaths (
67
71
options . dynamicRequireTargets
@@ -150,7 +154,7 @@ export default function commonjs(options = {}) {
150
154
disableWrap ,
151
155
commonDir ,
152
156
ast ,
153
- defaultIsModuleExports
157
+ getDefaultIsModuleExports ( id )
154
158
) ;
155
159
}
156
160
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { FilterPattern } from '@rollup/pluginutils';
2
2
import { Plugin } from 'rollup' ;
3
3
4
4
type RequireReturnsDefaultOption = boolean | 'auto' | 'preferred' | 'namespace' ;
5
+ type DefaultIsModuleExportsOption = boolean | 'auto' ;
5
6
6
7
interface RollupCommonJSOptions {
7
8
/**
@@ -161,6 +162,13 @@ interface RollupCommonJSOptions {
161
162
requireReturnsDefault ?:
162
163
| RequireReturnsDefaultOption
163
164
| ( ( id : string ) => RequireReturnsDefaultOption ) ;
165
+
166
+ /**
167
+ * @default "auto"
168
+ */
169
+ defaultIsModuleExports ?:
170
+ | DefaultIsModuleExportsOption
171
+ | ( ( id : string ) => DefaultIsModuleExportsOption ) ;
164
172
/**
165
173
* Some modules contain dynamic `require` calls, or require modules that
166
174
* contain circular dependencies, which are not handled well by static
You can’t perform that action at this time.
0 commit comments