Add `sourceType` to babylon parse calls

Reviewed By: rafeca

Differential Revision: D8004409

fbshipit-source-id: 85573296fec6e849508d88848c1bc1afb81921cf
This commit is contained in:
Peter van der Zee 2018-05-15 05:56:56 -07:00 committed by Facebook Github Bot
parent f4999c87e4
commit a107dc3f57
4 changed files with 13 additions and 4 deletions

View File

@ -220,5 +220,8 @@ it('wraps a JSON file correctly', () => {
});
function astFromCode(code) {
return babylon.parse(code, {plugins: ['dynamicImport']});
return babylon.parse(code, {
plugins: ['dynamicImport'],
sourceType: 'script',
});
}

View File

@ -259,5 +259,8 @@ it('ignores require functions defined defined by lower scopes', () => {
});
function astFromCode(code) {
return babylon.parse(code, {plugins: ['dynamicImport']});
return babylon.parse(code, {
plugins: ['dynamicImport'],
sourceType: 'script',
});
}

View File

@ -132,5 +132,8 @@ it('throws if an invalid require() call is encountered', () => {
});
function astFromCode(code) {
return babylon.parse(code, {plugins: ['dynamicImport']});
return babylon.parse(code, {
plugins: ['dynamicImport'],
sourceType: 'script',
});
}

View File

@ -168,7 +168,7 @@ describe('transforming JS modules:', () => {
const dep1 = 'foo';
const dep2 = 'bar';
const code = `require('${dep1}'),require('${dep2}')`;
const {body} = parse(code).program;
const {body} = parse(code, {sourceType: 'script'}).program;
transformer.transform.stub.returns(transformResult(body));
const result = transformModule(toBuffer(code), options());