Skip to content

Conversation

@sanason
Copy link
Contributor

@sanason sanason commented Feb 20, 2025

The purpose of this PR is to demystify the process by which the DAP code is minified. In the repo's current state, it is not clear which tool is being used for minification or how that tool is configured. This PR adds an npm script that specifies how minification is to be performed - by the Terser library and with options described in minify_options.json. Terser is not what has been used up to now - currently the code is minified with the Google Closure Compiler. But the Closure Compiler is a Java app, which makes it awkward to use in our npm environment, and the minified file generated by Terser is the same size as the one generated by the Closure Compiler (29 KB), so we aren't losing any performance by switching tools.

One change resulting from this switch - the sourcemap file has been renamed from Federated.js.map to the more intuitive name Universal-Federated-Analytics-Min.js.map. I'll go through the wiki and update any references to Federated.js.map (I know the self-hosting instructions refer to this file, I'll look for any other places).

run: npm ci --timing
- name: Lint javascript
run: npm run lint
- name: Verify minification uses script
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is hacky but I'd like to prevent a re-occurrence of the the situation where package.json suggests that we're using minifier A when really we're using minifier B.

The proper thing to do would be to delete the generated files from source control and have deployment be based on a built artifact. However, given that this project is about to lose most of its engineering support, I don't think this is the right time to make such a change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants