-
-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module parse failed: Unexpected token (11509:70) #2233
Comments
@dolanmiu ping. Maybe you can help? Thanks |
Example usage. But result is always the same.
|
Maybe that's a babel preset issue? Well. Still no clue which presets I should've install. |
I use react and a typescript. What I have for a tsconfig.
|
It's hard to figure out the issue with limited stack trace is there more you can provide, or give some reproduction steps |
@dolanmiu That's literally all I've got for the stack trace. Nothing else. What else info can be useful? |
What is your set up, is it React Native |
My setup is React app (web not native). Created with create react app. Not ejected. The code I used to get an error is in the before messages. So the situation is I simply cannot use any imported class Document, Paragraph or else and see the error with exactly that non-descriptive trace. important libs: |
I believe I too am running into this issue of not being able to import and use components from the library. I have a small and simple JavaScript React app (also created with create-react-app). Any import statements are giving me errors at the moment; even when I try to just run the simple 'Basic Usage' example from the top of the docx.js.org page I get the error 'Can't import the named export 'Document' (imported as 'Document') from default-exporting module (only default export is available)' for each component (Document, Packer, Paragraph, etc). Some dependencies I am currently using are "react": "^18.2.0", "react-scripts": "5.0.1", "docx": "^8.2.0", among others. |
@KCrandall6 this is happened for me with vite and i resolved it by adding the following in my vite config file.
this is my config file |
I did some investigation and can conclude that it is only a problem with
@sathiya-pyramidions I didn't have to do what you did there with optimizeDeps This issue is caused by the upgrade from a I am having trouble into figuring out why |
@dolanmiu checkout this codesandbox, this is how my project base looks like |
@sathiya-pyramidions I am not sure, it works for me fine with |
@dolanmiu Does the generate button shows for you? For me it gives me the following errors. I have tried on different devices but it still be the same |
I don't get that issue with my link above ^ I do with your link though, try seeing what I did |
|
|
@momoca Worked around this error by downgrading to 8.0.4 |
@Hunterzhaoliu think you /:) |
This solved my issue. Thanks! |
Thanks! this resolve the issue I am facing. I working on Kibana 8.1.4 and it doesnt use These are the dependencies I am using
|
I am getting this same issue right now on 8.2.3 and I can confirm that downgrading to 8.0.4 resolves it as @Hunterzhaoliu mentioned. |
FYI this is still an issue with v8.3.0, only now the error is: |
I just tried to reproduce this on icleolion What is your set up? |
Ok, done some digging. Line 10008 uses the ?? operator, which in ES6 output was being rewritten into a conditional expression. In ES2020 it's left untouched. When you switched your tsconfig to target ES2020 instead of ES6, this library lost support for webpack 4 and node <14. Also you have increased the risk of issues being raised for bugs in browser land, as ES2020 has features unsupported by a not insignificant percentage of in-use browsers. There are a few options:
Hopefully this helps. |
@icleolion thanks for this, very informative, I learnt a lot I will try the first 3 options Edit: I have made a PR #2473 to go with option 1, to target 2015 to give the most backwards compatability again. Hopefully it should fix this issue. Will cut a new version with this fix Comment/Re-open if it still fails |
So this hasn’t worked. Final bundle is identical to previous version. As I don’t have experience with typescript or vite, I can’t be certain of the fix. But based on what I’ve just read at link below, tsconfig.json#compilerOptions.target is being ignored in favour of vite.config.ts#build.target. Which being undefined in your vite.config.ts is therefore defaulting to es2020. |
re-opened the issue. I will have another shot at it later Edit, made a PR here: #2492 |
I have an issue. When I import a library and use any component I get an error. How can I fix that? I have no clues or guesses,
The text was updated successfully, but these errors were encountered: