Skip to content
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

Webpack Module parse failed: Unexpected token... with nuxt-i18n 6.15.2 #929

Closed
1 task done
exophunk opened this issue Oct 14, 2020 · 4 comments · Fixed by #930
Closed
1 task done

Webpack Module parse failed: Unexpected token... with nuxt-i18n 6.15.2 #929

exophunk opened this issue Oct 14, 2020 · 4 comments · Fixed by #930
Labels

Comments

@exophunk
Copy link

Version

nuxt-i18n: 6.15.2
nuxt: 2.14.6
node: v14.2.0

Nuxt configuration

export default {
    modules: [
        ['nuxt-i18n', {}],
    ],
};

mode:

  • universal
  • [] spa

package.json

{
  ...
  "dependencies": {
    "core-js": "^3.6.5",
    "nuxt": "^2.14.6",
    "nuxt-i18n": "^6.15.2"
  },
  "devDependencies": {
    "@nuxtjs/eslint-config": "^3.1.0",
    "@nuxtjs/eslint-module": "^2.0.0",
    "@nuxtjs/stylelint-module": "^4.0.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.10.0",
    "eslint-plugin-nuxt": "^1.0.0",
    "stylelint": "^13.7.2",
    "stylelint-config-standard": "^20.0.0"
  }
}

Nuxt-i18n configuration

{}

Reproduction Link

Steps to reproduce

Install nuxt-i18n with Version 6.15.2 and use it as a module. When running the project with npm run dev, webpack fails with this:

Module parse failed: Unexpected token (75:55) File was processed with these loaders: * ./node_modules/babel-loader/lib/index.js You may need an additional loader to handle the result of these loaders. | name: this.getRouteBaseName() | }; > const canonicalPath = this.localeRoute(currentRoute)?.path; | | if (!canonicalPath) { 

With 6.15.1 it works, only happens with 6.15.2

  1. Create new project with npx create-nuxt-app test
    (I only add eslint + stylelint) everything else was default
  2. npm install nuxt-i18n
  3. Adjust nuxt config to include nuxt-18n module (nothing else)
  4. run npm run dev
  5. Webpack fails in my case

What is Expected?

Webpack should build normally

What is actually happening?

Webpack fails?

@zrisher
Copy link

zrisher commented Oct 14, 2020

Experiencing the same issue. Changing to 6.15.1 resolved it.

@exophunk
Copy link
Author

Seems to be related to this line because of the ?. operator?

My babel config (which is default of new nuxt project):

{
    "env": {
        "test": {
            "plugins": [
                [
                    "module-resolver",
                    {
                        "root": [
                            "."
                        ],
                        "alias": {
                            "@": ".",
                            "~": "."
                        }
                    }
                ]
            ]
        }
    }
}

@rchl
Copy link
Collaborator

rchl commented Oct 14, 2020

Released https://github.com/nuxt-community/i18n-module/releases/tag/v6.15.3 with a fix although optional chaining is supposed to be transpiled by Nuxt so not sure what's the issue.

I can reproduce this issue when using Node 14 but not Node 12.

@rchl
Copy link
Collaborator

rchl commented Oct 14, 2020

Found Nuxt bug here: nuxt/nuxt#7722

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants