code: function monkeyPatch() {
    return {
      transform: (code, id) => {
        var file = id.split('/').pop()
  
        // Only one define call per module is allowed by requirejs so
        // we have to remove calls that other libraries make
        if (file === 'FileSaver.js') {
          code = code.replace(/define !== null\) && \(define.amd != null/g, '0')
        } else if (file === 'html2canvas.js') {
          code = code.replace(/&&\s+define.amd/g, '&& define.amd && false')
        }
  
        return code
      }
    }
  }
docs: Monkey patching filesaver and html2canvas