jantimon/html-webpack-plugin

TypeError: childCompilation.errors.map is not a function

Opened this issue · 1 comments

Current behaviour 💣

When I attempt to build my project, I find the following error:

TypeError: childCompilation.errors.map is not a function
at /cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/html-rspack-plugin@5.6.2_@rspack+core@0.6.1/node_modules/html-rspack-plugin/lib/child-compiler.js:166:56
at finalCallback (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/@rspack+core@0.6.1_@swc+helpers@0.5.3/node_modules/@rspack/core/dist/Compiler.js:223:17)
at /cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/@rspack+core@0.6.1_@swc+helpers@0.5.3/node_modules/@rspack/core/dist/Compiler.js:250:20
at /cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/@rspack+core@0.6.1_@swc+helpers@0.5.3/node_modules/@rspack/core/dist/Compiler.js:423:28
at Hook.eval [as callAsync] (eval at create (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/HookCodeFactory.js:33:10), :6:1)
at Hook.CALL_ASYNC_DELEGATE [as callAsync] (/cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/tapable@2.2.1/node_modules/tapable/lib/Hook.js:18:14)
at /cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/@rspack+core@0.6.1@swc+helpers@0.5.3/node_modules/@rspack/core/dist/Compiler.js:419:41
at /cloudide/workspace/fe_mono/common/temp/node_modules/.pnpm/@rspack+core@0.6.1_@swc+helpers@0.5.3/node_modules/@rspack/core/dist/Compiler.js:743:65

Looking at the code, it appears that the code expects childCompilation.errors to be an array, but it is actually an iterator, which doesn't (yet) have a map method.

Expected behaviour ☀️

If I make the minimal change to get this working - changing childCompilation.errors.map to Array.from(childCompilation.errors).map - I get the compiler error I was expecting:

Failed to compile, check the errors for troubleshooting.
× JSONError { path: "/cloudide/workspace/fe_mono/apps/bernardTem/tsconfig.json", message: "invalid type: string \"./src/*\", expected a sequence at line 15 column 29", line: 15, column: 29 }

Reproduction Example 👾

I don't know how to easily reproduce this in a public fashion, because I have a Typescript project. The underlying reason for the error is that I set an entry in the compilerOptions.paths.[path] of tsconfig.json to be a string rather than an array of strings. See the following:

{
  "extends": "@modern-js/tsconfig/base",
  "compilerOptions": {
    "esModuleInterop": true,
    "declaration": false,
    "jsx": "preserve",
    "baseUrl": "./",
    "paths": {
      // "@/*": [
      //   "./src/*"
      // ],
      "@shared/*": [
        "./shared/*"
      ],
      "@project/*": "./src/*",
      "@components/*": [
        "./src/components/*"
      ],
      "@constants/*": [
        "./src/common/constants/*"
      ],
      "@imgs/*": [
        "./src/common/imgs/*"
      ],
      "@models/*": [
        "./src/models/*"
      ],
      "@utils/*": [
        "./src/common/utils/*"
      ],
    }
  },
  "include": [
    "src",
    "shared",
    "config"
  ]
}

The error entry is "@project/*": "./src/*". Changing that to "@project/*": ["./src/*"] fixes the compilation error.

Environment 🖥

I am fine with fix, but will be great to open an issue in rspack too