js-dxtools / js-dxtools/webpack-validator

validate pass but cannot run

Open
#153 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
290
Forks
23
PR merge metrics
No merged PRs in 30d

Description

error info:

node src/app/server.js


/Users/willin/Desktop/test/electronvue/node_modules/webpack/lib/webpack.js:19
                throw new WebpackOptionsValidationError(webpackOptionsValidationErrors);
                ^

Error
    at webpack (/Users/willin/Desktop/test/electronvue/node_modules/webpack/lib/webpack.js:19:9)
    at Object.<anonymous> (/Users/willin/Desktop/test/electronvue/src/app/server.js:7:18)
    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.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

webpack-config:

base.js

const path = require('path');

module.exports = {
  module: {
    loaders: [{
      test: /\.vue?$/,
      loader: 'vue-loader',
      exclude: /node_modules/
    }, {
      test: /\.js$/,
      loader: 'babel-loader',
      query: {
        presets: ['latest'],
        plugins: [
          'transform-runtime'
        ]
      }
    }, {
      test: /\.(jpe?g|png|gif|svg)$/i,
      loaders: [
        'file?hash=sha512&digest=hex&name=[hash].[ext]',
        'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'
      ]
    }]
  },
  output: {
    path: path.join(__dirname, '../../build'),
    filename: 'app.js',
    publicPath: '/'
  },
  resolve: {
    root: path.join(__dirname, '../../'),
    extensions: ['', '.js', '.vue'],
    modulesDirectories: ['node_modules', 'src'],
    packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main'],
    alias: {}
  },
  plugins: [

  ],
  externals: [
  ]
};

development.js:

const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const baseConfig = require('./base');
const path = require('path');

const config = Object.create(baseConfig);

config.debug = true;

config.devtool = 'cheap-module-eval-source-map';

config.entry = [
  'webpack-hot-middleware/client?noInfo=true&reload=true',
  './src/app/app.js'
];

config.output.publicPath = 'http://localhost:3000/build/';

config.module.loaders.push({
  test: /^((?!\.module).)*\.css$/,
  loaders: [
    'style-loader',
    'css-loader'
  ]
}, {
  test: /\.module\.css$/,
  loaders: [
    'style-loader',
    'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!'
  ]
});

// config.resolve.alias.config = path.join(__dirname, '../config/development.js');

config.plugins.push(
  new webpack.HotModuleReplacementPlugin(),
  new webpack.NoErrorsPlugin(),
  new webpack.DefinePlugin({
    __DEV__: true,
    'process.env': {
      NODE_ENV: JSON.stringify('development')
    }
  }),
  new HtmlWebpackPlugin({
    filename: 'app.html',
    template: 'src/app/app.html'
  })
);

config.target = 'electron';

module.exports = config;

validate result:

[webpack-validator] Config is valid.
{ debug: true,
  devtool: 'cheap-module-eval-source-map',
  entry:
   [ 'webpack-hot-middleware/client?noInfo=true&reload=true',
     './src/app/app.js' ],
  target: 'electron' }

i found that:

const config = Object.create(baseConfig);
// console.log:   {} 

// ok
const config = new Object(baseConfig);

but still cannot run.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing node src/app/server.js and compare the validator output with the runtime failure at src/app/server.js:7. Read the configuration assembly in base.js and development.js, especially the Object.create(baseConfig) path; done means the reported configuration and the actual webpack run agree, with a focused regression test for the case found.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, webpack
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.