enactjs / enact

An app development framework built atop React that’s easy to use, performant and customizable.
http://enactjs.com
Apache License 2.0
311 stars 30 forks source link

Enact pack command doesn't build project to es5 and that cause errors at older TVs #3262

Open javadsalman opened 1 month ago

javadsalman commented 1 month ago

Rendering issue

Description

Enact pack and pack -p commands doesn't convert final bundle to ES5. It cause render errors at Older TV versions such as webOS TV 4.x (2018-2019).

Environment

LG Smart TV (2018-2019) and Chromium 53 on Windows

Enact version: latest

Reproduction Code

I got this code pieces from main.js file In dist after run npm run pack -p command. Which is not supported by older chromium versions

  async resolveData(signal) {
    let aborted = false;
    if (!this.done) {
      let onAbort = () => this.cancel();
      signal.addEventListener("abort", onAbort);
      aborted = await new Promise(resolve => {
        this.subscribe(aborted => {
          signal.removeEventListener("abort", onAbort);
          if (aborted || this.done) {
            resolve(aborted);
          }
        });
      });
    }
    return aborted;
  }

class AbortedDeferredError extends Error {}

const defer = function defer(data, init) {
  if (init === void 0) {
    init = {};
  }
  let responseInit = typeof init === "number" ? {
    status: init
  } : init;
  return new DeferredData(data, responseInit);
};

Comments and Screen Shots

The webpack and babel configuration must be modified to build project to es5 to make it supported by any devices.

hong6316 commented 1 month ago

Older TV versions cannot support the latest version of enact. Please check the below link and choose the appropriate version of enact, and please test again. https://webostv.developer.lge.com/develop/guides/enyo-enact-guide

javadsalman commented 1 month ago

Older TV versions cannot support the latest version of enact. Please check the below link and choose the appropriate version of enact, and please test again. https://webostv.developer.lge.com/develop/guides/enyo-enact-guide

Thanks for your response. But 2018-2019 is not a long time ago. And I need it to be supported by both new and old devices. Not just older devices. On the other hand, I used a bunch of new features of the latest Enact. It must be parsed to ES5 instead of ES6 to ensure it works smoothly on any device. Or there must be this kind of option to parse to ES5.

ahmaaz10 commented 1 month ago

Hello I also Have the same issue! Can you please work on the fix.

hong6316 commented 1 month ago

If so, try one of the 2 options:

  1. Please try export ES5="true" This env supports optional transpiling to full ES5 if needed when enact pack -p. Whether to force transpiling to full ES5, rather than ES6 targetted to webOS Chrome version.

  2. Please try enact transpile before enact pack -p This command transpiles the code to ES5.

ji394sfx87 commented 1 week ago

I use react-redux and @reduxjs/toolkit with latest version, but it still has ES5 problem.

.browserslistrc setting:

> 1%
not chrome < 38
ie >= 11

And I build with this: ES5=true NODE_PATH=./node_modules enact pack -p --content-hash

I use old version and it can be work in ES5

react-redux@7.2.9
@reduxjs/toolkit@1.6.0

I think enact does not transpile node_modules code to ES5...

PS: My enact version is 4.7.9

hong6316 commented 2 days ago

OK, Thanks for the additional information. I will check again.