mirror of https://github.com/status-im/metro.git
Add `sourceType` to babylon parse calls
Reviewed By: rafeca Differential Revision: D8004409 fbshipit-source-id: 85573296fec6e849508d88848c1bc1afb81921cf
This commit is contained in:
parent
f4999c87e4
commit
a107dc3f57
|
@ -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',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
Loading…
Reference in New Issue