risen228 / craco-alias

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

compilerOptions.paths must not be set (aliased imports are not supported) #25

Closed lyhourchhen closed 3 years ago

lyhourchhen commented 3 years ago

compilerOptions.paths must not be set (aliased imports are not supported)

Output

Initial options:

{
  "source": "tsconfig",
  "tsConfigPath": "./tsconfig.extend.json",
  "baseUrl": "./",
  "debug": true
}

Normalized options:

{
  "source": "tsconfig",
  "baseUrl": "./",
  "tsConfigPath": "./tsconfig.extend.json",
  "debug": true
}

Aliases:

{
  "@src": "/Users/lyhourchhen/Developments/gogym-pos/src",
  "@components": "/Users/lyhourchhen/Developments/gogym-pos/src/components",
  "@services": "/Users/lyhourchhen/Developments/gogym-pos/src/services",
  "@pages": "/Users/lyhourchhen/Developments/gogym-pos/src/pages",
  "@api-generator": "/Users/lyhourchhen/Developments/gogym-pos/src/generators/gogym-gen-api.ts",
  "@uri": "/Users/lyhourchhen/Developments/gogym-pos/src/constants/rest-uri.constant.ts"
}

Webpack Config:

{
  "react-native": "react-native-web",
  "src": "/Users/lyhourchhen/Developments/gogym-pos/src",
  "@src": "/Users/lyhourchhen/Developments/gogym-pos/src",
  "@components": "/Users/lyhourchhen/Developments/gogym-pos/src/components",
  "@services": "/Users/lyhourchhen/Developments/gogym-pos/src/services",
  "@pages": "/Users/lyhourchhen/Developments/gogym-pos/src/pages",
  "@api-generator": "/Users/lyhourchhen/Developments/gogym-pos/src/generators/gogym-gen-api.ts",
  "@uri": "/Users/lyhourchhen/Developments/gogym-pos/src/constants/rest-uri.constant.ts"
}

The following changes are being made to your tsconfig.json file:
  - compilerOptions.paths must not be set (aliased imports are not supported)

craco.config.js


/* eslint-disable @typescript-eslint/no-var-requires */
const CracoLessPlugin = require("craco-less");
const CracoAlias = require("craco-alias");

module.exports = {
  plugins: [
    {
      plugin: CracoAlias,
      options: {
        source: "tsconfig",
        tsConfigPath: "./tsconfig.extend.json",
        baseUrl: "./",
        debug: true,
      },
    },
    {
      plugin: CracoLessPlugin,
      options: {
        lessLoaderOptions: {
          lessOptions: {
            modifyVars: { "@primary-color": "#62caad" },
            javascriptEnabled: true,
          },
        },
      },
    },
  ],
};
lyhourchhen commented 3 years ago

resolved by disable debug option in craco option