Failed to compile. sandwich-stream.mjs

Failed to compile.

Can’t import the named export ‘Readable’ from non EcmaScript module (only default export is available)


I did some research and found out that .mjs files seem to cause problem in CRA projects generally. I’m not sure what would be the proper fix but something like this seemed to work:

import SandwichStream from 'sandwich-stream/dist/sandwich-stream.js';

Based on that the related plugin code would look like this:

this.getReactWebImports = function(exporter) {
  return [
    { varName: "SandwichStream", path: "sandwich-stream/dist/sandwich-stream.js" },