risen228 / craco-alias

A craco plugin for automatic aliases generation for Webpack and Jest
MIT License
109 stars 11 forks source link

TypeError: aliases[aliasName].replace is not a function #42

Closed jastako closed 2 years ago

jastako commented 2 years ago

In my CRA app I receive:

> craco start

(node:15302) UnhandledPromiseRejectionWarning: TypeError: aliases[aliasName].replace is not a function
    at normalizeAliases (/home/jastako/workspace/servibou/ui/node_modules/craco-alias/plugin/extract-aliases/normalize-aliases.js:8:43)
    at extractAliases (/home/jastako/workspace/servibou/ui/node_modules/craco-alias/plugin/extract-aliases/index.js:46:12)
    at Object.overrideWebpackConfig (/home/jastako/workspace/servibou/ui/node_modules/craco-alias/plugin/create-overrider.js:11:26)
    at overrideWebpack (/home/jastako/workspace/servibou/ui/node_modules/@craco/craco/lib/features/plugins.js:42:40)
    at /home/jastako/workspace/servibou/ui/node_modules/@craco/craco/lib/features/plugins.js:64:29
    at Array.forEach (<anonymous>)
    at applyWebpackConfigPlugins (/home/jastako/workspace/servibou/ui/node_modules/@craco/craco/lib/features/plugins.js:63:29)
    at mergeWebpackConfig (/home/jastako/workspace/servibou/ui/node_modules/@craco/craco/lib/features/webpack/merge-webpack-config.js:110:30)
    at overrideWebpackDev (/home/jastako/workspace/servibou/ui/node_modules/@craco/craco/lib/features/webpack/override.js:11:36)
    at /home/jastako/workspace/servibou/ui/node_modules/@craco/craco/scripts/start.js:27:5
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15302) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15302) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Terminal will be reused by tasks, press any key to close it.

craco.config.js:

module.exports = {
  plugins: [
    {
      plugin: require("craco-alias"),
      options: {
        source: "options",
        baseUrl: "./src",
        aliases: {
          "@graphql/*": ["graphql/*"],
          "@utils": ["utils"],
          "@utils/*": ["utils/*"],
        },
        debug: true,
      },
    },
  ],
  style: {
    postcss: {
      plugins: [require("tailwindcss"), require("autoprefixer")],
    },
  },
};