Skip to content

Commit ae9869e

Browse files
committed
Update ParseServer.js
1 parent 87c5590 commit ae9869e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/ParseServer.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,10 @@ class ParseServer {
103103
if (typeof cloud === 'function') {
104104
cloud(Parse);
105105
} else if (typeof cloud === 'string') {
106-
try {
106+
if (process.env.npm_package_type === 'module') {
107+
import(path.resolve(process.cwd(), cloud));
108+
} else {
107109
require(path.resolve(process.cwd(), cloud));
108-
} catch (e) {
109-
if (e.code === 'ERR_REQUIRE_ESM') {
110-
import(path.resolve(process.cwd(), cloud));
111-
} else {
112-
throw e;
113-
}
114110
}
115111
} else {
116112
throw "argument 'cloud' must either be a string or a function";

0 commit comments

Comments
 (0)