-
-
Notifications
You must be signed in to change notification settings - Fork 450
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
Unexpected token when using import() #493
Comments
You'll need to enable https://babeljs.io/docs/plugins/syntax-dynamic-import/ The |
I have enabled that plugin in .babelrc but still get the error. Any idea? |
@felixfbecker, I just came across the very same issue and adding this plugin fixed it. Make sure you add the property "plugins": ["syntax-dynamic-import"] like this:
|
@felixfbecker do you use SSR ? |
getting
.babelrc
dependencies:
|
@kjda |
// try this util i made to avoid issues related to dynamic imports with ssr rendering export const importAsync = path => typeof System === "object" && typeof System.import === "function" ? System.import(`../${path}`) : null; how to use? import {importAsync} from "../../lib/import-async";
const Admin = () => importAsync('components/routes/admin');
console.log(<Admin />); |
@felixfbecker Turns out you need babel-plugin-dynamic-import-node |
Thanks @rommguy, it solved it for me! |
It got solved for me when I changed the webpack's file name from |
I am having this issue, none of the above solutions function / are ideal. Does webpack dynamic importing work with babel? |
@komali2 yep, it should. we'll need a bit more info to debug though... can you create a new issue with your configs (or even better, a small repo that repros the issue)? |
Ok, thank you, I'll create a new issue |
@existentialism I'm not convinced I'm looking at an actual bug, so I'll stay in "support mode" for now. Here's the stack overflow question if you wanna take a crack at it: https://stackoverflow.com/questions/49788115/syntax-error-on-dynamic-import-using-webpack-and-babel |
|
I got the same issue like @BonBonSlick , still, looking for another solution for this |
I had the same problem. I tried Solution:
|
The solution spotted by @jdgarcia1381 works for me, but I'd prefer to keep the .babelrc file. Edit: I just found out why it was failing to me. it was a trailing comma I had added in the .babelrc file. All I had to do was to search for a json error there, and it was the trailing coma, so I removed it: And now it works like a charm! |
issue still exists webpack.dev.config
error
any babels plugins do not help
|
I'm submitting a bug report
Webpack Version:
3.3.0
Babel Core Version:
6.25.0
Babel Loader Version:
7.1.1
Please tell us about your environment:
Linux
Current behavior:
Using
import
function result inExpected/desired behavior:
Letting webpack handle this.
I read somewhere modules should be disabled for babel, if that's the case I did not found how. Any insight?
The text was updated successfully, but these errors were encountered: