context FEATURE allow explicit context compilation
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 97bbe2a..89c97ad 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -800,6 +800,12 @@
 
     assert(!mod->implemented);
 
+    if (mod->ctx->flags & LY_CTX_EXPLICIT_COMPILE) {
+        /* do not compile the module yet */
+        mod->to_compile = 1;
+        return LY_SUCCESS;
+    }
+
     /* we have module from the current context */
     m = ly_ctx_get_module_implemented(mod->ctx, mod->name);
     if (m) {
@@ -843,8 +849,14 @@
             return r;
         }
 
-        /* full recompilation */
-        return lys_recompile(mod->ctx, 1);
+        if (mod->ctx->flags & LY_CTX_EXPLICIT_COMPILE) {
+            /* just mark the module as changed */
+            mod->to_compile = 1;
+            return LY_SUCCESS;
+        } else {
+            /* full recompilation */
+            return lys_recompile(mod->ctx, 1);
+        }
     }
 
     /* implement this module and any other required modules, recursively */