Comments (4)
@cliffordfajardo @Octopixell check option unsafeAllowModulesOutsideOfSrc
in release 3.0.0
from craco-alias.
I ended up using react-app-rewire-alias
My config-overrides.js
file looks like this
/**
* This file is required by `react-app-rewired` to override or make additions to webpack.
* `react-app-rewired` allows us to make modifications & extend `create-react-app` without ejecting.
* This allows us to get upstream updates, bug fixes, best practices baked in and improvements
* from the react team & open source community.
* - https://github.com/timarney/react-app-rewired/
*/
const {aliasDangerous, configPaths} = require('react-app-rewire-alias/lib/aliasDangerous');
// const fs = require('fs'); useful for debugging; see commented out fs function call(s) below
module.exports = {
/**
* @description
* The Webpack config to use when compiling your react app for development or production
* @param {Object} config
* @param {string} env - the environment variable passed to node on start.
* https://github.com/timarney/react-app-rewired#1-webpack-configuration---development--production
*/
webpack: function(config, env) {
aliasDangerous({
...configPaths('tsconfig.overrides.json'),
})(config)
// fs.writeFileSync('debug-config.json', JSON.stringify(config, null, 2)) Uncomment to view see the output for debugging
return config;
},
}
My ts-config-overrides.json
file looks like this:
ts-config-overrides.json
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"paths": {
"theme": ["./src/theme/*"],
"pages": ["./src/pages/*"],
"lib": ["./src/lib/*"],
"components": ["./src/components/*"],
"@shared/*": ["../shared/src/*"]
},
"isolatedModules": false
},
"references": [
{
"path": "../shared"
}
]
}
tsconfig.json
{
"compilerOptions": {
"module": "CommonJS",
},
"exclude": ["**/node_modules/**"]
}
from craco-alias.
I've ran into the exact same issue unfortunately. Did you manage to find a solution for this @cliffordfajardo ?
from craco-alias.
Yeah, this is the CRA restriction. The plugin doesn't remove it; I'll think about adding this feature.
from craco-alias.
Related Issues (20)
- it doesn't work at all when use with `tsconfig`. HOT 18
- Cannot add property paths, object is not extensible HOT 2
- Cannot parse tsconfig.extend.json
- TypeError: Cannot add property paths, object is not extensible HOT 1
- 按照官方给的案例配置craco-alias以后,项目都启动不了 HOT 3
- 'Cannot parse tsconfig.extend.json' error HOT 7
- compilerOptions.paths must not be set (aliased imports are not supported) HOT 1
- UnhandledPromiseRejectionWarning: TypeError: Object.fromEntries is not a function HOT 1
- Error if paths are already absolute
- Cannot find module 'react' or its corresponding type declarations. HOT 2
- compilerOptions.paths must not be set (aliased imports are not supported) HOT 9
- Cannot parse valid tsconfig that includes comments
- Does not work with TypeScript on CRA4 HOT 1
- Support `@*` HOT 2
- Module not found in monorepo
- TypeError: aliases[aliasName].replace is not a function
- Multiple fall back locations in paths do not get compiled
- Alias resolution requires duplicate
- Plans for upgrade to Craco 7 (CRA 5) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from craco-alias.