                                       (list doom-private-dir))
                            if (doom-glob dir "autoload.el") collect it
                            if (doom-glob dir "autoload/*.el") append it)
-                  (mapcan #'doom-glob doom-autoloads-files)))
+                  (mapcan #'doom-glob doom-autoloads-files))
+          nil)
          (doom-autoloads--scan
           (mapcar #'straight--autoloads-file
                   (seq-difference (hash-table-keys straight--build-cache)
                                   doom-autoloads-excluded-packages))
+          doom-autoloads-excluded-files
           'literal))
         (print! (start "Byte-compiling autoloads file..."))
         (doom-autoloads--compile-file file)

These packages have silly or destructive autoload files that try to load
everyone in the universe and their dog, causing errors that make babies cry. No
one wants that.")

(defvar doom-autoloads-cached-vars
  '(doom-modules

      (doom-autoloads--scan-autodefs
       file target-buffer module module-enabled-p))))

(defun doom-autoloads--scan (files &optional exclude literal)
  (require 'autoload)
  (let (case-fold-search  ; case-sensitive regexp from here on
        autoloads)
    (dolist (file files (nreverse (delq nil autoloads)))
      (when (and (or (null exclude)
                     (seq-remove (doom-rpartial #'string-match-p file)
                                 exclude))
                 (file-readable-p file))
        (doom-log "Scanning %s" file)
        (with-temp-buffer
          (if literal
              (insert-file-contents file)
            (doom-autoloads--scan-file file))
          (save-excursion
            (let ((filestr (prin1-to-string file)))
              (while (re-search-forward "\\_<load-file-name\\_>" nil t)
                ;; `load-file-name' is meaningless in a concatenated
                ;; mega-autoloads file, so we replace references to it with the
                ;; file they came from.
                (let ((ppss (save-excursion (syntax-ppss))))
                  (or (nth 3 ppss)
                      (nth 4 ppss)
                      (replace-match filestr t t))))))
          (let ((load-file-name file)
                (load-path
                 (append (list doom-private-dir)
                         doom-modules-dirs
                         load-path)))
            (condition-case _
                (while t
                  (push (doom-autoloads--cleanup-form (read (current-buffer))
                                                      (not literal))
                        autoloads))
              (end-of-file))))))))
