[Pas2js] Disable optimization in specific units/blocks

silvioprog silvioprog at gmail.com
Thu Jan 10 22:25:57 CET 2019


Hello,

I've got a problem in a code I'm maintaining that uses some asm-blocks and
the final script must be built using the compiler optimization. The problem
is: my JS code is completely removed.

So, is there some option to disable the optimization in specific parts of
the project? For example:

{$PUSH}{$SOMETHING_TO_DISABLE_THE_OPTIMIZATION_HERE OFF}

procedure Foo;
asm
  // ... my very required Vanilla JS polyfill here ...
end;

{$POP}

IMHO, the compiler should not remove the custom JS scripts of the
programmer unconditionally, because it maybe raise a lot of undefined
errors. I would like to solve them using pure pas2js code (or Vanilla Pas
😅), but we need some polyfills which couldn't be solved using pure Pascal,
since some compiler features are missing (yet).

For a while, it seems the only available option is to disable the entire
optimizer. Well, it is very bad, cause it will generate the final
application script about 2.9 MB (in the front-end world, scripts of this
magnitude are unacceptable, specially for embedded applications.), against
about 1.2 MB using the optimizer. (1.2 MB is minified to ~900 kB using some
minify tool)

Any tricks to solve it? Thanks in advance for any help!

p.s: the project has been compiled using Pas2JS 1.0.3.

--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/pas2js/attachments/20190110/3120b904/attachment.html>


More information about the Pas2js mailing list