RE: Source Maps with JS in Fragments

Michael Freeman, modified 5 Years ago. Junior Member Posts: 37 Join Date: 7/2/12 Recent Posts
Is there any way to include/use source maps with the Javascript included in a fragment?

If one assumes that in certain cases i might have some reasonably complex JS in a fragment, and that i used some kind of transformation to generate the JS even as simple as using Typescript, is there any notion or idea how i could include/provide source maps for a fragment?
thumbnail
Victor Galan, modified 5 Years ago. Regular Member Posts: 144 Join Date: 6/14/16 Recent Posts
Hey Michael!At the moment it is not possible to add them to the portal, I'm afraidI am not sure about adding it to the portal, but in the fragments toolkit we have a preview functionality that allows to test the fragment before upload it to the server, would you found it useful to add the source maps there for ease the testing of the fragment? 
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Are fragment js files transpiled? I tried it with the sample fragment and my impression was that the code I write is just packaged without further processing. Or is it transpiled on the server?
Michael Freeman, modified 5 Years ago. Junior Member Posts: 37 Join Date: 7/2/12 Recent Posts
In this case i am talking about writing a fragment offline (non-server) in Typescript. So yes it would be transpiled and produce a JS file. And let's say for example we are doing enough work using a framework or whatever that it produces a .map file that corresponds to the JS file. From what i can see there is no way to associate/use that map file on the server.
Maybe the problem is that this use case i am describing, where the fragment code is rich/complex enough that you'd want to use a framework & source maps, is not the target of fragments after all. And that the intent for fragments is just to provide smaller pieces of "glue"JS
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts
Yes, I understand. But I tried it with the sample liferay fragment code and "let x = 5;" stayed "let x = 5;". Maybe I did something wrong, I didn't really test it thoroughly.
AFAIK source maps are not supported currently, we are still experimenting, but we will probably only put minimal code into each fragment and put the actual sourcecode of our applications in extra modules, since we also need all those pesky dependencies to Vue or React.