oklas / react-app-alias

:label: Alias and multiple src directory for craco or rewired create-react-app
MIT License
173 stars 18 forks source link

alias Doesn't send files into expandPluginsScope #7

Closed joshkarges closed 3 years ago

joshkarges commented 4 years ago

When my paths are something like:

"paths": {
      "@myorg/mylib": [
        "libs/mylib/src/index.ts"
      ]
    }

That file never gets sent into the new ModuleScopePlugin constructor, because you only send in the values of the aliasLocal map into the dirs argument of expandPluginsScope.

Then you set dirs to filter out any elements that aren't directories, so it also doesn't get concatenated in files.

The result is that you'll still get errors complaining that any imports of @myorg/mylib is outside of the src/ directory because they're not exceptions in the ModuleScopePlugin: Module not found: You attempted to import /home/myrepo/myorg/libs/mylib/src/index.ts which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.

To fix this, either pass the values of aliasLocal into the last 2 args of expandPluginsScope, or don't overwrite the dirs variable when filtering out directories.

oklas commented 3 years ago

Thanks @joshkarges for point this out. This closed with commit 831e5de. And released with v0.1.8. Feel free to let me know if any.