bundle-tools icon indicating copy to clipboard operation
bundle-tools copied to clipboard

Webpack + vue.config.js failed to compile

Open Glandos opened this issue 2 years ago • 13 comments
trafficstars

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

  • [X] Read the Contributing Guidelines.
  • [X] Read the README
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion.

Glandos avatar Feb 07 '23 16:02 Glandos

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

michug avatar Feb 07 '23 19:02 michug

@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 avatar Feb 08 '23 08:02 Glandos

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

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

Glandos avatar Feb 08 '23 09:02 Glandos

@Glandos

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

michug avatar Feb 08 '23 11:02 michug

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

jpkohrs avatar Feb 23 '23 12:02 jpkohrs

Same issue here

psven avatar Mar 09 '23 08:03 psven

I face the same issue;

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

liyasthomas avatar Mar 11 '23 16:03 liyasthomas

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.

it9gamelog avatar Jun 10 '23 15:06 it9gamelog

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 [email protected]

xrado avatar Aug 13 '23 12:08 xrado

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.

SuperSchek avatar Aug 24 '23 12:08 SuperSchek

Same issue here.Version 0.7.2 and earlier works fine. It seems to be due to update [email protected] Since Version 0.8.0. image but older is image

TianbinTobin avatar Sep 07 '23 17:09 TianbinTobin

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

Aviv-Galmidi avatar Apr 07 '24 07:04 Aviv-Galmidi