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

Build Step: Transform Tagged Template Literals into Simple Code #14658

Closed
jridgewell opened this issue Apr 17, 2018 · 2 comments
Closed

Build Step: Transform Tagged Template Literals into Simple Code #14658

jridgewell opened this issue Apr 17, 2018 · 2 comments
Assignees
Projects

Comments

@jridgewell
Copy link
Contributor

jridgewell commented Apr 17, 2018

Post #14623, we'll have a lot of code using the html`<div />` Tagged Template Literal.

But, the output of TTLs is very large:

// input
function test() {
  const div = html`
      <div>
        <p>Some text</p>
      </div>`;
}


// output
var $0=["\n      <div>\n        <p>Some text</p>\n      </div>"];
$0.raw=["\n      <div>\n        <p>Some text</p>\n      </div>"];

function test(){
  const div = html($0)
}

Notice the duplication between the var $0 and $0.raw. For the html static template helper, we never use raw (it's actually forbidden in the linter), we only use the cooked value (the first array).

So, we can do a simple build transform (for the html helper only):

// input
function test() {
  const div = html`
      <div>
        <p>Some text</p>
      </div>`;
}


// output
function test() {
  const div = html(['\n      <div>\n        <p>Some text</p>\n      </div>']);
}
@jridgewell jridgewell added this to To do in Build Size via automation Apr 17, 2018
@jridgewell jridgewell moved this from To do to To do (Build Transforms) in Build Size May 8, 2018
@ampprojectbot ampprojectbot added this to the Pending Triage milestone Jun 5, 2018
@ampprojectbot
Copy link
Member

This issue seems to be in Pending Triage for awhile. @erwinmombay Please triage this to an appropriate milestone.

@kristoferbaxter
Copy link
Contributor

Addressed with #19704.

Build Size automation moved this from To do (Build Transforms) to Done Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Build Size
  
Done
Development

No branches or pull requests

4 participants