-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewire alias from outside of root folder? #3
Comments
Thanks for clarification that it is not works by default (it will be cool otherwise as that was with alias inside src). Seems, as far as I remember there additional restrictions to imports outside of project root in react scripts, but I did not analyze that carefully due to it was not necessary that time. I definitely interesting in this question and I would like to see. But currently there is no time for that absolutely. I hope this week make it possible to see. |
@Elyx0 Is your project written in TypeScript? I had the same issue that ESLint could not process my files in an outside directory. I believe the root cause is CRA's ESLint configuration, which has the this override for TypeScript files: To solve this issue, I tried overriding this override, but ESLint does not support external files and gives this error: Instead, I excluded the external library from the ESLint rule altogether by changing
My project now works, the only downside is that the external project is now excluded from lint-checking, which probably cannot be fixed. @oklas Do you think you can implement these changes? To not break the existing behaviour, I also altered the
I then called the function in my |
@JollyGoodHolly, Some how I can not reproduce the problem with const {aliasDangerous} = require('react-app-rewire-alias/lib/aliasDangerous') Let me know if the problem is solved or create repo with minimal reproducible example otherwise so I can see with details. |
@oklas This almost works, but there is one bug: - if(rule.use && 0 < rule.use.filter(isRuleOfEslint)) return true
+ if(rule.use && 0 < rule.use.filter(isRuleOfEslint).length) return true Otherwise, this function always returns false. You can easily test it like this: module.exports = function override(config) {
const configCopy = JSON.parse(JSON.stringify(config));
aliasDangerous({
...configPaths('tsconfig.paths.json')
})(config);
console.log("These should be equivalent:")
console.log(configCopy.module.rules[1].include);
console.log(config.module.rules[1].include);
return config;
} Also note that you might have cache pollution and need to delete the |
I suggests introduce restriction to paths outside of root for base
So base Implmentation of |
Just for clarification, does this mean that the line "provided fully functional aliases and allows the use of Babel, JSX, etc. outside of src" in the README is false at the moment or am I misunderstanding? For context, I'm trying to create an alias to a folder outside my React project folder in a monorepo and I can't seem to get it to work. What I would like to do is something like |
@tobloef were you be able to have React resolve the |
Hi, @tobloef, @edolix, if problem relevant I rewrite and simplify docs to show what need to do for these days to make it worked (instead of which files and options are exists and its possible values). I also added an example project it works - check it 🚴♂️ (it uses temporary patch - read #9). Feel free to ask. Subscribe to twitter for a news.👍 |
I try aliasDangerous, but, on require: const {aliasDangerous} = require('react-app-rewire-alias/lib/aliasDangerous') causes error: function expandRulesInclude(rules, include) { SyntaxError: Identifier 'expandRulesInclude' has already been declared |
Ok, i remove the duplicate method aliasDangerous.js, but now the error returns: Module not found: You attempted to import C:\Desenvolvimento\Git\JavaScript\projetos\pdvsuite\web\framework/Componentes/Botoes/BotaoAdicionar which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. "\framework" is a simbolic link (Windows), but if i try with the relative path de same error occour. I use:
The problem occour if i use a full or relative path to a outside directory of root. |
Is there a way of making it work for imports outside of the current folder? It works on the node side with
ts-node
but incra
not yet..The text was updated successfully, but these errors were encountered: