Patches to typescript files .ts not affecting transpiled JS files in <module>/dist
See original GitHub issueI’ve patched a typescript (.ts
) file in a module in node_modules/<module>/src
and integrated the patch toolchain with package.json as documented.
The patches are applied properly (even when reinstalling the module) but their transpiled .js
files in <module>/dist/
aren’t affected, hence the monkey patch has no affect in my application.
What am I missing?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
allowJS prevents transpiling of .ts files · Issue #35505 - GitHub
I wanted typescript to transpile both js and ts files and hav. ... tsc it does not transpile my typescript code (.ts file)...
Read more >Transpiling Javascript to Typescript. My built files are not ...
I am in the process of learning Cypress & Typescript. I have set up my files according to the following article: Converting a...
Read more >@rollup/plugin-typescript - npm
Start using @rollup/plugin-typescript in your project by running ... Create a rollup.config.js configuration file and import the plugin:.
Read more >TSConfig Reference - Docs on every TSConfig option
A TSConfig file in a directory indicates that the directory is the root of a ... This does not affect how TypeScript emits...
Read more >Recommend way to patch @theia module typescript files
Hi I'm trying to test a patch to @theia/plugin-ext/src/main/browser/webview/webview-environment.ts, in order to address an issue I'm ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@papb Thanks for your elaborated answer. I have figured that the library I wanted to patch - https://github.com/auth0/auth0-spa-js - uses the regular, second approach. Since its generated JS code is minified, I refrained from patching it.
I guess with the ever increasing usage of TypeScript in the JS ecosystem there will be less use cases for this patching library, although it does work really great. I used it on the minified JS files to see how it works, but then that’s not a sustainable approach because the resulting diff isn’t of any value since the minified JS file is a one-liner.
@larsblumberg In theory, both cases are possible:
.js
files are generated in your side;.js
files are generated at the moment of release in the library owner’s side, and you just get them directlyHowever, I do not remember ever seeing the first case, and would not recommend this approach. It could be done via a
postinstall
npm hook in the module, but for this to work npm would have to first install the typescript compiler (and worse, other typescript-only utilities they might use would have to be installed as well) in order to be able to build it for you. This would make installation much slower, since npm would end up installing all that packagesdevDependencies
first.The second case is the normal, and what I would recommend. As a module creator, one can use whichever tools they like for development, such as typescript, coffeescript, babel, whatever. But this should not be a problem of the end user, so you should just publish the final generated
.js
files in your module (and ideally not even publish the source.ts
files along, since they will be just useless files increasing the installation size).However, if you wish to say what is the specific package, I can help you check if by any chance it uses the first approach.
Since the first approach is rare and not recommended, I am not sure
patch-package
intends to support this use case. If it does, you might have indeed found a bug here.