[gjs/esm/static-imports: 3/5] SQUASH: control compileModule/compileInternalModule with a flag




commit db76e8faeac9cd1e6ae2bb39bfa0be70365541fc
Author: Philip Chimento <philip chimento gmail com>
Date:   Fri Feb 5 14:55:18 2021 -0800

    SQUASH: control compileModule/compileInternalModule with a flag

 modules/internal/internalLoader.js |  6 +++++-
 modules/internal/loader.js         | 16 ++--------------
 2 files changed, 7 insertions(+), 15 deletions(-)
---
diff --git a/modules/internal/internalLoader.js b/modules/internal/internalLoader.js
index b2b6a945..7c870f4f 100644
--- a/modules/internal/internalLoader.js
+++ b/modules/internal/internalLoader.js
@@ -67,6 +67,9 @@ export class InternalModuleLoader {
      */
     constructor(global) {
         this.global = global;
+        // Controls whether modules are compiled for the internal global or the
+        // imports global. Overridden to be false in ModuleLoader.
+        this.compileInternal = true;
     }
 
     /**
@@ -136,7 +139,8 @@ export class InternalModuleLoader {
      * @returns {import("../types").Module}
      */
     compileModule(priv, text) {
-        const compiled = compileInternalModule(priv.uri, text);
+        const compileFunc = this.compileInternal ? compileInternalModule : compileModule;
+        const compiled = compileFunc(priv.uri, text);
 
         setModulePrivate(compiled, priv);
 
diff --git a/modules/internal/loader.js b/modules/internal/loader.js
index d6b43130..8518c197 100644
--- a/modules/internal/loader.js
+++ b/modules/internal/loader.js
@@ -30,21 +30,9 @@ class ModuleLoader extends InternalModuleLoader {
          * A map of handlers for URI schemes (e.g. gi://)
          */
         this.schemeHandlers = new Map();
-    }
-
-    /**
-     * Compiles a module source text with the module's URI
-     *
-     * @param {ModulePrivate} priv a module private object
-     * @param {string} text the module source text to compile
-     * @returns {import("../types").Module}
-     */
-    compileModule(priv, text) {
-        const compiled = compileModule(priv.uri, text);
 
-        setModulePrivate(compiled, priv);
-
-        return compiled;
+        // overrides InternalModuleLoader.compileInternal
+        this.compileInternal = false;
     }
 
     /**


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]