@@ -134,6 +134,23 @@ bar/
134134 default.js (Entry point for import)
135135```
136136
137+ ### Interaction with ".mjs"
138+
139+ This proposal can work alongside the ".mjs" proposal if necessary:
140+
141+ 1 . The ES module resolver can support loading files ending in ".mjs"
142+ 2 . "main" files as ".mjs" can be supported as loading as ES modules
143+
144+ The above cause no further statting in the module system.
145+
146+ Further,
147+
148+ * "default.js" is still checked by the ES directory resolve, with no support for "default.mjs"
149+ * "index.js" is still checked by the CJS direcotry resolve, with no support for "index.mjs"
150+
151+ A variant could support ".mjs" for both default and index, although this would incur some
152+ unnecessary statting.
153+
137154## Why "default.js"?
138155
139156- "default.html" is frequently used as a folder entry point for web servers.
@@ -178,6 +195,7 @@ Loads _X_ from a module at path _Y_. _T_ is either "require" or "import".
178195
1791961 . If T is "import",
180197 1 . If X is a file, then
198+ 1 . If extname(X) is ".mjs", load X as ES module text. STOP
181199 1 . If extname(X) is ".js", load X as ES module text. STOP
182200 1 . If extname(X) is ".json", parse X to a JavaScript Object. STOP
183201 1 . If extname(X) is ".node", load X as binary addon. STOP
@@ -200,6 +218,7 @@ Loads _X_ from a module at path _Y_. _T_ is either "require" or "import".
2002181 . If X/package.json is a file,
201219 1 . Parse X/package.json, and look for "main" field.
202220 1 . let M = X + (json main field)
221+ 1 . If extname(M) is ".mjs", load M as ES module text. STOP
203222 1 . LOAD_AS_FILE(M, "require")
2042231 . If X/index.js is a file, load X/index.js as JavaScript text. STOP
2052241 . If X/index.json is a file, parse X/index.json to a JavaScript object. STOP
0 commit comments