Not sure if we should go down this rabbit hole, but I've been thinking several times to remove the Babel dependency and the release of Fable 3 could be an opportunity for it.
When Fable was born, it used modern JS features (particularly the module system) that weren't supported by most browsers. thanks to Babel we could output different code depending on the environment. However, now JS modules are very extended and the JS features we use are supported for most JS engines. In principle, it "shouldn't" be too difficult to create our own JS printer and remove the Babel dependency.
The only library I've found to produce source maps in .net is this one but it's quite old and maybe not reliable.
Yay or not yay? @ncave @MangelMaxime @Zaid-Ajaj @forki
@alfonsogarciacaro I'm on the yay side.
Sounds amazing
ncave notifications@github.com schrieb am Fr., 26. Juni 2020, 04:11:
@alfonsogarciacaro https://github.com/alfonsogarciacaro I'm on the yay
side.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/fable-compiler/Fable/issues/2109#issuecomment-649909397,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAOANBPRTM7MMBULLLH27LRYP7VTANCNFSM4OI4UHUQ
.
I think it is a good idea personally I never use the source-maps. I always disabled them because at the time it was making compilation slower.
I prefer to debug the JavaScript in general if I have a problem and if the readability it will be even easier.
The need for source maps depends on whether the generated javascript code will be readable and still easy to map with the F# source using our brains.
I do debug with source maps quite often, but it's true I have a deeper understanding of what transformations are being done. Well, let's disable the source maps temporarily (but keep the location info to add them later if necessary) and work on #2087 and the printers to get readable JS :+1:
but keep the location info to add them later if necessary
+1
How would this work if a library wants to use an es6+ feature after this change? Like @Zaid-Ajaj mentioned here, there are cases where we may still want to use more advanced JS features.
Do you mean if users want to emit or reference JS with advanced features from F#? In that case, they can keep Babel in the pipeline to translate JS to something that's compatible with more browser as it's now: https://github.com/fable-compiler/webpack-config-template/blob/44ca14c1959d4474a23d7ec49958c06494c4f984/webpack.config.js#L140-L147
Yeah, but if it's a library that wants to do this, how would that be handled? Would they need to ensure that the user runs it through Babel?
Well, yes. But this is what is already happening. Note that Fable only uses Babel to translate the AST into JS code but it doesn't set any plugin (except for a couple of custom ones) or set any target by itself. It will spit out JS as it finds it. Right now, if users want to translate modern JS to more widely supported code they need to config that themselves: https://github.com/fable-compiler/webpack-config-template/blob/44ca14c1959d4474a23d7ec49958c06494c4f984/webpack.config.js#L28-L41
Okay I think I understand. Sounds like it's all good then.
We develop commercial apps with Fable and I do use source maps for debugging. It's essential to me.
It's likely that Fable 3 will ship initially without F# source map support (we're trying to compensate that with more readable JS output) but the infrastructure to generate them is still in place. As Fable 3 is a "pure" dotnet app, we need a dotnet library to generate the source maps but we couldn't find any that meets our needs. The easiest way it's probably to translate the low-level API of this JS library to dotnet (either F# or C#). It'd be great if the community could help with that.
BTW, this issue should be resolved after removing the Babel dependency in nagareyama, so let's close it. I will write a new one to bring source maps 👍