@@ -12,7 +12,12 @@ import { makeNodeResolvePlugin, makeSucrasePlugin } from './plugins/index.js';
1212const packageDotJSON = require ( path . resolve ( process . cwd ( ) , './package.json' ) ) ;
1313
1414export 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