bevry / istextorbinary

Determine if a filename and/or buffer is text or binary. Smarter detection than the other solutions.
Other
148 stars 17 forks source link

create-react-app compatibility #246

Open ghost opened 3 years ago

ghost commented 3 years ago

Hello when I try to compile my TypeScript create react app project I get this:

Any ideas on how to solve?

thanks!

Failed to compile.

./node_modules/istextorbinary/edition-browsers/index.js 68:27
Module parse failed: Unexpected token (68:27)
File was processed with these loaders:
 * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|   const textEncoding = 'utf8';
|   const binaryEncoding = 'binary';
>   const chunkLength = opts?.chunkLength ?? 24;
|   let chunkBegin = opts?.chunkBegin ?? 0; // Discover
|
balupton commented 3 years ago

Did you get it working, if so what needed to be changed?

andygock commented 3 years ago

istextorbinary@6.0.0 still not working with react-scripts@4.0.3

Failed to compile.

./node_modules/istextorbinary/edition-browsers/index.js 68:86
Module parse failed: Unexpected token (68:86)
File was processed with these loaders:
 * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|   const textEncoding = 'utf8';
|   const binaryEncoding = 'binary';
>   const chunkLength = (opts === null || opts === void 0 ? void 0 : opts.chunkLength) ?? 24;
|   let chunkBegin = (opts === null || opts === void 0 ? void 0 : opts.chunkBegin) ?? 0; // Discover
|
ghost commented 3 years ago

No I didn't get it working with TypeScript. Instead I had to import it as JavaScript into my TypeScript program.

Like this:

https://github.com/bootrino/reactoxide/blob/master/reactoxide/src/editor/textorbinary.js

Feels hacky - still hoping this will eventually support TypeScript and create react app.