webpack-ext-reloader: Cannot read properties of undefined (reading 'parse')

I am getting an error when attempting to run my vue project using vue-cli-service build --mode development

Error Stacks

TypeError: Cannot read properties of undefined (reading 'parse')
    at extractEntries ([PATH]\node_modules\webpack-ext-reloader\dist\webpack:\webpack-ext-reloader\src\utils\manifest.ts:12:30)
    at ExtensionReloaderImpl._registerPlugin ([PATH]\node_modules\webpack-ext-reloader\dist\webpack:\webpack-ext-reloader\src\ExtensionReloader.ts:81:23)
    at ExtensionReloaderImpl.apply ([PATH]\node_modules\webpack-ext-reloader\dist\webpack:\webpack-ext-reloader\src\ExtensionReloader.ts:111:12)

To Reproduce

Config
const { resolve } = require("path");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtReloader = require('webpack-ext-reloader');

const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    entry: {
      background: './src/background.js',
      main: './src/main.js',
    },
    output: {
      filename: (pathData) => {
        return pathData.chunk.name === 'background' ? 'js/background.js' : 'js/[name].[contenthash].js';
      }
    },
    plugins: [
      new ExtReloader({
        manifest: resolve(__dirname, "public/manifest.json")
      }),
      new CopyWebpackPlugin({
        patterns: [
          { from: 'public/manifest.json', to: 'manifest.json' },
          // If you have icons or other assets you need to include, add them here
          { from: 'public/icons', to: 'icons' },
        ],
      }),
    ],
  }
})
Manifest
{
    "manifest_version": 3,
    "name": "MYEXTENSION",
    "version": "1.0",
    "description": "Extension Description",
    "action": {
      "default_popup": "index.html",
      "default_icon": {
        "16": "icons/get_started16.png",
        "32": "icons/get_started32.png",
        "48": "icons/get_started48.png",
        "128": "icons/get_started128.png"
      }
    },
    "permissions": ["storage", "activeTab", "identity"],
    "background": {
      "service_worker": "js/background.js"
    }
  }

Expected behavior

I expected it to build

Environment:

  • OS: Windows
  • Browser Version:
  • webpack Version:
  • webpack-ext-reloader Version: ^1.1.10

I’m going to open a PR

  • yes
  • no

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 21

Most upvoted comments

Adding a strange note here that I’m having the same issue and the stack trace is referring to files that I can’t seem to find.

Stack Trace:

╰ $ yarn watch
yarn run v1.22.19
$ NODE_ENV=development webpack --config webpack/webpack.dev.js --mode=development --watch
[webpack-cli] TypeError: Cannot read properties of undefined (reading 'parse')
    at extractEntries (/Users/.../node_modules/webpack-ext-reloader/dist/webpack:/webpack-ext-reloader/src/utils/manifest.ts:12:30)

But:

╭ user@comp:~/.../node_modules/webpack-ext-reloader/dist (main)
╰ $ ll
total 2488
drwxr-xr-x@  4 user  staff   128B Nov  1 15:45 ./
drwxr-xr-x@ 17 user  staff   544B Nov  1 15:44 ../
-rwxr-xr-x@  1 user  staff   628K Nov  1 15:39 webpack-ext-reloader-cli.js*
-rw-r--r--@  1 user  staff   609K Nov  1 15:39 webpack-ext-reloader.js

@vialoh Thank you - I can confirm that the build error has now gone 🙌 Great work!

@ProNotion (and anyone else) can you verify for me that version 1.1.12 fixes your issue? The problem was indeed with how Vue imports dependencies. Relevant commit to fix the JSON5 import: cf971cb52e4417ce955d28726b7134e06612ca23

The original entry finding code also did not allow the Webpack config’s output.filename to be a function, and I think the original filename comparisons were flawed, but that should be fixed now as well: 9fc2a78185034e222166ca84813c02125208ec97

@vialoh Sorry for the delay but I have put together a simplified repo which demonstrates the issues - https://github.com/ProNotion/webpack-ext-reloader-example