dynamic import() Syntax makes webpack throw an error
See original GitHub issueVersion
3.3.0
Reproduction link
https://github.com/DragosRocsoreanu/VueCreateExample/tree/master/src
Environment info
Environment Info:
System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz
Binaries:
Node: 10.15.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.17763.1.0
npmPackages:
@vue/babel-helper-vue-jsx-merge-props: 1.0.0-beta.2
@vue/babel-plugin-transform-vue-jsx: 1.0.0-beta.2
@vue/babel-preset-app: 3.3.0
@vue/babel-preset-jsx: 1.0.0-beta.2
@vue/babel-sugar-functional-vue: 1.0.0-beta.2
@vue/babel-sugar-inject-h: 1.0.0-beta.2
@vue/babel-sugar-v-model: 1.0.0-beta.2
@vue/babel-sugar-v-on: 1.0.0-beta.2
@vue/cli-overlay: 3.3.0
@vue/cli-plugin-babel: ^3.3.0 => 3.3.0
@vue/cli-plugin-eslint: ^3.3.0 => 3.3.0
@vue/cli-service: ^3.3.0 => 3.3.0
@vue/cli-shared-utils: 3.3.0
@vue/component-compiler-utils: 2.5.0
@vue/eslint-config-prettier: ^4.0.1 => 4.0.1
@vue/preload-webpack-plugin: 1.1.0
@vue/web-component-wrapper: 1.2.0
babel-helper-vue-jsx-merge-props: 2.0.3
babel-plugin-transform-vue-jsx: 4.0.1
eslint-plugin-vue: ^5.0.0 => 5.1.0
vue: ^2.5.21 => 2.5.22
vue-eslint-parser: 2.0.3
vue-hot-reload-api: 2.3.1
vue-loader: 15.5.1
vue-router: ^3.0.1 => 3.0.2
vue-style-loader: 4.1.2
vue-template-compiler: ^2.5.21 => 2.5.22
vue-template-es2015-compiler: 1.8.1
vuex: ^3.0.1 => 3.1.0
npmGlobalPackages:
@vue/cli: Not Found
Steps to reproduce
vue create example
Select Lint,Vuex,Babel,Router
Select anything
CD example
npm run serve
What is expected?
To start the server and run normally
What is actually happening?
INFO Starting development server...
98% after emitting CopyPlugin
ERROR Failed to compile with 1 errors 11:18:18 PM
error in ./src/router.js
Module parse failed: Unexpected token (19: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");
@ ./src/main.js 6:0-30 10:10-16
@ multi (webpack)-dev-server/client?http://192.168.0.10:8082/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
Apparently if I use YARN I won’t have this issue, so it’s NPM related issue Problem is with Router!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:28
- Comments:35 (8 by maintainers)
Top Results From Across the Web
Syntax Error on dynamic import() using webpack and babel
As for config=config , my understanding is that declaring a variable without var, const, let makes it a global variable. Lemme try this...
Read more >Dynamic Import, Code Splitting, Lazy Loading, and Error ...
You will encounter the error: “Cannot find module with dynamic import.” This error comes from Webpack, which is used by Create React App....
Read more >import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >Output - webpack
output.importFunctionName. string = 'import'. The name of the native import() function. Can be used for polyfilling, e.g. with dynamic-import-polyfill .
Read more >babel/plugin-syntax-dynamic-import
Currently, @babel/preset-env is unaware that using import() with Webpack relies on Promise internally. Environments which do not have builtin support for ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
revert webpack to v4.28 https://github.com/webpack/webpack/issues/8656
I can confirm this, doing simply
yarn install
fixes this