Suporte a navegadores legados
O Reactive Data Client foi projetado para funcionar sem configuração adicional com a maioria das ferramentas.
Se você encontrar Uncaught TypeError: Class constructor Resource cannot be invoked without 'new',
isso provavelmente se deve ao suporte ao Internet Explorer em uma configuração personalizada do webpack.
O erro ocorre mesmo em um navegador moderno, desde que o seu target (normalmente definido com browserslist)
inclua navegadores legados como o Internet Explorer.
Nesse caso, siga as instruções abaixo para garantir a compatibilidade.
Transpilar pacotes
Adicionar o webpack-plugin-modern-npm garante a compatibilidade de todos os pacotes instalados com navegadores legados.
- NPM
- Yarn
- pnpm
- esm.sh
yarn add --dev webpack-plugin-modern-npm
npm install --saveDev webpack-plugin-modern-npm
pnpm add -D webpack-plugin-modern-npm
<script type="module">
import * from 'https://esm.sh/webpack-plugin-modern-npm?dev';
</script>
Em seguida, instale o plugin adicionando-o à configuração do webpack.
const ModernNpmPlugin = require('webpack-plugin-modern-npm');
module.exports = {
plugins: [
new ModernNpmPlugin()
]
};
Polyfills
Use o CRA polyfill ou siga as instruções abaixo.
- NPM
- Yarn
- pnpm
- esm.sh
yarn add core-js whatwg-fetch
npm install --save core-js whatwg-fetch
pnpm add core-js whatwg-fetch
<script type="module">
import * from 'https://esm.sh/core-js';
import * from 'https://esm.sh/whatwg-fetch';
</script>
import 'core-js/stable';
import 'whatwg-fetch';
// place the above line at top