Any suggestion to prevent warnings when bundle with webpack?

···
WARNING in d:/dws/projects/febs/febs//express/lib/view.js
Critical dependencies:
78:29-56 the request of a dependency is an expression
@ d:/dws/projects/febs/febs/
/express/lib/view.js 78:29-56
···

Related code: https://github.com/strongloop/express/blob/master/lib/view.js#L78

P.S Webpack is very useful even in build server side bundles. It can reduce the size of release packages by include required js file only.

Author: Fantashit

2 thoughts on “Any suggestion to prevent warnings when bundle with webpack?

  1. @dougwilson , There is a way to avoid the warning:

    change these lines

      if (!opts.engines[this.ext]) {
        // load engine
        opts.engines[this.ext] = require(this.ext.substr(1)).__express;
      }

    to

      if (!opts.engines[this.ext]) {
        // use external loader to load engine.
        opts.engines[this.ext] = engineLoader(this.ext.substr(1));
      }

    and add this line to file head

    var engineLoader = require('./express-engine-loader');

    and then create a new file express-engine-loader.js

    // file: express-engine-loader.js
    module.exports = function engineLoader(ext) {
      return require(ext).__express;
    };

    OK, that’s all.

    Now, users can use webpack.NormalModuleReplacementPlugin to replace express-engine-loader in webpack’s build process to use static require which is friendly to bundler, or even ignore it by webpack.IgnorePlugin.

Comments are closed.