Skip to content

Commit 101289c

Browse files
committed
Solve bugs from node port.
1 parent ecf2c4a commit 101289c

File tree

1 file changed

+15
-24
lines changed

1 file changed

+15
-24
lines changed

source/ports/node_port/index.js

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -214,34 +214,25 @@ mod.prototype.require = function (name) {
214214
// /* Continue loading */
215215
// }
216216

217-
/* Try to load it with NodeJS first */
218-
try {
219-
return node_require.apply(this, [ name ]);
220-
} catch (e) {
221-
if (e.code !== 'MODULE_NOT_FOUND') {
222-
throw e;
223-
}
224-
}
225-
226-
try {
227-
return node_require.apply(this, [ require.resolve(name) ]);
228-
} catch (e) {
229-
if (e.code !== 'MODULE_NOT_FOUND') {
230-
throw e;
231-
}
232-
}
233-
234217
const index = name.lastIndexOf('.');
235218

236219
if (index !== -1) {
237-
/* If there is extension, load the module depending on the tag */
238-
const extension = name.substr(index + 1);
239-
const tag = tags[extension];
220+
/* If there is extension, load the module depending on the tag */
221+
const extension = name.substr(index + 1);
222+
const tag = tags[extension];
240223

241-
if (tag && tag !== 'node') {
242-
/* Load with MetaCall if we found a tag and it is not NodeJS */
243-
return metacall_require(tag, name);
244-
}
224+
if (tag && tag !== 'node') {
225+
/* Load with MetaCall if we found a tag and it is not NodeJS */
226+
return metacall_require(tag, name);
227+
}
228+
}
229+
230+
try {
231+
return node_require.apply(this, [ name ]);
232+
} catch (e) {
233+
if (e.code !== 'MODULE_NOT_FOUND') {
234+
throw e;
235+
}
245236
}
246237

247238
/* If there is no extension or the extension is not supported or it is 'node', load it with NodeJS require */

0 commit comments

Comments
 (0)