Can't import the named export 'Children' from non EcmaScript module (only default export is available)
I am getting the following error when attempting to use the latest release (0.4.0)
./node_modules/react-shade/dist/index.mjs
Can't import the named export 'Children' from non EcmaScript module (only default export is available)
I installed with Yarn into a basic create-react-app project.
I tried:
import {styled} from "react-shade";
const P = styled("p", {
":host": {
color: "green",
textTransform: "uppercase"
}
});
export {P};
and:
const P = styled({
":host": {
color: "green",
textTransform: "uppercase"
}
}, {name: "p"});
Interesting. I'll have a look.
I just noticed I updated the docs in master but haven't released the new api for styled yet. This is probably not your issue, but just FYI.
I can't reproduce this yet, but will try again a bit later.
@o-t-w, just add this to your webpack config rules:
{
type: 'javascript/auto',
test: /\.mjs$/,
use: []
}
@o-t-w, did @avele's solution work for you?
@treshugart - Same error here. Using typescript. I've no idea what generates this error, but @avele 's suggestion to add that snippet to webpack's config did work for me.
I think this is likely an issue where TypeScript doesn't support .mjs files by default. Closing for now unless we can pinpoint this as being an issue with react-shade itself. Thanks again for the fix @avele!
Another work around for this is importing react-shade/dist/index.js directly. It seems microbundle outputs an .mjs file for module and TypeScript prefers that, but doesn't support .mjs. Not sure yet if we can workaround this with microbundle.
Can't import the named export 'Children' from non EcmaScript module (only default export is available)
any updates , faced on with the same issue
@vaniadimova @iamakiraa did you try importing react-shade/dist/index.js directly, or did you try @avele's solution?
@vaniadimova @iamakiraa did you try importing
react-shade/dist/index.jsdirectly, or did you try @avele's solution?
@avele's solution helped, so I used react ts app, I ejected app, and modified web pack config.