Skip to content

Commit

Permalink
revert: refactor: allow ES import for cloud string if package type is…
Browse files Browse the repository at this point in the history
… module (#7691)

This reverts commit 0225340.
  • Loading branch information
mtrezza authored Nov 10, 2021
1 parent 6962bfa commit 200d4ba
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 18 deletions.
3 changes: 1 addition & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
["@babel/preset-env", {
"targets": {
"node": "12"
},
"exclude": ["proposal-dynamic-import"]
}
}]
],
"sourceMaps": "inline"
Expand Down
8 changes: 0 additions & 8 deletions spec/CloudCode.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ describe('Cloud Code', () => {
});
});

it('can load cloud code as a module', async () => {
process.env.npm_package_type = 'module';
await reconfigureServer({ cloud: './spec/cloud/cloudCodeModuleFile.js' });
const result = await Parse.Cloud.run('cloudCodeInFile');
expect(result).toEqual('It is possible to define cloud code in a file.');
delete process.env.npm_package_type;
});

it('can create functions', done => {
Parse.Cloud.define('hello', () => {
return 'Hello world!';
Expand Down
3 changes: 0 additions & 3 deletions spec/cloud/cloudCodeModuleFile.js

This file was deleted.

6 changes: 1 addition & 5 deletions src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ class ParseServer {
if (typeof cloud === 'function') {
cloud(Parse);
} else if (typeof cloud === 'string') {
if (process.env.npm_package_type === 'module') {
import(path.resolve(process.cwd(), cloud));
} else {
require(path.resolve(process.cwd(), cloud));
}
require(path.resolve(process.cwd(), cloud));
} else {
throw "argument 'cloud' must either be a string or a function";
}
Expand Down

0 comments on commit 200d4ba

Please sign in to comment.