Closed rickcoub closed 5 years ago
Hey @rickcoub! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.
On the node side, you will want to use babel-plugin-dynamic-import-node
.
@existentialism yes, i tried this also, it does not work
From above:
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-syntax-dynamic-import"],
presets: [ [ '@babel/preset-env',
], '@babel/preset-react', '@babel/preset-stage-0', ],
});
Have you tried including it in your server side config?
Can you clarify what you mean with
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-syntax-dynamic-import"],
presets: [ [ '@babel/preset-env',
], '@babel/preset-react', '@babel/preset-stage-0', ],
});
That's literally compiling a JS string "code"
and then discarding the compiled result. Did you maybe mean for that to be @babel/register
?
@existentialism yes i tried plugins: ["@babel/plugin-syntax-dynamic-import"], - got same error
@againksy that enables our parser to understand the syntax, but you’ll need babel-plugin-dynamic-node to transpire it so that it works with node...
@existentialism @loganfsmyth
https://github.com/againksy/webpack4-serverside-react16/tree/babel7 - branch babel7
here you can check - i set up the babel-plugin-dynamic-node
and got the unexpected token import
error
You can check a possible solution on this issue: https://github.com/babel/babel-loader/issues/493#issuecomment-452380751
@existentialism Yeah! It works
Have you tried removing the trailing comma you have after '@babel/preset-stage-0' ?
i have server side rendering on client package.json
on server side package.json
in webpack.config.js
on server side in server.js
starting server side got error