editor icon indicating copy to clipboard operation
editor copied to clipboard

Launch options 'concatenated scripts' doesn't create source maps with already minified files

Open yaustar opened this issue 3 years ago • 4 comments

Project: https://playcanvas.com/project/1019795/overview/concatenate-issue

Enable concatenated scripts in the launch options: image

When launching, source maps aren't generated in the scripts.js file image

This is because on the pipeline job, we rely on Terser to concatenate files and if fails, it falls back to simple string concatenation.

yaustar avatar Dec 15 '22 13:12 yaustar

Seems to be specific to certain files/contents of files.

vconsole.min.js gives the following error when trying to use terser

20221215-135617 % terser vconsole.min.js --parse bare_returns  --source-map url='inline',includeSources=true -o test.js
ERROR: Invalid character
    at btoa (node:buffer:1228:13)
    at minify (/usr/local/lib/node_modules/terser/dist/bundle.min.js:29852:103)
    at run_cli (/usr/local/lib/node_modules/terser/dist/bundle.min.js:30093:22)
    at run_cli (/usr/local/lib/node_modules/terser/dist/bundle.min.js:30053:5)

Looking at it more, terser is trying to base64 the source code to inline the source maps. Problem is that there is something in the code that it can't convert to base64

yaustar avatar Dec 15 '22 14:12 yaustar

May be a non issue once Scripts v3 is released next year

yaustar avatar Dec 15 '22 15:12 yaustar

This has been fixed in https://github.com/terser/terser/commit/6c726e90ddc048f2e4639d0681d3e6fbae90cf60

Will have to wait for the next tag release :)

yaustar avatar Jan 29 '23 15:01 yaustar

Note to self, terser is now on 5.16.6 and we are on 5.13.1. I would like to think I just update this with no issue 😅

yaustar avatar Mar 10 '23 11:03 yaustar