refactor: allow ES import for cloud string if package type is module (#7560)
* allow module import for Parse Cloud * Update .babelrc * catch esm error * Update ParseServer.js * add tests * Update CHANGELOG.md * Update CloudCode.spec.js Co-authored-by: Manuel <5673677+mtrezza@users.noreply.github.com>
This commit is contained in:
@@ -103,7 +103,11 @@ class ParseServer {
|
||||
if (typeof cloud === 'function') {
|
||||
cloud(Parse);
|
||||
} else if (typeof cloud === 'string') {
|
||||
require(path.resolve(process.cwd(), cloud));
|
||||
if (process.env.npm_package_type === 'module') {
|
||||
import(path.resolve(process.cwd(), cloud));
|
||||
} else {
|
||||
require(path.resolve(process.cwd(), cloud));
|
||||
}
|
||||
} else {
|
||||
throw "argument 'cloud' must either be a string or a function";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user