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

_states() is broken for esbuild bundle when NODE_ENV=production #213

Closed
eductech opened this issue Dec 15, 2022 · 2 comments · Fixed by #215 or #219
Closed

_states() is broken for esbuild bundle when NODE_ENV=production #213

eductech opened this issue Dec 15, 2022 · 2 comments · Fixed by #215 or #219

Comments

@eductech
Copy link

Hello. We are using esbuild to create development and production ready bundle.

It occurs that with current build configuration when NODE_ENV=production or code is minified with LNG_BUILD_MINIFY states feature is broken.

We are not using states directly. It was spotted because we use Router from sdk which use states under the hood. As the result - the is no ability to focus widgets.

From our initial investigation that that happens because function names (names of classes defined as states) are modified during build process.

Package versions:

    "@lightningjs/sdk": "5.2.0",
    "@lightningjs/cli": "2.9.1"
@michielvandergeest
Copy link
Contributor

Hi @eductech thanks for your report. We just got a similar report from someone else :)

It seems indeed that this is broken in ESbuild. The rollup configuration has an explicit setting to not scramble function and class names during minification (https://github.com/rdkcentral/Lightning-CLI/blob/master/src/configs/rollup.es6.config.js#L85).

We'll look into adding an equivalent config to ESbuild as well. Hopefully we'll get this in next week, in time to be included in our scheduled January release.

As an alternative in the mean time you could consider switching to rollup (when running production builds, that require minification)

@eductech
Copy link
Author

Thanks for looking into it. Unfortunately we could not switch to rollup because of issues with other 3rd party dependencies. Our temporary fix is:

static _states() {
        class Loading {
            static get name() {
                return 'Loading';
            }
        }

        return [Loading];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants