No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Dynamic/Lazy Loading component not working

    Help
    3
    4
    669
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Manieck last edited by

      Re: dynamic/lazy component import with runtime generated path not working with v1

      Hi,
      I’m in the process of migrating from Nuxt project to Quasar. Many things already work, but I have a problem with it.

      My code

      computed: {
          componentFile() {
            return () => this.componentName === ''
              ? import('./AppComponents/emptyComponent.vue')
              : import(`./AppComponents/${this.componentName}.vue`);
          }
        }
      

      Error

      Module build failed (from ./node_modules/eslint-loader/index.js):
        TypeError: Cannot read property 'range' of null
        Occurred while linting D:\Workspace\p1\qfrontend\src\components\PreviewComponent.vue:23
      

      In Nuxt this is working properly.

      metalsadman 1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman @Manieck last edited by metalsadman

        @Manieck check https://github.com/babel/babel-eslint/issues/799#issuecomment-570790316.

        1 Reply Last reply Reply Quote 0
        • rstoenescu
          rstoenescu Admin last edited by

          Hi,

          This problem has nothing to do with Quasar.
          Are you using ESLint v6 by any chance? Cause the solution to the babel issue (babel issue, not Quasar issue), is to pin @babel/parser to a specific version in your app (through yarn instead of npm):

          // package.json
          
          "resolutions": {
              "@babel/parser": "7.7.5"
            }
          
          1 Reply Last reply Reply Quote 0
          • M
            Manieck last edited by

            Hi

            The reason is @babel/parser@7.8.4 which is installed as we generate a new quasar project.

            There are two solutions.

            First.
            Change inline declarations

            : import(`./AppComponents/${this.componentName}.vue`);
            

            for

            : import('./AppComponents/' + this.componentName + '.vue');
            

            It works with @babel/parser@7.8.4

            Second.
            Delete folder ./node_modules/babel/parser
            Install @babel/parser@7.7.5:
            Add in package.json “@babel/parser”: “7.7.5”

            "devDependencies": {
                "@babel/core": "^7.6.2",
                "@quasar/app": "^1.0.0",
                "@babel/parser": "7.7.5",
                "@vue/eslint-config-standard": "^4.0.0",
                "babel-eslint": "^10.0.1",
                "eslint": "^5.10.0",
                "eslint-loader": "^2.1.1",
                "eslint-plugin-vue": "^5.2.2",
                "sass": "^1.25.0",
                "sass-loader": "^8.0.2"
              },
            
            npm install
            

            or directly

            npm install @babel/parser@7.7.5
            

            Works with inline declarations.

            Thank you for helping me find the reason.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post