Module singletons

Raul-Sebastian Mihăilă raul.mihaila at
Thu Feb 9 09:37:10 UTC 2017

1) My understanding is that a module is a singleton. But how does the spec
enforce that? Section HostResolveImportedModule ( says that
the resolving process of a module must be indempotent. 'Each time it is
called with a specific referencingModule, specifier pair as arguments it
must return the same Module Record instance.'

But in the following scenario:

import a from 'a.js';
import b from 'b.js';

impot c from 'c.js';


import c from 'c.js';


export default 3;

can we be certain that c.js resolves to the same module record and that
both a.js and b.js print 3? There are two different referencingModule,
specifier pairs even though the specifier is the same.

2) Is it correct that it's mandatory for an implementation to produce
different module instances in every TopLevelModuleEvaluationJobs? So if we
have two script tags with type module and with the same script content will
they always produce different module instances or is it possible for an
implementation to produce modules without executing a
TopLevelModuleEvaluationJob and reuse module instances?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list