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:
dblythy
2021-09-14 22:10:37 +10:00
committed by GitHub
parent fdb7dfba9f
commit 0225340ccb
5 changed files with 23 additions and 6 deletions

View File

@@ -39,6 +39,14 @@ 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!';