gajus / prepack-webpack-plugin

A webpack plugin for prepack.
Other
1.04k stars 46 forks source link

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

Open natew opened 6 years ago

natew commented 6 years ago

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

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',
})
websocket98765 commented 4 years ago

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.