risen228 / craco-alias

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

Cannot add property paths, object is not extensible #19

Closed uj-jung closed 3 years ago

uj-jung commented 3 years ago

[debug: true]

PS C:\data\test\todo> npm start

> todo@0.1.0 start C:\data\test\todo
> craco start

craco:  *** Cannot find ESLint loader (eslint-loader). ***
Initial options:

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

Normalized options:

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

Aliases:

{
  "@root": "C:\\data\\test\\todo\\src"
}

Webpack Config:

{
  "react-native": "react-native-web",
  "@root": "C:\\data\\test\\todo\\src"
}

C:\data\test\todo\node_modules\react-scripts\scripts\start.js:19
  throw err;
  ^

TypeError: Cannot add property paths, object is not extensible
    at verifyTypeScriptSetup (C:\data\test\todo\node_modules\react-scripts\scripts\utils\verifyTypeScriptSetup.js:239:43)
    at Object.<anonymous> (C:\data\test\todo\node_modules\react-scripts\scripts\start.js:31:1)
    at Module._compile (internal/modules/cjs/loader.js:1015:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
    at Module.load (internal/modules/cjs/loader.js:879:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:903:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at start (C:\data\test\todo\node_modules\@craco\craco\lib\cra.js:202:5)
    at C:\data\test\todo\node_modules\@craco\craco\scripts\start.js:27:5

craco.config.js

const CracoAlias = require("craco-alias");

module.exports = {
  plugins: [
    {
      plugin: CracoAlias,
      options: {
        source: "tsconfig",
        // baseUrl SHOULD be specified
        // plugin does not take it from tsconfig
        baseUrl: "./src",
        // tsConfigPath should point to the file where "baseUrl" and "paths" are specified
        tsConfigPath: "./tsconfig.extend.json",
        debug: true
      }
    }
  ]
};

tsconfig.extend.json

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "@root": ["./"],
      "@root/*": ["./*"]
    }
  }
}

tsconfig.json

{
  "extends": "./tsconfig.extend.json",
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ]
}

What am I missing?

I did this. just

yarn create react-app myapp --template typescript
yarn add @craco/craco
yarn add craco-alias -D
wlxscn commented 3 years ago

why do you close this issue? I meet the same problem, how do you solve @uj-jung

abbasegbeyemi commented 3 years ago

Facing the exact same error. Was excited to find this. Why did you close it? How did you solve the issue? @uj-jung