Skip to content
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

await fetch is dropped in 1.14.0 #2896

Closed
kenrick95 opened this issue Jun 5, 2019 · 5 comments · Fixed by #2899
Closed

await fetch is dropped in 1.14.0 #2896

kenrick95 opened this issue Jun 5, 2019 · 5 comments · Fixed by #2899

Comments

@kenrick95
Copy link

kenrick95 commented Jun 5, 2019

  • Rollup Version: 1.14.0
  • Operating System (or Browser): Windows 10 1809
  • Node Version: v10.15.3

How Do We Reproduce?

REPL

main.js

import fetchAndDecode from './util.js';

fetchAndDecode();

util.js

export default async function fetchAndDecode() {
	const response = await fetch('https://example.com');
	return response.json();
}

Expected Behavior

await is not dropped. This is the UMD output from Rollup 1.13.0. REPL

(function (factory) {
	typeof define === 'function' && define.amd ? define(factory) :
	factory();
}(function () { 'use strict';

	async function fetchAndDecode() {
		const response = await fetch('https://example.com');
	 	return response.json();
	}

	fetchAndDecode();

}));

Actual Behavior

This is the UMD output in Rollup 1.14.0

(function (factory) {
	typeof define === 'function' && define.amd ? define(factory) :
	factory();
}(function () { 'use strict';

	async function fetchAndDecode() {
		const response; // <-- the `await` is dropped, creating a Syntax Error
	 	return response.json();
	}

	fetchAndDecode();

}));
@kenrick95 kenrick95 changed the title await is dropped in 1.14.0 await fetch is dropped in 1.14.0 Jun 5, 2019
@RomanHotsiy
Copy link

RomanHotsiy commented Jun 5, 2019

I'm seeing a similar more generic issue on 1.14.0:

REPL

main.js

export async function handler() {
	await test();
}

async function test() {
	console.log('test');
}

Expected Behavior

CJS output from rollup 1.14.0:

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

async function handler() {
	 await test();
}

async function test() {
	console.log('test');
}

exports.handler = handler;

Actual Behavior

CJS output from rollup 1.13.1:

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

async function handler() {
	 await test();
}

exports.handler = handler;

The test function is dropped!

@lukastaegert
Copy link
Member

Fix at #2899

@RomanHotsiy
Copy link

That was fast 🔥! Thanks!

@lukastaegert
Copy link
Member

Sorry for the inconvenience, should be fixed in 1.14.1 now.

@kenrick95
Copy link
Author

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants