When I try to use @wordpress/api-fetch, I am getting following errors when compiling:
ERROR in ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js 15:90 Module parse failed: Unexpected token (15:90) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
ERROR in ./node_modules/@wordpress/i18n/build-module/create-i18n.js 196:29 Module parse failed: Unexpected token (196:29) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
This is my babel config, with @wordpress-default listed under presets.
module.exports = {
'presets': [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: {
version: 3,
proposals: true
},
}
],
'@babel/preset-react',
'@wordpress/default'
],
};
"@wordpress/babel-preset-default": "^4.8.0", is listed in the package.json
How can I fix this?
Although not fixing the actual issue, loading api-fecth with
wp.apiFetchsolves the problem.