Skip to content

revert: refactor: allow ES import for cloud string if package type is module #7691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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