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
dynamic import() Syntax makes webpack throw an error #3335
Comments
I can confirm this, doing simply |
Looked at it a bit, seems to be an import Vue from "vue";
import Router from "vue-router";
import Home from "./views/Home.vue";
Vue.use(Router);
export default new Router({
mode: "history",
base: process.env.BASE_URL,
routes: [{
path: "/",
name: "home",
component: Home
}, {
path: "/about",
name: "about",
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: function component() {
return import(
/* webpackChunkName: "about" */
"./views/About.vue");
}
}]
}); at https://github.com/webpack/webpack/blob/master/lib/Parser.js#L2233 . Maybe related to webpack/webpack@ef67132 . I failed to found the difference between |
@michaeltintiuc Strange, it works here when using |
My bad, removed the comment |
I have the same problem Now I can remove node_modules without having a problem using cnpm or yarn installation dependencies, but this is only a temporary solution |
I have the same problem.The node version and the vue version is the same as you |
same here. After upgrading to 3.3.0, my app is broken |
the same problem with me, it works when using npm has this error |
revert webpack to v4.28 |
eslint parses dynamic import incorrectly |
Looks like an |
Any workaround suggestions? |
Just started hitting this now, import Component from './ComponentPath.vue' is fine, seems to just be the lazy loading syntax that's broken. |
UPDATE: Doesn't seem to work after allsee @lbogdan's comment below instead (#3335 (comment)) WorkaroundPeople using yarn seem to be unaffected. For users of npm: According to webpack/webpack#8656 (comment) this works:
see the linked comment for an explantion of what's going on. |
@LinusBorg workaround with npm didn't seem to work. Steps taken:
|
I can confirm the workaround in the webpack issue doesn't work. What worked for me was "downgrading" to
|
Yes, downgrading webpack to 4.28.4 seems to have worked for me as well. |
@broady02 The root cause is an npm issue, it was filed here: https://npm.community/t/packages-with-peerdependencies-are-incorrectly-hoisted/4794 . |
Just released @vue/cli-service 3.3.1 on npm to pin webpack version for now. |
I can confirm that doing
fixes the issue. |
New projects working as expected, Thankyou! |
In the end I decided it was time to use yarn from now on. |
The solution, work for me. I do:
Thanks |
webpack v4.29.0 not support. yesterday, run vue create <project-name>
cd <project-name>
npm run serve is error. Module parse failed: Unexpected token (17:13)
You may need an appropriate loader to handle this file type.
| // which is lazy-loaded when the route is visited.
| component: function component() {
> return import(
| /* webpackChunkName: "about" */
| './views/About.vue'); today, run vue create <project-name>
cd <project-name>
npm run serve is ok. compare package-lock.json, error version ...
"webpack": {
"version": "4.29.0",
"resolved": "http://registry.npm.taobao.org/webpack/download/webpack-4.29.0.tgz",
...
}
... ok version ...
"webpack": {
"version": "4.28.4",
"resolved": "http://registry.npm.taobao.org/webpack/download/webpack-4.28.4.tgz",
...
}
... So, the vue-cli is compatible with the downgraded version of webpack. You can do this rm -fr node_modules package-lock.json
npm install
npm run serve then see package-lock.json ...
"webpack": {
"version": "4.28.4",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.28.4.tgz",
...
}
... is work. |
Encounter the same problem |
想问一下我路由是使用 (resolve) => { |
it works for me. thanks |
I just bumped my project from webpack 3 to webpack 4, and met this problem.
since before I was using babel-plugin-syntax-dynamic-import.
|
@yunhan0 facing similar issue. I'm rolling out my own webpack configs, but dynamic imports are not working. What can I do? |
@DominusVilicus Did you change dynamic import plugin from babel-plugin-syntax-dynamic-import to @babel/plugin-syntax-dynamic-import? |
I found my issue. I was using |
{
test: /\.js$/,
loader: 'babel-loader',
options: {
plugins: ['@babel/plugin-syntax-dynamic-import']
}
} as module rule and ensure the |
Version
3.3.0
Reproduction link
https://github.com/DragosRocsoreanu/VueCreateExample/tree/master/src
Environment info
Steps to reproduce
What is expected?
To start the server and run normally
What is actually happening?
Apparently if I use YARN I won't have this issue, so it's NPM related issue Problem is with Router!
The text was updated successfully, but these errors were encountered: