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
This issue is for tracking purposes of something the core team is working on. Informed feedback is welcomed, but please think before commenting.
Moving the post emit bundling out to Rust requires a few things we are doing in compiler.ts that might be hard inside of Rust:
Because of Expose emitted module specifiers on AMD outfile emit microsoft/TypeScript#35052 there is no way to determine from the AST what the module names will be when emitted. This requires for us to "guess" at what they will be as the logic is buried deep in the compiler and not easy to get to. There is some code in compiler.ts that mimics this logic. We need this to identify what the emitted root module name is so we can instantiate the bundle. It has to determine the common root of all the module specifiers in the bundle and then transform the root module specifier into what the emitted specifier will be in the bundle. That is replacing the common root with an empty string and removing the extension from the module specifier. (Yes, the TypeScript compiler always remove that extension even if it has it everywhere else. 🤷)
We have to "wrap" the emitted bundle with bundle loader. Because we need to preprend it, it messes up the source map that would get emitted. If we manipulate it and remap it in Rust we could close Consume source maps from JavaScript files #4499. I don't know if we want an inline source map or not. My feeling is not as long as we could resolve it at runtime when consuming a bundle, but we don't currently do that. Inline simply bloats the bundle, especially if we were to include sources.
We has to do a static analysis of the root module to figure out what exports are there, so we can re-export them in the bundle. This is currently done in the compiler.ts, and we would have to use swc to do that analysis in there. A temporary measure would be to still do the analysis in there, but have the bundle response include the string names of the exports to Rust, and Rust does the bundle manipulation. This is probably better as we already have the AST sitting there after the bundle emit.
This all would be an interim step until we start doing transformation only in Rust.
The text was updated successfully, but these errors were encountered:
This issue is for tracking purposes of something the core team is working on. Informed feedback is welcomed, but please think before commenting.
Moving the post emit bundling out to Rust requires a few things we are doing in compiler.ts that might be hard inside of Rust:
compiler.ts
that mimics this logic. We need this to identify what the emitted root module name is so we can instantiate the bundle. It has to determine the common root of all the module specifiers in the bundle and then transform the root module specifier into what the emitted specifier will be in the bundle. That is replacing the common root with an empty string and removing the extension from the module specifier. (Yes, the TypeScript compiler always remove that extension even if it has it everywhere else. 🤷)This all would be an interim step until we start doing transformation only in Rust.
The text was updated successfully, but these errors were encountered: