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 + vue.config.js failed to compile #222

Open
4 tasks done
Glandos opened this issue Feb 7, 2023 · 13 comments
Open
4 tasks done

Webpack + vue.config.js failed to compile #222

Glandos opened this issue Feb 7, 2023 · 13 comments

Comments

@Glandos
Copy link

Glandos commented Feb 7, 2023

Reporting a bug?

I've added this to my vue.config.js:

const path = require('path');
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/webpack');

module.exports = {
  configureWebpack: {
    plugins: [
      VueI18nPlugin({
        include: path.resolve(__dirname, './src/locales/**')
      })
    ],

Expected behavior

yarn build should work as before.

Reproduction

https://github.com/Glandos/unplugin-vue-i18n-issue222

  • yarn
  • yarn serve

Issue Package

unplugin-vue-i18n

System Info

System:
    OS: Linux 6.1 Debian GNU/Linux bookworm/sid
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 16.50 GB / 31.21 GB
    Container: Yes
    Shell: 3.5.1 - /usr/bin/fish
  Binaries:
    Node: 16.19.0 - /tmp/fnm_multishells/68944_1675784800039/bin/node
    Yarn: 3.3.1 - /usr/local/bin/yarn
    npm: 8.19.3 - /tmp/fnm_multishells/68944_1675784800039/bin/npm
  Browsers:
    Chromium: 109.0.5414.119
    Firefox: 109.0
  npmPackages:
    vue: ^2.7.14 => 2.7.14 
    vue-i18n: ^8.28.2 => 8.28.2 
    webpack: ^5 => 5.75.0 

Screenshot

  Error: Child compilation failed:
  Module parse failed: Unexpected token (1:0)
  File was processed with these loaders:
   * ./node_modules/unplugin/dist/webpack/loaders/load.js
   * ./node_modules/html-webpack-plugin/lib/loader.js
  You may need an additional loader to handle the result of these loaders.
  > <!DOCTYPE html>
  | <html lang="en" translate="no">
  | 

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the README
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion.
@Glandos Glandos added the Status: Review Needed Request for review comments label Feb 7, 2023
@michug
Copy link

michug commented Feb 7, 2023

Same is happening to me.

const path = require('path')
const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/webpack')

let exportsObject = {
  publicPath: process.env.VUE_APP_STATIC_CONTENT_BASE_URL,
  chainWebpack: config => {
    const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
    types.forEach(type => addStyleResource(config.module.rule('less').oneOf(type)))
  },
  /* ... */
  plugins: [
    /* ... */
    VueI18nPlugin({
      /* options */
      // locale messages resourece pre-compile option
      include: path.resolve(__dirname, './path/to/src/locales/**'),
    })
  ],
  pluginOptions: {
    'style-resources-loader': {
      preProcessor: 'less',
      patterns: []
    }
  }
}

image

@Glandos
Copy link
Author

Glandos commented Feb 8, 2023

@michug did you install the module in your project, either:

  • npm install --save-dev @intlify/unplugin-vue-i18n
  • yarn add -D @intlify/unplugin-vue-i18n

?

@Glandos
Copy link
Author

Glandos commented Feb 8, 2023

Reproduction in https://github.com/Glandos/unplugin-vue-i18n-issue222:

  • git clone https://github.com/Glandos/unplugin-vue-i18n-issue222.git
  • yarn
  • yarn build

@michug
Copy link

michug commented Feb 8, 2023

@Glandos

yes, I did npm install --save-dev @intlify/unplugin-vue-i18n

@jpkohrs
Copy link

jpkohrs commented Feb 23, 2023

Same issue here, this occurs since version 0.7.0 of @intlify/unplugin-vue-i18n.
Version 0.6.2 and earlier works fine.

@kazupon kazupon added Package: unplugin-vue-i18n and removed Status: Review Needed Request for review comments labels Mar 4, 2023 — with Volta.net
@psven
Copy link

psven commented Mar 9, 2023

Same issue here

@liyasthomas
Copy link

I face the same issue;

Cannot find module '@intlify/vite-plugin-vue-i18n' or its corresponding type declarations.

@it9gamelog
Copy link

Same here on quasar v2.6.0 with webpack and latest @intlify/unplugin-vue-i18n

// quasar.config.js
build: {
      chainWebpack (chain) {
        const VueI18nPlugin = require('@intlify/unplugin-vue-i18n/webpack')
        chain.plugin('unplugin-vue-i18n').use(VueI18nPlugin).init(() => VueI18nPlugin())
      }
}

The error is

  Module parse failed: Unexpected token (1:0)
  File was processed with these loaders:
   * ./node_modules/unplugin/dist/webpack/loaders/load.js
   * ./node_modules/html-webpack-plugin/lib/loader.js
  You may need an additional loader to handle the result of these loaders.
  > <!DOCTYPE html>
  | <html>
  |   <head>
...

And this is the index.template.html that's having problem.

By install an older version of unplugin-vue-i18n (0.6.2), npm install --save-dev @intlify/unplugin-vue-i18n@^0.6.2, thing works again.

@xrado
Copy link

xrado commented Aug 13, 2023

same here. Tried version 0.6.2, above error is gone, but I get a parse error on other JSON files (not locales).

Module parse failed: Unexpected token (2:18) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.

for me build works with unplugin-vue-i18n@0.7.x

@SuperSchek
Copy link

Same issue here. Currently stuck using version 0.7.3. Any version above that gives me the following error:

Error: Child compilation failed:
  Module parse failed: Unexpected token (1:0)
  File was processed with these loaders:
   * ./node_modules/unplugin/dist/webpack/loaders/load.js
   * ./node_modules/html-webpack-plugin/lib/loader.js
  You may need an additional loader to handle the result of these loaders.

@TianbinTobin
Copy link

TianbinTobin commented Sep 7, 2023

Same issue here.Version 0.7.2 and earlier works fine.
It seems to be due to update unplugin@1.0.0 Since Version 0.8.0.
image
but older is
image

@Aviv-Galmidi
Copy link

Issue still exists in v4.0.0
Reverting to version 0.7.2 as suggested by TianbinTobin resolves the issue

@owlyowl
Copy link

owlyowl commented Oct 24, 2024

Also experiencing the same issue:

"dependencies": {
        "core-js": "^3.8.3",
        "raygun4js": "^3.0.1",
        "style-resources-loader": "^1.5.0",
        "uuid": "^9.0.0",
        "vue": "^3.2.13",
        "vue-class-component": "^8.0.0-0",
        "vue-i18n": "^9.14.1",
        "vue-property-decorator": "^10.0.0-rc.3",
        "vuex": "^4.0.0",
        "vuex-module-decorators": "^2.0.0"
    },
    "devDependencies": {
        "@intlify/unplugin-vue-i18n": "^5.2.0",
        "@intlify/vue-i18n-loader": "^4.2.0",
        "@types/grecaptcha": "^3.0.7",
        "@types/node": "^18.11.18",
        "@types/raygun4js": "^3.0.0",
        "@types/uuid": "^9.0.0",
        "@typescript-eslint/eslint-plugin": "^5.50.0",
        "@typescript-eslint/parser": "^5.50.0",
        "@vue/cli-plugin-babel": "~5.0.0",
        "@vue/cli-plugin-eslint": "~5.0.8",
        "@vue/cli-plugin-typescript": "~5.0.0",
        "@vue/cli-plugin-vuex": "~5.0.0",
        "@vue/cli-service": "~5.0.0",
        "@vue/eslint-config-standard": "^8.0.1",
        "@vue/eslint-config-typescript": "^11.0.2",
        "aws-sdk": "^2.1308.0",
        "cross-env": "^7.0.3",
        "eslint": "^8.33.0",
        "eslint-config-prettier": "^8.6.0",
        "eslint-plugin-eslint-comments": "^3.2.0",
        "eslint-plugin-import": "^2.27.5",
        "eslint-plugin-prettier": "^4.2.1",
        "eslint-plugin-promise": "^6.1.1",
        "eslint-plugin-vue": "^9.9.0",
        "file-loader": "^6.2.0",
        "pretty-hrtime": "^1.0.3",
        "rimraf": "^4.1.2",
        "sass": "^1.32.7",
        "sass-loader": "^12.0.0",
        "svg-inline-loader": "^0.8.2",
        "typescript": "~4.5.5",
        "vue-i18n-loader": "^0.1.1"
    }

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

No branches or pull requests