[gjs/esm/dynamic-imports] temp - cleanup
- From: Evan Welsh <ewlsh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/esm/dynamic-imports] temp - cleanup
- Date: Sun, 7 Feb 2021 04:51:25 +0000 (UTC)
commit 663d59b4db5133861bad2673bc6ef2ccd0ec37a7
Author: Evan Welsh <contact evanwelsh com>
Date: Sat Feb 6 20:51:17 2021 -0800
temp - cleanup
installed-tests/js/.eslintrc.yml | 1 +
installed-tests/js/modules/say.js | 6 +++---
installed-tests/js/testESModules.js | 8 ++++----
modules/internal/.eslintrc.yml | 2 ++
modules/internal/loader.js | 16 ++++++++--------
5 files changed, 18 insertions(+), 15 deletions(-)
---
diff --git a/installed-tests/js/.eslintrc.yml b/installed-tests/js/.eslintrc.yml
index 28ec04c6..c1a4c9bd 100644
--- a/installed-tests/js/.eslintrc.yml
+++ b/installed-tests/js/.eslintrc.yml
@@ -35,5 +35,6 @@ overrides:
- testESModules.js
- modules/importmeta.js
- modules/exports.js
+ - modules/say.js
parserOptions:
sourceType: module
diff --git a/installed-tests/js/modules/say.js b/installed-tests/js/modules/say.js
index 4729dff5..0e543cae 100644
--- a/installed-tests/js/modules/say.js
+++ b/installed-tests/js/modules/say.js
@@ -1,7 +1,7 @@
export function say(str) {
- return `<( ${str} )`;
+ return `<( ${str} )`;
}
-export default function() {
- return 'default export';
+export default function () {
+ return 'default export';
}
diff --git a/installed-tests/js/testESModules.js b/installed-tests/js/testESModules.js
index bdc1a89f..a36cccc5 100644
--- a/installed-tests/js/testESModules.js
+++ b/installed-tests/js/testESModules.js
@@ -82,18 +82,18 @@ describe('Dynamic imports', function () {
let module;
beforeEach(async function () {
try {
- module = await import('resource:///org/gjs/jsunit/modules/say.js')
- } catch(err) {
+ module = await import('resource:///org/gjs/jsunit/modules/say.js');
+ } catch (err) {
logError(err);
fail();
}
});
- it('default import', async function () {
+ it('default import', function () {
expect(module.default()).toEqual('default export');
});
- it('named import', async function () {
+ it('named import', function () {
expect(module.say('hi')).toEqual('<( hi )');
});
});
diff --git a/modules/internal/.eslintrc.yml b/modules/internal/.eslintrc.yml
index 2889cc64..edc1a23a 100644
--- a/modules/internal/.eslintrc.yml
+++ b/modules/internal/.eslintrc.yml
@@ -26,3 +26,5 @@ globals:
setGlobalModuleLoader: readonly
setModulePrivate: readonly
getRegistry: readonly
+ initAndEval: readonly
+ finishDynamicModuleImport: readonly
diff --git a/modules/internal/loader.js b/modules/internal/loader.js
index 6067af15..67752490 100644
--- a/modules/internal/loader.js
+++ b/modules/internal/loader.js
@@ -77,13 +77,13 @@ class ModuleLoader extends InternalModuleLoader {
}
moduleDynamicImportHook(module, specifier, promise) {
- if (!module || !module.uri) {
+ if (!module || !module.uri)
throw new ImportError('Cannot resolve relative imports from an unknown file.');
- }
- this.resolveModuleAsync(specifier, module.uri).then((m) => {
+
+ this.resolveModuleAsync(specifier, module.uri).then(m => {
initAndEval(m);
-
+
finishDynamicModuleImport(module, specifier, promise);
}).catch(err => {
throw new ImportError(err.message);
@@ -140,9 +140,9 @@ class ModuleLoader extends InternalModuleLoader {
/**
* Resolves a module import with optional handling for relative imports asynchronously.
*
- * @param {import("./internalLoader.js").ModulePrivate} importingModulePriv
- * the private object of the module initiating the import
- * @param {string} specifier the module specifier to resolve for an import
+ * @param {string} specifier the specifier (e.g. relative path, root package) to resolve
+ * @param {string | null} importingModuleURI the URI of the module
+ * triggering this resolve
* @returns {import("../types").Module}
*/
async resolveModuleAsync(specifier, importingModuleURI) {
@@ -252,5 +252,5 @@ moduleLoader.registerScheme('gi', {
loadAsync(uri) {
// gi: only does string manipulation, so it is safe to use the same code for sync and async.
return this.load(uri);
- }
+ },
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]