Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagged templates are not compressed #951

Open
denyaalt opened this issue Mar 9, 2021 · 3 comments
Open

Tagged templates are not compressed #951

denyaalt opened this issue Mar 9, 2021 · 3 comments

Comments

@denyaalt
Copy link

denyaalt commented Mar 9, 2021

Bug report or Feature request?
Bug report

Version (complete output of terser -V or specific git commit)
terser 5.6.0

Complete CLI command or minify() options used

{
  compress: {},
  mangle: {},
  output: {},
  parse: {},
  rename: {},
}

terser input

result=template();
function template()
{ 	
    return html`
    <div class="parent">
    	<div class="child">${set}</div>
    </div>`;
}

terser output

Tagged templates are not compressed:

result=html`
    <div class="parent">
    	<div class="child">${set}</div>
    </div>`;

Expected result

result=html`\n\t<div class="parent">\n\t\t<div class="child">${set}</div>\n\t</div>`;
@Conduitry
Copy link
Contributor

There's no reasonable way for Terser to know that whitespace can be collapsed in this particular string.

@denyaalt
Copy link
Author

denyaalt commented Mar 9, 2021

If you remove the html tag, then the terser changes the string.
Why doesn't anything change with the html tag?

terser input (without tag literals)

result=template();
function template()
{ 	
	return `
	<div class="parent">
		<div class="child">${set}</div>
	</div>`;
}

terser output (result OK)

result=`\n\t<div class="parent">\n\t\t<div class="child">${set}</div>\n\t</div>`;

@developit
Copy link
Contributor

Terser can't inline html because it's a function call you're importing from an external module. It has unknown side effects.

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

No branches or pull requests

3 participants