Giter Site home page Giter Site logo

prepack-webpack-plugin's Introduction

prepack-webpack-plugin

Travis build status Coveralls NPM version Canonical Code Style

A webpack plugin for prepack.

Usage

  1. Install prepack-webpack-plugin.
  2. Add an instance of the plugin to the webpack plugin configuration.

Note that this plugin only works with webpack 4.x

Configuration

Name Description Default
test A regex used to match the files. /\.js($|\?)/i
prepack Prepack configuration. See Prepack documentation.

Example

import PrepackWebpackPlugin from 'prepack-webpack-plugin';

const configuration = {};

module.exports = {
  // ...
  plugins: [
    new PrepackWebpackPlugin(configuration)
  ]
};

If you are using commonjs, you must explicitly reference the .default property of the module, e.g.

const PrepackWebpackPlugin = require('prepack-webpack-plugin').default;

const configuration = {};

module.exports = {
  // ...
  plugins: [
    new PrepackWebpackPlugin(configuration)
  ]
};

prepack-webpack-plugin's People

Contributors

danielruf avatar gajus avatar horrigan avatar mastilver avatar mxstbr avatar stackdumper avatar thelarkinn avatar tmarshall avatar zacanger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prepack-webpack-plugin's Issues

Utilise prepackFromAst

The prepack method does not allow to utilise source maps. Use prepackFromAst to sourcemap generation.

Webpack + Prepack + React, not optimizing react elements

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

Invariant Violation

Not sure what causes this error, I'm not able to build using this plugin:

Invariant Violation
    at invariant (/my_project/node_modules/prepack/src/invariant.js:15:15)
    at new Serializer (/my_project/node_modules/prepack/src/serializer/serializer.js:64:5)
    at prepack (/my_project/node_modules/prepack/src/prepack-standalone.js:36:20)
    at Compilation.compilation.plugin (/my_project/node_modules/prepack-webpack-plugin/src/PrepackPlugin.js:58:35)
    at Compilation.applyPluginsAsyncSeries (/my_project/node_modules/tapable/lib/Tapable.js:142:13)
    at self.applyPluginsAsync.err (/my_project/node_modules/webpack/lib/Compilation.js:631:10)
    at Compilation.applyPluginsAsyncSeries (/my_project/node_modules/tapable/lib/Tapable.js:131:46)
    at sealPart2 (/my_project/node_modules/webpack/lib/Compilation.js:627:9)
    at Compilation.applyPluginsAsyncSeries (/my_project/node_modules/tapable/lib/Tapable.js:131:46)
    at Compilation.seal (/my_project/node_modules/webpack/lib/Compilation.js:575:8)

How can I provide more info?

Plugin interferes with UglifyJsPlugin

This plugin is awesome! Thanks for writing this. There is one small issue I've found: it undoes the minification performed by webpack.optimize.UglifyJsPlugin, adding indentation and formatting. It would be great if this plugin could be run in the Webpack compile cycle prior to the Uglify plugin.

Unfrozen object leaked before end of global code

Tried to run my Webpack production config and getting the following error since I added prepack-webpack-plugin:

Error: PP0017: Unfrozen object leaked before end of global code at 2:1 to 2:6378
Error
    at app.js:2:2

My Webpack config:

'use strict';

const path = require('path');
const webpack = require('webpack');
const PrepackWebpackPlugin = require('prepack-webpack-plugin').default;
const UglifyJsWebpackPLugin = require('uglifyjs-webpack-plugin');

const srcPath = path.resolve(__dirname, 'src');
const appPath = path.resolve(__dirname, 'app');

const webpackConfig = {
    context: srcPath,
    entry: {
        app: path.resolve(srcPath, 'app.jsx'),
        vendor: [
            'react',
            'react-dom',
            'react-router-dom',
            'glamor',
            'glamorous',
            'socket.io-client'
        ]
    },
    output: {
        path: path.resolve(appPath, 'js'),
        filename: 'app.js',
        publicPath: '/'
    },
    resolve: {
        extensions: ['.js', '.jsx'],
        modules: [
            path.resolve(__dirname, 'node_modules'),
            path.resolve(srcPath, 'fonts'),
            path.resolve(srcPath, 'helper'),
            path.resolve(srcPath, 'screens'),
            path.resolve(srcPath, 'components')
        ]
    },
    module: {
        rules: [{
            test: /\.jsx?$/,
            use: 'babel-loader'
        }, {
            test: /\.(woff2?|jpg|jpeg|png|ico)$/,
            use: {
                loader: 'file-loader',
                options: {
                    name: '[name].[ext]'
                }
            }
        }]
    },
    plugins: [
        new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            filename: 'vendor.js'
        }),
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify('production')
        }),
        new UglifyJsWebpackPLugin(),
        new PrepackWebpackPlugin()
    ]
};

module.exports = webpackConfig;

I'm on the latest version of prepack-webpack-plugin, thought my app was corrupt, but that isn't the case. I tested it with a basic setup of just importing React, React-Dom and then just rendering a basic Hello World!.

Any ideas what could cause this?

prepack is not a function

/Users/chet/Code/notion-next/node_modules/prepack-webpack-plugin/src/PrepackPlugin.js:58
            const prepackedCode = prepack(code, {
                                  ^
TypeError: (0 , _prepack.prepack) is not a function
    at Compilation.compilation.plugin (/Users/chet/Code/notion-next/node_modules/prepack-webpack-plugin/src/PrepackPlugin.js:58:35)
    at Compilation.applyPluginsAsyncSeries (/Users/chet/Code/notion-next/node_modules/tapable/lib/Tapable.js:206:13)
    at self.applyPluginsAsync.err (/Users/chet/Code/notion-next/node_modules/webpack/lib/Compilation.js:666:10)
    at next (/Users/chet/Code/notion-next/node_modules/tapable/lib/Tapable.js:202:11)
    at Compilation.<anonymous> (/Users/chet/Code/notion-next/node_modules/extract-text-webpack-plugin/dist/index.js:275:11)
    at next (/Users/chet/Code/notion-next/node_modules/tapable/lib/Tapable.js:204:14)
    at Compilation.<anonymous> (/Users/chet/Code/notion-next/node_modules/extract-text-webpack-plugin/dist/index.js:275:11)
    at Compilation.applyPluginsAsyncSeries (/Users/chet/Code/notion-next/node_modules/tapable/lib/Tapable.js:206:13)
    at sealPart2 (/Users/chet/Code/notion-next/node_modules/webpack/lib/Compilation.js:662:9)
    at next (/Users/chet/Code/notion-next/node_modules/tapable/lib/Tapable.js:202:11)
    at /Users/chet/Code/notion-next/node_modules/extract-text-webpack-plugin/dist/index.js:244:13
    at /Users/chet/Code/notion-next/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/Users/chet/Code/notion-next/node_modules/async/dist/async.js:1050:13)
    at /Users/chet/Code/notion-next/node_modules/async/dist/async.js:958:16
    at /Users/chet/Code/notion-next/node_modules/extract-text-webpack-plugin/dist/index.js:227:15
    at /Users/chet/Code/notion-next/node_modules/async/dist/async.js:473:16

Not working with worker loader

Prepack fails when trying to parse worker-loader generated bundle

 65% building modules 1234/1335 modules 101 active ...s/babel-runtime/core-js/array/from.jsnot an object
TypeError
    at ../node_modules/babel-loader/lib/index.js!./path/to/worker/file.js(8569baa88463d70f55c2.worker.js:184:34)
    at call (native)
    at __webpack_require__ (8569baa88463d70f55c2.worker.js:20:12)
    at 8569baa88463d70f55c2.worker.js:63:18
    at 8569baa88463d70f55c2.worker.js:1:10
/Users/teo/Work/smartup-ui/node_modules/prepack/lib/prepack-standalone.js:68
    throw _errors.fatalError;
    ^

Error: A fatal error occurred while prepacking.
    at new FatalError (/Users/teo/Work/smartup-ui/node_modules/prepack/lib/errors.js:48:14)
    at Object.<anonymous> (/Users/teo/Work/smartup-ui/node_modules/prepack/lib/errors.js:55:39)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/teo/Work/smartup-ui/node_modules/prepack/lib/realm.js:21:15)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/teo/Work/smartup-ui/node_modules/prepack/lib/methods/call.js:19:14)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)

Doesn't work with node 7

the engine line in the package.json prevents people from being able to install on node versions greater than 7

throw new InitializationError()

After added to webpack and run, I have error:

....
91% additional asset processingnot an object                                            

TypeError

~/project/node_modules/prepack/lib/prepack-standalone.js:59
throw new InitializationError();
^

Error: An error occurred while prepacking. See the error logs.
    at new InitializationError (~/project/node_modules/prepack/lib/prepack-standalone.js:35:14)
at prepack (~/project/node_modules/prepack/lib/prepack-standalone.js:59:11)
at Compilation.compilation.plugin (~/project/node_modules/prepack-webpack-plugin/dist/PrepackPlugin.js:58:56)
at Compilation.applyPluginsAsyncSeries (~/project/node_modules/tapable/lib/Tapable.js:142:13)
at self.applyPluginsAsync.err (~/project/node_modules/webpack/lib/Compilation.js:635:10)
at next (~/project/node_modules/tapable/lib/Tapable.js:138:11)
at Compilation.compilation.plugin.callback (~/project/node_modules/webpack/lib/ProgressPlugin.js:113:6)
at next (~/project/node_modules/tapable/lib/Tapable.js:140:14)
at ExtractTextPlugin.<anonymous> (~/project/node_modules/extract-text-webpack-plugin/index.js:341:4)
at next (~/project/node_modules/tapable/lib/Tapable.js:140:14)
at ExtractTextPlugin.<anonymous> (~/project/node_modules/extract-text-webpack-plugin/index.js:341:4)
at next (~/project/node_modules/tapable/lib/Tapable.js:140:14)
at ExtractTextPlugin.<anonymous> (~/project/node_modules/extract-text-webpack-plugin/index.js:341:4)
at Compilation.applyPluginsAsyncSeries (~/project/node_modules/tapable/lib/Tapable.js:142:13)
at sealPart2 (~/project/node_modules/webpack/lib/Compilation.js:631:9)
at next (~/project/node_modules/tapable/lib/Tapable.js:138:11)
at Compilation.compilation.plugin (~/project/node_modules/webpack/lib/ProgressPlugin.js:109:6)
at next (~/project/node_modules/tapable/lib/Tapable.js:140:14)
at ExtractTextPlugin.<anonymous> (~/project/node_modules/extract-text-webpack-plugin/index.js:313:5)
at ~/project/node_modules/async/dist/async.js:356:16
at iteratorCallback (~/project/node_modules/async/dist/async.js:936:13)
at ~/project/node_modules/async/dist/async.js:840:16
at ~/project/node_modules/extract-text-webpack-plugin/index.js:297:6
at ~/project/node_modules/async/dist/async.js:356:16
at iteratorCallback (~/project/node_modules/async/dist/async.js:936:13)
at ~/project/node_modules/async/dist/async.js:840:16
at ~/project/node_modules/extract-text-webpack-plugin/index.js:294:13
at ~/project/node_modules/async/dist/async.js:3025:16
at eachOfArrayLike (~/project/node_modules/async/dist/async.js:941:9)
at eachOf (~/project/node_modules/async/dist/async.js:991:5)
at Object.eachLimit (~/project/node_modules/async/dist/async.js:3089:3)

Packege.json :

{
  "name": "project",
  "version": "0.0.1",
  "devDependencies": {
   /*....*/
    "prepack-webpack-plugin": "^1.1.0",
    "webpack": "^2.5.0",
    "webpack-dev-server": "^2.4.5"
  },
  "dependencies": {
   /*...*/
  }
}

webpack config:

entry: { /*...*/},
module: {
        rules: [
          {
                test: /\.js$/,
                exclude: /node_modules/,
                use: [
                    'react-hot-loader',
                    'jsx-loader',
                    {
                        loader: 'babel-loader',
                        query: {
                            presets: ['react', 'es2015', 'stage-0'],
                            plugins: ['transform-regenerator', 'transform-async-functions', 'transform-react-display-name', 'transform-decorators-legacy', 'transform-react-jsx-img-import'],
                            cacheDirectory: false
                        }
                    }
                ]
            },
          /*....*/
       ]
},
 plugins: [
        new PrepackWebpackPlugin({}),
        /*....*/
]

Add this to webpack-contrib

Are you thinking about adding this to webpack contrib, if so, I'll go ahead and delete mine so you can continue development on it.

webpack 4 crash

I have include plugin in my config and got the error:

....
[0] finish module graph
  0% [0] after dependencies optimization
[0] advanced module optimization
[0] basic chunk optimization
[0] basic chunk optimization
[0] advanced chunk optimization
[0] basic chunk optimization
[0] chunk modules optimization
  0% [0] after chunk modules optimization
[0] chunk reviving
  0% [0] hashing
  0% [0] chunk assets processing
  0% [0] additional chunk assets processing
[0] chunk asset optimization
Warn: PP1023: Program may terminate with exception: not an object
Error
  TypeError
    
    at e79af574d74c913e5be8.chunk.js:2:35 at 2:34 to 2:48
Warn: PP1023: Program may terminate with exception: not an object

.......  here goes a list of all chunks with such error
    
...\node_modules\prepack-webpack-plugin\dist\PrepackPlugin.js:27
  return chunk.hasRuntime() && chunk.isInitial();
                                     ^

TypeError: chunk.isInitial is not a function
    at isEntryChunk (...\node_modules\prepack-webpack-plugin\src\PrepackPlugin.js:23:38)
    at compilation.plugin (...\node_modules\prepack-webpack-plugin\src\PrepackPlugin.js:56:26)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (...\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:12:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (...\node_modules\tapable\lib\Hook.js:35:21)
    at hooks.additionalAssets.callAsync.err (...\node_modules\webpack\lib\Compilation.js:943:36)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (...\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:9:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (...\node_modules\tapable\lib\Hook.js:35:21)
    at hooks.optimizeTree.callAsync.err (...\node_modules\webpack\lib\Compilation.js:939:32)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (...\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:9:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (...\node_modules\tapable\lib\Hook.js:35:21)
    at Compilation.seal (...\node_modules\webpack\lib\Compilation.js:881:27)
    at hooks.make.callAsync.err (...\node_modules\webpack\lib\Compiler.js:464:17)
    at _err0 (eval at create (...\node_modules\tapable\lib\HookCodeFactory.js:24:12), <anonymous>:11:1)
    at _addModuleChain (...\node_modules\webpack\lib\Compilation.js:749:12)
    at processModuleDependencies.err (...\node_modules\webpack\lib\Compilation.js:688:9)
    at process._tickCallback (internal/process/next_tick.js:150:11)
script exit code: 1npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `prun build`
npm ERR! Exit status 1
npm ERR! 

here is my part of optimization config

optimization: {
        splitChunks: {
            cacheGroups: {
                vendor: {
                    test: /node_modules/, // you may add "vendor.js" here if you want to
                    name: 'vendor',
                    chunks: 'initial',
                    enforce: true,
                },
            },
        },
        runtimeChunk: {
            name: 'runtime',
        },
        minimizer: [new BabiliPlugin(), new OptimizeJsPlugin({ sourceMap: false })],
    },

Conflict with UglifyJsPlugin

plugins: [
    new PrepackPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      sourceMap:true,
      compress:true
    })
  ]

Will fire an error:

ERROR in bundle.js from UglifyJs
TypeError: Cannot read property 'section' of null

But if I flip the order of applying plugins, everything is fine:

plugins: [
    new webpack.optimize.UglifyJsPlugin({
      sourceMap:true,
      compress:true
    }),
    new PrepackPlugin()
  ]

And if I turn off sourceMap, everything is also fine.

plugins: [
    new PrepackPlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress:true
    })
  ]

Warn: PP0023: Program may terminate with exception: require is not defined

Hi, I'm trying to include this plugin in my webpack configuration but it is throwing this error:

Warn: PP0023: Program may terminate with exception: require is not defined ReferenceError at server.js:22302:18 at __webpack_require__ (server.js:20:12) at server.js:22293:1 at __webpack_require__ (server.js:20:12) at server.js:84:18 at server.js:1:10 at 22302:17 to 22302:24 Error

I'm using babel and I've removed Uglify to avoid any incompatibility
Thanks

Code splits limitation

Detailed Description

Since code split creates multiple independent chunks, prepack can only apply optimizations to chunk "shells", not modules contained in these chunks (maybe except for entry chunk).
I wondering if there is any workaround for this ?

Possible Implementation

call __optimize(module) for each module in a chunk
eg: https://prepack.io/repl.html#GYVwdgxgLglg9mABAWzgExAGwKYEYAUAlIgN4BQiioksCVccRpFliATtlCG0gOTANeAbhYBfFtWjwkAIwCGbJuVbtO3PvLbCxLDlx71GxANSJNREeLIB9a3AAOsZDABe2fKgw5chMkA

`chunk.hasRuntime is not a function` with Angular & Babel

There's prolly something really obvious here that I'm missing. Plugin seems to refuse to work with my stack, which is a fork of http://juhamust.github.io/silverplate

Steps to reproduce

  • git clone https://github.com/juhamust/silverplate.git
  • npm install
  • npm install prepack-webpack-plugin --save-dev
  • Do the minimal setup according to instructions

After this

$ git diff
diff --git a/package.json b/package.json
index 140f670..e6aaff4 100644
--- a/package.json
+++ b/package.json
@@ -51,6 +51,7 @@
     "normalize.css": "^3.0.3",
     "postcss-loader": "^0.8.0",
     "precss": "^1.4.0",
+    "prepack-webpack-plugin": "^1.1.0",
     "raw-loader": "^0.5.1",
     "resolve-url": "^0.2.1",
     "resolve-url-loader": "^1.4.3",
diff --git a/webpack.config.js b/webpack.config.js
index 3fa42f4..fbf1b74 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -5,6 +5,7 @@ var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
 var autoprefixer = require('autoprefixer');
 var precss = require('precss');
 var packageInfo = require('./package.json');
+var PrepackWebpackPlugin = require('prepack-webpack-plugin').default;
 
 module.exports = {
   context: __dirname,
@@ -30,6 +31,8 @@ module.exports = {
   },
   noParse: [],
   plugins: [
+    new PrepackWebpackPlugin({
+    }),
     new ExtractTextPlugin('app.css', { allChunks: true }),
     new HtmlWebpackPlugin({
       version: packageInfo.version,

Then fire it up

$ npm start
[...]
/home/tero/src/silverplate/node_modules/prepack-webpack-plugin/dist/PrepackPlugin.js:27
  return chunk.hasRuntime() && chunk.isInitial();
               ^

TypeError: chunk.hasRuntime is not a function
    at isEntryChunk (/home/tero/src/silverplate/node_modules/prepack-webpack-plugin/src/PrepackPlugin.js:23:16)

There seems to be abundance of causes for chunk.hasRuntime is not a function and I couldn't find out how to make it work.

webpack unhandledRejection error

Actual Behavior

unhandledRejection TypeError: Cannot read property 'compilation' of undefined

Specifications

  • Node.js version: 9.10.1
  • Plugin version: 1.1.1
  • Webpack version: 4.17.1

This operation not yet supported on an abstract value

Gave this a shot on a pretty big codebase as an experiment and I got this error:

This operation is not yet supported on abstract value
__IntrospectionError
    at app.js:19887:56
    at call (native)
    at __webpack_require__ (app.js:20:12)
    at app.js:127578:29
    at call (native)
    at __webpack_require__ (app.js:20:12)
    at app.js:17934:18
    at call (native)
    at __webpack_require__ (app.js:20:12)
    at app.js:137943:16
    at call (native)
    at __webpack_require__ (app.js:20:12)
    at app.js:66:18
    at app.js:1:10

/Users/chet/Code/notion-next/node_modules/prepack/src/prepack-standalone.js:24
  let self = new Error("An error occurred while prepacking. See the error logs.");
             ^
Error: An error occurred while prepacking. See the error logs.
    at new InitializationError (/Users/chet/Code/notion-next/node_modules/prepack/src/prepack-standalone.js:24:14)
    at prepack (/Users/chet/Code/notion-next/node_modules/prepack/src/prepack-standalone.js:39:11)
    at Compilation.compilation.plugin (/Users/chet/Code/notion-next/node_modules/prepack-webpack-plugin/src/PrepackPlugin.js:58:35)
    at Compilation.applyPluginsAsyncSeries (/Users/chet/Code/notion-next/node_modules/tapable/lib/Tapable.js:142:13)
    at self.applyPluginsAsync.err (/Users/chet/Code/notion-next/node_modules/webpack/lib/Compilation.js:626:10)
    at Compilation.applyPluginsAsyncSeries (/Users/chet/Code/notion-next/node_modules/tapable/lib/Tapable.js:131:46)
    at sealPart2 (/Users/chet/Code/notion-next/node_modules/webpack/lib/Compilation.js:622:9)
    at Compilation.applyPluginsAsyncSeries (/Users/chet/Code/notion-next/node_modules/tapable/lib/Tapable.js:131:46)
    at Compilation.seal (/Users/chet/Code/notion-next/node_modules/webpack/lib/Compilation.js:570:8)
    at /Users/chet/Code/notion-next/node_modules/webpack/lib/Compiler.js:474:16

Any ideas where I might find those logs?

BundelTracker incompatibility

Hi all, I am fairly new to react and webpack.
But once I want to implement the prepack wepback optimisation, it gives an invalid RegExp SyntaxError
as described by :
Are my settings not right, or is this a deeper level bug with the bundletracker?

invalid RegExp
SyntaxError
    at call (native)
    at __webpack_require__ (main-fac13eab93be169f21c7.js:20:12)
    at main-fac13eab93be169f21c7.js:26551:21
    at call (native)
    at call (native)
    at __webpack_require__ (main-fac13eab93be169f21c7.js:20:12)
    at main-fac13eab93be169f21c7.js:76:18
    at call (native)
    at __webpack_require__ (main-fac13eab93be169f21c7.js:20:12)
    at main-fac13eab93be169f21c7.js:60502:14
    at call (native)
    at __webpack_require__ (main-fac13eab93be169f21c7.js:20:12)
    at main-fac13eab93be169f21c7.js:64028:12
    at call (native)
    at __webpack_require__ (main-fac13eab93be169f21c7.js:20:12)
    at main-fac13eab93be169f21c7.js:66:18
    at main-fac13eab93be169f21c7.js:1:10
{directory}/node_modules/prepack/lib/prepack-standalone.js:59
    throw new InitializationError();

My webpack config:

var path = require("path")
var webpack = require('webpack')
var BundleTracker = require('webpack-bundle-tracker')
var PrepackWebpackPlugin = require('prepack-webpack-plugin').default;
const configuration = {};

module.exports = {
  context: __dirname,
  entry: './assets/js/index', 

  output: {
    path: path.resolve('./assets/bundles/'),
    filename: "[name]-[hash].js",
  },

  plugins: [
    new BundleTracker({ filename: './webpack-stats.json' }),
    new PrepackWebpackPlugin(configuration)

  ],

  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        query:
        {
          presets: ['es2015', 'react','stage-0']
        }
      }, 
    ],
  },

  resolve: {
    modules: ['node_modules'],
    extensions: ['.js', '.jsx']
  },
  node: {
    fs: 'empty'
  },
  externals: [
    { "./cptable": "var cptable" }
  ]

}

Compatibility with old webpack

This doesn't work for older versions of webpack. For compatibility, can you consider changing:

const isEntryChunk = (chunk: Object) => {
  return chunk.hasRuntime() && chunk.isInitial();
};

to:

const isEntryChunk = (chunk: Object) => {
  return ((chunk.hasRuntime && chunk.hasRuntime()) || chunk.entry) && ((chunk.isInitial && chunk.isInitial()) || chunk.initial);
};

Broken npm version

The dist just has:

 "use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

exports.default = source => {};
//# sourceMappingURL=index.js.map

this is after npm installing :)

Write test cases

At the moment, there isn't anything exciting to test. Furthermore, as this project is using internal prepack API it might be too early to start writing tests using mocking.

This issue is open just to keep an eye on the subject.

FATAL ERROR: Javascript heap out of memory

Hello everyone, I tried to test but unfortunately it did not work ... below are the settings made and the error log occurred.

webpack.prod.config.js:

...
const PrepackWebpackPlugin = require('prepack-webpack-plugin').default;
...
const configuration = {};
...
    new PrepackWebpackPlugin(configuration),
...
oler ~/Projects/private/private/private-project[feature/prepack-webpack*]$ yarn build
yarn build v0.23.4
$ webpack -p --config webpack.prod.config.js --progress --profile --colors 
20665ms building modules                                                                   
151ms sealing
0ms optimizing 
0ms basic module optimization 
48ms module optimization
949ms advanced module optimization
71ms basic chunk optimization       
28ms chunk optimization
0ms basic chunk optimization        
18ms chunk optimization       
0ms basic chunk optimization        
10ms chunk optimization       
0ms basic chunk optimization        
10ms chunk optimization       
6ms advanced chunk optimization 
0ms module and chunk tree optimization 
81ms module reviving
0ms module order optimization 
9ms module id optimization 
9ms chunk reviving 
0ms chunk order optimization 
29ms chunk id optimization
124ms hashing
1ms module assets processing 
308ms chunk assets processing
10ms additional chunk assets processing
0ms recording 
 91% additional asset processing
<--- Last few GCs --->

[48230:0x103000000]   242410 ms: Mark-sweep 1401.5 (1496.5) -> 1401.4 (1465.5) MB, 2911.0 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 2911 ms) last resort 
[48230:0x103000000]   245147 ms: Mark-sweep 1401.4 (1465.5) -> 1401.4 (1465.5) MB, 2734.6 / 0.0 ms  last resort 


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x68aea0a66a1 <JS Object>
    1: visitQueue [/Users/oler/Projects/private/private/private-project/node_modules/babel-traverse/lib/context.js:~114] [pc=0x47fb9e7cd52](this=0x1e114403e1f1 <a TraversalContext with map 0x3b773b974a31>,queue=0x1e114403e239 <JS Array[1]>)
    2: node [/Users/oler/Projects/private/private/private-project/node_modules/babel-traverse/lib/index.js:~94] [pc=0x47fba07c66a](this=0xb3970eba7b1 <JS Funct...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
 4: v8::internal::Factory::NewByteArray(int, v8::internal::PretenureFlag) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
 5: v8::internal::Factory::NewCode(v8::internal::CodeDesc const&, unsigned int, v8::internal::Handle<v8::internal::Object>, bool, bool, int, bool) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
 6: v8::internal::PropertyAccessCompiler::GetCodeWithFlags(unsigned int, char const*) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
 7: v8::internal::NamedLoadHandlerCompiler::CompileLoadNonexistent(v8::internal::Handle<v8::internal::Name>) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
 8: v8::internal::NamedLoadHandlerCompiler::ComputeLoadNonexistent(v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Map>) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
 9: v8::internal::LoadIC::UpdateCaches(v8::internal::LookupIterator*) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
10: v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
11: v8::internal::Runtime_LoadIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/oler/.nvm/versions/node/v7.10.0/bin/node]
12: 0x47fb95843a7
โœจ  Done in 245.39s.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.