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
Typescript module refactor (and minification) will break vue-tsc
#2095
Comments
A strategy employed in Yarn is based on https://github.com/cevek/ttypescript via https://github.com/nonara/ts-patch |
Yarn's approach isn't great, and I don't recommend it (and comes out from them wanting to patch the real tsc vs y'all, who already have your own variant). Your needs are simple enough that our compiler APIs should be sufficient. I think you can just copy the |
Actually, apparently I've misunderstood what's being done, sorry (why override readfile just to patch a js file you're about to execute?). I'm just going to go out on a limb and say these kinds of modifications aren't officially supported and definitely not guaranteed to be stable across TS versions, so... Good luck? This is definitely one of the weirder ways to float a patch on something, considering you could actually maintain a fork & test your modified tsc. |
You may still be able to modify the output tsc file, it just won't be the same patch; but, I would agree that we should try and figure out how to actually support you in our API rather than needing to patch. |
I'll see what should we do when TS releases a beta version for this, I think no snag, |
If minification of tsc is a followup (making patching infeasible) isn't this a time to restructure how One concern here is if people have prior versions of So that suggests to me getting a semver-range into the peerDependencies as a short-term resolution, followed up by some future strategy to make vue-tsc Typescript-tooling-API aware. |
Thanks for telling me, I haven't checked the PR yet 😅. With it, we can look forward to some better way instead of proxy For example, I hope the original tsc.js decoupling base ts library and allows input it with a parameter: // bin/tsc
const ts = require("../lib/typescript.js")
require("../lib/tsc.js")(ts) So we can very easy to do any hacking with it in vue-tsc: const ts = require("typescript/lib/typescript.js")
ts. supportedTSExtensions = ...
ts. supportedJSExtensions = ...
ts. allSupportedExtensions = ...
ts. createProgram = ...
require("typescript/lib/tsc.js")(ts) But we're at a passive position, depending on how typescript actually refactors it. |
Well the original PR I linked to has already merged to main, so you can see the API surface you can work with already, noting comments from core Typescript contributors; @weswigham ...
@jakebailey ...
So if you are able to bottom out what's already possible with the APIs, and that's not enough, there's an appetite for understanding how the Typescript API needs to be opened up to permit downstream tooling to do its work. But if you need any tweaks in place in advance of a breaking release the discussion needs to start immediately I think. |
The current strategy in
vue-tsc
for dynamically patchingtsc
by interceptingreadFileSync
beforerequire
will not survive the PR which converts Typescript to use modules as per microsoft/TypeScript#51387 (comment)That PR has several ticks and is green to main.
The Typescript module refactor may be followed up by minification of the distributed code which would make the strategy unmaintainable.
In the short term this will mean pinning the highest compatible peerDependency version to be the last release before modules (possibly 4.8.x). The wildcard currently in place would implicitly include upcoming versions which will break at runtime.
In the medium term @weswigham has hinted at an api-compliant approach to extend the behaviours of tsc in the ways implied by the patch and the proxy ... ( see microsoft/TypeScript#51387 (comment) )
The text was updated successfully, but these errors were encountered: