Skip to content

Conversation

@brendankenny
Copy link
Contributor

@brendankenny brendankenny commented Oct 27, 2021

part of #13231

just uses our current settings (default terser minification targeting ecma: 2019).

@brendankenny brendankenny requested a review from a team as a code owner October 27, 2021 16:48
@brendankenny brendankenny requested review from connorjclark and removed request for a team October 27, 2021 16:48
@google-cla google-cla bot added the cla: yes label Oct 27, 2021

// TODO(bckenny): minify inlined javascript.
// Minify inlined javascript.
if (constructedPath.endsWith('.js')) {
Copy link
Contributor Author

@brendankenny brendankenny Oct 27, 2021

Choose a reason for hiding this comment

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

One notable thing is that our current pipeline (and now this plugin) spends a full 2 seconds on my machine trying to re-minify axe.min.js, which ends up saving about 1.9KB (out of 416KB for just that file), much of which ends up being from stripping the license header out :)

We could skip minifying when constructedPath.endsWith('.min.js'), but not sure what balance is there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yeah, it starts with /*! so it is actually preserved.

It's mostly annoying just how slow that single file is compared to everything else, but I'm fine keeping the status quo of not special casing it

Comment on lines +370 to +373
// Verify that minification was valid. End result should be something like:
// `const sum = eval('function add(a,b){return a+b}add(1,2);')sum;`
const evaledResult = eval(code);
expect(evaledResult).toEqual(3);
Copy link
Contributor Author

@brendankenny brendankenny Oct 27, 2021

Choose a reason for hiding this comment

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

this is kind of tricky code but it should be robust to future changes to minification tool and options, and it didn't feel right to not have any unit test that the inlined string was still evaluatable javascript

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants