You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/commonjs/README.md
+43
Original file line number
Diff line number
Diff line change
@@ -174,6 +174,49 @@ If you set `esmExternals` to `true`, this plugins assumes that all external depe
174
174
175
175
You can also supply an array of ids to be treated as ES modules, or a function that will be passed each external id to determine if it is an ES module.
176
176
177
+
### `defaultIsModuleExports`
178
+
179
+
Type: `boolean | "auto"`<br>
180
+
Default: `"auto"`
181
+
182
+
Controls what is the default export when importing a CommonJS file from an ES module.
183
+
184
+
-`true`: The value of the default export is `module.exports`. This currently matches the behavior of Node.js when importing a CommonJS file.
185
+
```js
186
+
// mod.cjs
187
+
exports.default=3;
188
+
```
189
+
```js
190
+
importfoofrom'./mod.cjs';
191
+
console.log(foo); // { default: 3 }
192
+
```
193
+
-`false`: The value of the default export is `exports.default`.
194
+
```js
195
+
// mod.cjs
196
+
exports.default=3;
197
+
```
198
+
```js
199
+
importfoofrom'./mod.cjs';
200
+
console.log(foo); // 3
201
+
```
202
+
-`"auto"`: The value of the default export is `exports.default` if the CommonJS file has an `exports.__esModule === true` property; otherwise it's `module.exports`. This makes it possible to import
203
+
the default export of ES modules compiled to CommonJS as if they were not compiled.
0 commit comments