[gjs] modules: Add bootstrap file with ESM support



commit 83aab56f178b4e15ddf185693b8e20aa2f4cfc5d
Author: Evan Welsh <contact evanwelsh com>
Date:   Thu Jul 1 10:18:54 2021 -0700

    modules: Add bootstrap file with ESM support

 gjs/context.cpp                   | 7 +++++++
 js.gresource.xml                  | 2 ++
 modules/esm/_bootstrap/default.js | 4 ++++
 3 files changed, 13 insertions(+)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index 726dad27..ce0692b1 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -627,6 +627,13 @@ GjsContextPrivate::GjsContextPrivate(JSContext* cx, GjsContext* public_context)
     load_context_module(cx,
                         "resource:///org/gnome/gjs/modules/internal/loader.js",
                         "module loader");
+
+    {
+        JSAutoRealm ar(cx, global);
+        load_context_module(
+            cx, "resource:///org/gnome/gjs/modules/esm/_bootstrap/default.js",
+            "ESM bootstrap");
+    }
 }
 
 void GjsContextPrivate::set_args(std::vector<std::string>&& args) {
diff --git a/js.gresource.xml b/js.gresource.xml
index fc55e597..47be6425 100644
--- a/js.gresource.xml
+++ b/js.gresource.xml
@@ -8,6 +8,8 @@
     <file>modules/internal/loader.js</file>
 
     <!-- ESM-based modules -->
+    <file>modules/esm/_bootstrap/default.js</file>
+  
     <file>modules/esm/cairo.js</file>
     <file>modules/esm/gettext.js</file>
     <file>modules/esm/gi.js</file>
diff --git a/modules/esm/_bootstrap/default.js b/modules/esm/_bootstrap/default.js
new file mode 100644
index 00000000..fefeb51b
--- /dev/null
+++ b/modules/esm/_bootstrap/default.js
@@ -0,0 +1,4 @@
+// SPDX-License-Identifier: MIT OR LGPL-2.0-or-later
+// SPDX-FileCopyrightText: 2021 Evan Welsh <contact evanwelsh com>
+
+// Bootstrap file which supports ESM imports.


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