prepack-webpack-plugin icon indicating copy to clipboard operation
prepack-webpack-plugin copied to clipboard

Webpack + Prepack + React, not optimizing react elements

Open natew opened this issue 6 years ago • 1 comments

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',
})

natew avatar Nov 18 '18 00:11 natew

Still seeing this issue. I built a demo that shows the problem that uses an up-to-date, barebones Create React App + react-app-rewired to include this plugin.

Is it certain this is an issue with prepack-webpack-plugin or should it be reported on the facebook/prepack repo?

Would really like to use this.

websocket98765 avatar Dec 08 '19 19:12 websocket98765