tools: lit-html render function breaks when minifying and compiling to es5

Hi,

I am not sure if this is the right place to report this issue, but since it is a problem with the code compilation, it seems wise.

You can see below the two versions of the compiled code for the render function of the lit-html package when using the Polymer LitElement.

ES5 (not minified)

function render(result, container) {
    var templateFactory$$1 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : templateFactory;
    var part = parts$1.get(container);

    if (part === undefined) {
      removeNodes(container, container.firstChild);
      parts$1.set(container, part = new NodePart(templateFactory$$1));
      part.appendInto(container);
    }

    part.setValue(result);
    part.commit();
}

ES5 (minified)

function render(result, container) {
    var templateFactory$$1 = 2 < arguments.length && arguments[2] !== void 0 ? arguments[2] : templateFactory,
        part = parts$1.get(container);
    part.setValue(result);
    part.commit();
}

As you can see the check of the part is missing which results to the following error TypeError: Cannot read property 'setValue' of undefined at render.

These are the contents of the polymer.json file I am using.

{
  "npm": true,
  "lint": {
    "rules": [
      "polymer-3"
    ]
  },
  "entrypoint": "src/index.html",
  "shell": "src/main.js",
  "moduleResolution": "node",
  "extraDependencies": [
    "node_modules/@webcomponents/webcomponentsjs/**"
  ],
  "builds": [
    {
      "name": "esm-bundled",
      "browserCapabilities": [
        "es2015",
        "modules"
      ],
      "js": {
        "minify": true
      },
      "css": {
        "minify": true
      },
      "html": {
        "minify": true
      },
      "bundle": true
    },
    {
      "name": "es2015-bundled",
      "browserCapabilities": [
        "es2015"
      ],
      "js": {
        "compile": "es2015",
        "minify": true,
        "transformModulesToAmd": true
      },
      "css": {
        "minify": true
      },
      "html": {
        "minify": true
      },
      "bundle": true
    },
    {
      "name": "es5-bundled",
      "js": {
        "compile": "es5",
        "minify": true, // it works if I set this to false
        "transformModulesToAmd": true
      },
      "css": {
        "minify": true
      },
      "html": {
        "minify": true
      },
      "bundle": true
    }
  ]
}

Any ideas?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 16 (10 by maintainers)

Most upvoted comments

Appears to be a babel-minify issue. Note there is new version 0.5.0 released recently.