Skip to content

Commit c3e8295

Browse files
committed
add esModuleInterop option
1 parent 35711b7 commit c3e8295

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

rollup/npmHelpers.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ import { makeNodeResolvePlugin, makeSucrasePlugin } from './plugins/index.js';
1212
const packageDotJSON = require(path.resolve(process.cwd(), './package.json'));
1313

1414
export function makeBaseNPMConfig(options = {}) {
15-
const { entrypoints = ['src/index.ts'], externals: packageSpecificExternals = [], hasBundles = false } = options;
15+
const {
16+
entrypoints = ['src/index.ts'],
17+
esModuleInterop = false,
18+
externals: packageSpecificExternals = [],
19+
hasBundles = false,
20+
} = options;
1621

1722
const nodeResolvePlugin = makeNodeResolvePlugin();
1823
const sucrasePlugin = makeSucrasePlugin();
@@ -43,6 +48,17 @@ export function makeBaseNPMConfig(options = {}) {
4348
// get: () => are.great,
4449
// });
4550
externalLiveBindings: false,
51+
52+
// Equivalent to `esModuleInterop` in tsconfig.
53+
// Controls whether rollup emits helpers to handle special cases where turning
54+
// `import * as dogs from 'dogs'`
55+
// into
56+
// `const dogs = require('dogs')`
57+
// doesn't work.
58+
//
59+
// `auto` -> emit helpers
60+
// `esModule` -> don't emit helpers
61+
interop: esModuleInterop ? 'auto' : 'esModule',
4662
},
4763

4864
plugins: [nodeResolvePlugin, sucrasePlugin],

0 commit comments

Comments
 (0)