Skip to content

Webpack + Prepack + React, not optimizing react elements #53

@natew

Description

@natew

Expected Behavior

Attempting to get this to prepack react elements: https://github.com/facebook/prepack/wiki/react-compiler

Actual Behavior

Components don't seem to be picked up, neither do __evaluatePureFunction tagged functions. I do see prepack working on other areas.

Specifications

  • Platform: Mac
  • Plugin version: 1.1.2
  • Webpack version: 4.25.1

Here's some example code output when running it:


      const CosalDebug = __evaluatePureFunction(() => {
        return react__WEBPACK_IMPORTED_MODULE_0__["createElement"]("div", {
          style: {
            height: '100%',
            overflow: 'hidden',
            position: 'relative'
          }
        }, react__WEBPACK_IMPORTED_MODULE_0__["createElement"](Half, null, react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_Saliency__WEBPACK_IMPORTED_MODULE_2__[
        /* Saliency */
        "a"], null)), react__WEBPACK_IMPORTED_MODULE_0__["createElement"](Half, {
          style: {
            flex: 4
          }
        }, react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_Search__WEBPACK_IMPORTED_MODULE_1__[
        /* Search */
        "a"], null)));
      }); // prepack


      if (global.__optimizeReactComponentTree) {
        __optimizeReactComponentTree(CosalDebug);
      }

As you can see the function doesn't seem to be touched by prepack, but I'm attempting to run it with these options:

new PrepackPlugin({
        reactEnabled: true,
        compatibility: 'node-react',
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions