agilgur5/react-signature-canvas

Importing `src/` with latest CRA errors gets syntax error

zhil opened this issue · 2 comments

zhil commented

Library cant be used with create-react-app by default because of error
image

@babel/plugin-proposal-class-properties cant be added without ejecting CRA, which is pain.
CRA explanations
image
image

Not sure how to fix it, is it possible to change that experemental syntax?

related issues
facebook/create-react-app#4648
material-components/material-components-web-react#107

zhil commented

ok, I tried to use another CRA version, which I supposed to have that babel plugin enabled - because your library works fine for me in another project.
But it failed with the same error.

And I noticed, that in other project I have

import SignatureCanvas from "react-signature-canvas";

and in current project autocompletion added

import SignatureCanvas from "react-signature-canvas/src";

First import works just fine, so issue is solved for me.

Not sure about all that "experemental syntax" stuff - probably, we could close this issue if its false error.

Yea you imported src/, which as you might imagine, contains untranspiled source code. If you import regularly, you'll get the transpiled code.

src/ is really only there to aid in debugging along with the sourcemaps, and not to be imported directly in code.