Babylon.js icon indicating copy to clipboard operation
Babylon.js copied to clipboard

Support for minification property mangling

Open bghgary opened this issue 3 years ago • 3 comments

Is it possible to turn on property mangling in minification? For my project, turning on property mangling reduces the bundle from 1.43MB to 1MB, but it doesn't run.

For example, for the terser plugin to webpack:

      new TerserPlugin({
        terserOptions: {
          mangle: {
            properties: true,
          },
        },
      }),

This isn't on by default because it can cause things to break, but maybe we can do it in a way that doesn't break?

https://stackoverflow.com/questions/58835084/webpackterserplugin-mangle-ignores-properties-and-class-names-poor-quality-o

bghgary avatar May 31 '22 16:05 bghgary

We cannot mangle public properties. We are providing a public API that should never be mangled. What we can do is agree to mangle private properties, which are marked in babylon with _ at the beginning of the function. This, however, will also mangle public hidden properties (!).

Private/hidden mangling:

mangle: {
    properties: {
        regex: /^_/,
    },
},

My personal opinion - yes, we should mangle private properties. From initial tests ca. 10% on the package size is reduced when mangling private properties. However (!) this requires changes to the build process, as if an internal package is using a public hidden function, the build might fail or provide incorrect access to those mangled properties.

RaananW avatar Jun 27 '22 13:06 RaananW

This issue has been automatically staled because it has been inactive for more than 14 days. Please update to "unstale".

github-actions[bot] avatar Mar 14 '24 00:03 github-actions[bot]

This issue has been automatically staled because it has been inactive for more than 14 days. Please update to "unstale".

github-actions[bot] avatar Mar 31 '24 00:03 github-actions[bot]