Closed zwigglers closed 4 years ago
@zwigglers It is possible to do this, but in the way that you proposed, we will have to do checks on whether the path is the name of the module, or it's just the path. This will become an unnecessary complication of the plugin logic.
Have you also tried to specifying the module path like that?
options: {
source: "options",
aliases: {
"shortened": "node_modules/some-installed-library/sub-module",
}
}
Anyway, i'm not sure CRA allows to do that. So I need some time to test it and to think about variants of solving this problem.
I tried referencing node_modules as a path but I ran into problems, I think it was because I was using yarn workspaces which puts node_modules outside the root directory which causes other problems with the CRA webpack config.
There is a slight difference in behavior
I think at the very least the documentation should be updated to reflect that this library only supports path aliasing, even though the underlying webpack config allows for named import aliasing.
I think it should work in V2. But I ran into the problems with types declarations. For some reason, TS thinks that package does not have types, even when @type/package is installed. Trying to find out the reason.
The current aliases only support aliasing paths. What if I want to alias named imports.
as a trivial example, say instead of importing
import * from 'some-installed-library/sub-module'
i want to alias it toimport * from 'shortened'
with alias