import typescript from '@rollup/plugin-typescript' ; import resolve from '@rollup/plugin-node-resolve' ; import commonjs from '@rollup/plugin-commonjs' ; import json from '@rollup/plugin-json' ; import nodePolyfills from 'rollup-plugin-node-polyfills' ; import alias from '@rollup/plugin-alias' ; import inject from '@rollup/plugin-inject' ; import replace from '@rollup/plugin-replace' ; import path from 'path' ; typedef { import ( "rollup" ) . RollupOptions } RollupOptions typedef { import ( "rollup" ) . Plugin } RollupPlugin type { ( ) => RollupPlugin } function fixForGoogleAppsScript ( ) { return { name : 'google-apps-script' , renderChunk : ( code , chunk , options ) => { type { ( exportName : string ) => string } const mapExport = ( exportName ) => `function ${ exportName }(...args) {
  return ${ options . name }.${ exportName }(...args);
}` ; return `${ code }
${ chunk . exports . map ( mapExport ) . join ( '\n' ) }
` ; } , } ; } const emptyAdapterPath = path . resolve ( __dirname , 'src/google-apps-interop/emptyAdapter.js' ) ; type { RollupOptions } const config = { input : 'src/index.ts' , output : { name : '__main' , format : 'iife' , file : 'build/script.js' , } , plugins : [ alias ( { entries : [ { find : './adapters/xhr' , replacement : emptyAdapterPath , } , { find : './adapters/http' , replacement : emptyAdapterPath , } , ] , } ) , inject ( { Buffer : [ 'buffer' , 'Buffer' ] , } ) , nodePolyfills ( ) , commonjs ( { transformMixedEsModules : true } ) , resolve ( { browser : true , preferBuiltins : false } ) , json ( ) , typescript ( ) , replace ( { 'module.exports' : 'exports.__nested' , include : [ 'node_modules/**/axios/**/*' ] , } ) , replace ( { module : 'exports.__nested' , include : [ 'node_modules/**/lodash/**/*' ] , } ) , fixForGoogleAppsScript ( ) , ] , } ; export default config ;