Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
Webpack (or babel) appears to be replacing all instances of NodeJS Streams with standard ReadableStreams

So, I'm in the process of doing a long overdue update on a Node-based project, bundled with webpack and babel. In the process of updating webpack beyond v4, I've set up some of the polyfills I need by adding a resolve.fallback section to the config in my webpack.config.js:

    resolve: {
      extensions: [".ts", ".tsx", ".html", ".js"],
      fallback: {
        buffer: require.resolve("buffer"),
        crypto: require.resolve("crypto-browserify"),
        stream: require.resolve("stream-browserify"),
      },
    },

However, something (I suspect these polyfills, but I'm not sure) is now causing all instances of NodeJS Streams in my project to wind up being standard ReadableStreams, including the body of a response from an explicitly-imported node-fetch:

import {default as nodefetch} from 'node-fetch'
[...]
  const response = await nodefetch(endpointURI, {
    method: "POST",
    headers: {
      Authorization: authToken,
      Origin: window.location.host,
    },
    body: JSON.stringify(data),
  });
  return response.body;  // Attempting to call `response.body.pipe()` here 
                         // will result in a "not a function" error. In a debugger,
                         // response.body appears to be a standard (Non-Node) ReadableStream.

So, not sure why this is happening but I'd love to find out! Relevant versions:

node: v16.15.1
node-fetch@2.6.7
webpack-cli@4.10.0
webpack@5.73.0
stream-browserify@3.0.0
@babel/core@7.18.6
@babel/preset-env@7.18.6
@babel/preset-react@7.18.6
@babel/preset-typescript@7.18.6
@babel/runtime@7.18.6
about 4 years ago · Santiago Gelvez
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda