8000
Skip to content

core(build): add js minification to inline-fs plugin - #13272

Merged
devtools-bot merged 1 commit into
masterfrom
inline-fs-minify
Oct 27, 2021
Merged

core(build): add js minification to inline-fs plugin#13272
devtools-bot merged 1 commit into
masterfrom
inline-fs-minify

Conversation

@brendankenny
@brendankenny brendankenny commented Oct 27, 2021
Copy link
Copy Markdown
Contributor

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')) {
@brendankenny brendankenny Oct 27, 2021
Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the license remain? https://github.com/terser/terser#:~:text=JSDoc-style%20comments-,that%20contain%20%22%40license%22,-%2C%20%22%40preserve%22%20or%20start

No strong preference here. Keeping the extra minification pass seems fine to me.

Copy link
Copy Markdown
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);
@brendankenny brendankenny Oct 27, 2021
Copy link
Copy Markdown
Contributor Author

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

0