-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11717 from Automattic/vkarpov15/fix-webpack-build
fix: fix browser build for Webpack 5
- Loading branch information
Showing
4 changed files
with
34 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,22 @@ | ||
'use strict'; | ||
|
||
const asyncFunctionPrototype = Object.getPrototypeOf(async function() {}); | ||
let asyncFunctionPrototype = null; | ||
// try/catch for Babel compatibility, because Babel preset-env requires | ||
// regenerator-runtime for async/await and we don't want to include that | ||
// for a simple check. | ||
try { | ||
asyncFunctionPrototype = Object.getPrototypeOf(async function() {}); | ||
} catch (err) {} | ||
|
||
module.exports = function isAsyncFunction(v) { | ||
return ( | ||
typeof v === 'function' && | ||
Object.getPrototypeOf(v) === asyncFunctionPrototype | ||
); | ||
}; | ||
if (asyncFunctionPrototype == null) { | ||
module.exports = function isAsyncFunction() { | ||
return false; | ||
}; | ||
} else { | ||
module.exports = function isAsyncFunction(v) { | ||
return ( | ||
typeof v === 'function' && | ||
Object.getPrototypeOf(v) === asyncFunctionPrototype | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters