You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In a monorepo situation tsconfig-paths sometimes remaps relative file reference as absolute one. Compilation itself works (since for tsc everything works fine), but the resulting bundle is broken (will refer wrong webpack modules and thus miss some objects)
From debugging the code, I think it's actually caused by this problem dividab/tsconfig-paths-webpack-plugin#76 (so blame on the plugin or perhaps on enhanced-resolve), but perchance you can put workaround into your code, or at least warn about the situation in docs
(this doesn't actually matter, since the problem is triggered by the default wildcard rule, not our mappings)
Now what happens is that as part of the logic in enhanced-resolver (DescriptionFilePlugin), the tsconfig-paths-webpack-plugin gets asked to resolve file "../types" at relative path "./helpers". The tsconfig plugin merges the request and the relative path, but due to the change in the resolver's code, the resulting path is "types" instead of "./types". And since the plugin also automatically looks for packages in the baseUrl, it will happily resolve the request to the src/types package.
Solution on our side:
avoid having top-level folders with the same name as some files (that might be good idea anyway; however note that it is no problem for typescript or even angular, only for the storybook)
make sure, that baseUrl is one level higher; that way the wildcard rule in the remapper won't find "types". This is how I ended up solving the problem for now
Additional context
In default setup (empty ng new app followed by default sb setup) the problem doesn't occur, since the baseUrl ends up being higher than the src folder.
The text was updated successfully, but these errors were encountered:
Describe the bug
In a monorepo situation tsconfig-paths sometimes remaps relative file reference as absolute one. Compilation itself works (since for tsc everything works fine), but the resulting bundle is broken (will refer wrong webpack modules and thus miss some objects)
From debugging the code, I think it's actually caused by this problem dividab/tsconfig-paths-webpack-plugin#76 (so blame on the plugin or perhaps on enhanced-resolve), but perchance you can put workaround into your code, or at least warn about the situation in docs
Setup:
helper.ts includes
tsconfig.json contains in the paths something like
(this doesn't actually matter, since the problem is triggered by the default wildcard rule, not our mappings)
Now what happens is that as part of the logic in enhanced-resolver (DescriptionFilePlugin), the tsconfig-paths-webpack-plugin gets asked to resolve file "../types" at relative path "./helpers". The tsconfig plugin merges the request and the relative path, but due to the change in the resolver's code, the resulting path is "types" instead of "./types". And since the plugin also automatically looks for packages in the baseUrl, it will happily resolve the request to the src/types package.
Solution on our side:
System
Additional context
In default setup (empty
ng new
app followed by default sb setup) the problem doesn't occur, since the baseUrl ends up being higher than the src folder.The text was updated successfully, but these errors were encountered: