Closed
Description
This plugin works by inserting itself into the resolution process, and whenever webpack is resolving a file ending in .js
, the plugin tries .ts
and then .tsx
first, and then continues with the usual process if those files don't exist. This plugin ignores files within node_modules
so those files are resolved as normal with no alteration to the file extension.
I'm not sure of my approach and I'm seeking community feedback, so if anyone interested in this problem could take a look and let me know what they think I'd really appreciate it.
In particular:
- Should this solution, or something like it, be rolled into another project such as ts-loader, enhanced-resolve, or webpack itself? I'm interested in helping with this if so. Opinions of the maintainers of those projects are especially welcome :-).
- Am I hooking into enhanced-resolve in the right place? There are lots of places I could hook in to do this and it's not clear if the one I've chosen is the best choice.
- Is there a better way to skip files from external libraries (e.g. files from
node_modules
)? At the moment the plugin skips over any request wherenode_modules
appears as a part of the path, but I'm not really happy with this. Apart from being a hack, the current solution has the obvious problem that it doesn't work if external libraries are in a directory other thannode_modules
, and it doesn't work if the project you're building is itself in anode_modules
hierarchy (I can imagine use cases for doing this). Ideally I think I'd like to ignore any request that has passed throughModulesInHierachicDirectoriesPlugin
at any point, but I can't see a good way to do this. - Is skipping imports from external libraries even a good idea? My rationale for skipping external files is that some library developers might distribute
.ts
files on npm in addition to the compiled.js
files, for use with source maps, and it's desirable for webpack to resolve the.js
files and not the.ts
files in this case. TypeScript itself won't compile source files resolved fromnode_modules
when you compile withtsc
.
Metadata
Metadata
Assignees
Labels
No labels