 throw an error if the file doesn't exist.
 
 Sets `__FILE__' and `__DIR__' on the loaded file."
-  (let ((path (or (and path (eval path)) __DIR__)))
+  (let ((path (or (and path (eval path)) (__DIR__))))
     (unless path
       (error "Could not find %s" filesym))
     (let ((file (f-expand (concat (symbol-name filesym) ".el") path)))

If SIMPLE-P is nil, also byte-compile modules/*/*/*.el (except for packages.el).
There should be a measurable benefit from this, but it may take a while."
  (interactive)
  (doom-initialize-packages t)
  (let ((targets
         (append (list (f-expand "init.el" doom-emacs-dir)
                       (f-expand "core.el" doom-core-dir))
                 (f-glob "core-*.el" doom-core-dir)
                 (unless simple-p
                   (-flatten
                    (--map (f--entries (doom-module-path (car it) (cdr it))
                                       (f-ext-p it "el") t)
                           (doom--module-pairs))))))
        (n 0)
        results)

      (unless (file-exists-p doom-autoload-file)
        (error "Autoloads file couldn't be generated")))))

(defun doom-initialize-packages (&optional force-p load-p)
  "Loads the packages.el files across DOOM Emacs in order to fill `doom-modules'
and `doom-packages', if they aren't set already. If FORCE-P is non-nil, do it
even if they are."
  (doom-initialize force-p)
  (let ((noninteractive t)
        (load-fn
         (lambda (file &optional noerror)
           (condition-case ex
               (load file noerror :nomessage :nosuffix)
             ('error (message "INIT-PACKAGES ERROR (%s): %s" file ex))))))
    (when (or force-p (not doom-modules))
      (setq doom-modules nil)
      (funcall load-fn (f-expand "init.el" doom-emacs-dir))
      (when load-p
        (mapc (lambda (file) (funcall load-fn file t))
              (append (reverse (f-glob "core*.el" doom-core-dir))
                      (f-glob "autoload/*.el" doom-core-dir)
                      (--map (doom-module-path (car it) (cdr it) "config.el")
                             (doom--module-pairs))))))

    (when (or force-p (not doom-packages))
      (setq doom-packages nil)
      (funcall load-fn (f-expand "packages.el" doom-core-dir))
      (mapc (lambda (file) (funcall load-fn file t))
            (--map (doom-module-path (car it) (cdr it) "packages.el")
                   (doom--module-pairs))))))

