Open thorlucas opened 3 years ago
I'm not seeing this, but IIRC, it did give me trouble. I suspect that if you add trailing slashes to the baseUrl in one/both of tsconfig.json
/craco.config.js
, you'll be back in business.
And to suppress the STERR output related to this (in Bash):
yarn build --no-colors \
2> >(grep -v -e "The following changes are being made to your tsconfig.json file:" -e "- compilerOptions.paths must not be set (aliased imports are not supported)")
you should change like this
Same problem here.
I see that the suggested solution from @beingtyson more like a hot fix. I don't want to separate my tsconfig just for a plugin. I really think this is an unexpected behavior / a bug.
Edit: The suggested fix does not seem to work either.
The problem is coming from CRA: See this issue: https://github.com/facebook/create-react-app/issues/8909
The workaround by @beingtyson works for me to use the defined aliases, but I still got the same error:
Nevertheless this workaround works better for me than ejecting CRA.
This is because tsconfig.json
does not conform to the validation rules of react-scripts. Until react-scripts changes the validation rules, this is my solution:
tools/fix-alias.js
as follows:
/* eslint-disable */
const path = require('path')
const fs = require('fs')
rewrite('node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js', c => c.replace("paths: { value:", "// paths: { value:") )
function rewrite(path0, fn) { const path1 = path.resolve(__dirname, '../', path0) const contentBefore = fs.readFileSync(path1).toString() const content = fn(contentBefore) fs.writeFileSync(path1, content) }
2. Execute ``tools/fix-alias.js``
```shell
node tools/fix-alias.js
tools/fix-alias.js
for each installation, edit package.json
as follows:
{
...
"scripts": {
...
"postinstall": "node tools/fix-alias"
},
...
}
@xcfox awesome! this solves my issue with the warning. thanks
c => c.replace("paths: { value:", "// paths: { value:")
am I missing something or would that just break the line?
In node_modules/react-scripts/scripts/utils/verifyTypeScriptSetup.js
Here's my setup:
Then, I created a
tsconfig.paths.json
:Finally, my
craco
config:And yet:
Why?