-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
[Feature] Transform paths of svg files #144
Comments
This is an interesting one. Thank you for the thorough explanation and resolution log detail. I've re-engineered quite a bit for the upcoming major release. We still rely on the compiler's resolution API, however, we're also getting a lot more information via other means, to support the new middleware custom resolver option. Part of that is to get the full range of path match possibilities, which means we might be able to do a post-resolution fail check for files with non-resolvable extensions. I'll look into this! In the mean time, you can use a |
Hi, and thanks for your
typescript-transform-paths
plugin, it's really helpful in a monorepo context to resolve imports specified asimport Something from '@namespace/some/path/Something'
while compiling.However, it would be even more helpful if it could resolve default imports of svg files, and I'll elaborate.
Currently in my source code I can import svgs like so:
Now, while the second import gets correctly compiled to
require('<relative_path_to>/SomeOtherComponent')
, the former remains untouched (i.e.require('@namespace/...')
) and if I publish the library to npm for use in a third-party application outside of the monorepo context it was developed in, it will of course complain that it cannot resolve'@namespace/...'
.Regarding my setup I have this in my
tsconfig.json
:And this is the ouput of
ttsc --traceResolution
:☝️ THAT is actually the correct path, so if the resolution stopped there and actually transformed
'@namespace/some/path/icons/alert/warning.svg'
to'/home/axedre/repo/projects/sdk/src/actual/path/icons/alert/warning.svg'
(aside from the fact it mistakenly saystarget file type 'TypeScript'
) I would be a very happy developer. But alas it thinkswarning.svg
is a typescript file or a folder name, so it proceeds on trying 👇😞
Before you ask, I've already tried all the widely-suggested approach of creating a
custom.d.ts
file with roughly this content:and include it both in
tsconfig.json
's"include"
(also in"compilerOptions.typeRoots"
) and inpackage.json
'stypes/typings
field, but to no avail.I think this might call for a specific
typescript-transform-svg-paths
plugin, but open to any suggestion.Cheers!
The text was updated successfully, but these errors were encountered: