Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with hot reloading and "-d": "SyntaxError: missing ) after argument list" #18

Closed
alvaro-cuesta opened this issue Sep 21, 2014 · 7 comments

Comments

@alvaro-cuesta
Copy link

This is style-loader@~0.8.0. My *.styl loader looks like this: { test: /\.styl$/, loader: 'style!css!stylus' }.

The offending lines (specifically the one with module.hot.accept):

if(true) {
    // When the styles change, update the <style> tags
    module.hot.accept(/*! !../~/css-loader!../~/stylus-loader!./viewer.styl */ 2/*! !../~/css-loader!../~/stylus-loader!./viewer.styl */ 2, function() {
        var newContent = __webpack_require__(/*! !../~/css-loader!../~/stylus-loader!./viewer.styl */ 2);
        if(typeof newContent === 'string') newContent = [module.id, newContent, ''];
        update(newContent);
    });
    // When the module is disposed, remove the <style> tags
    module.hot.dispose(function() { update(); });
}
@sokra
Copy link
Member

sokra commented Sep 21, 2014

huh?... Looks like an webpack bug... :(

@alvaro-cuesta
Copy link
Author

Narrowed it down to using --output-pathinfo. Took a dive into style-loader and the code looks exactly like the next line (https://github.com/webpack/style-loader/blob/8ec1dc6ee6af93b4c89f6c52c15b2e8f44314939/index.js#L20-L21) but the output is different.

Happens both with vanilla webpack and dev-server.

Definitely a webpack bug, I guess.

@sokra
Copy link
Member

sokra commented Sep 21, 2014

Try to repoduce it, but with no success. It doesn't occur for me.

Could you please create a repro repo?

@alvaro-cuesta
Copy link
Author

Here's the repo: https://github.com/alvaro-cuesta/webpack-bug

npm install
npm start

Then go to http://localhost:8080/webpack-dev-server/bug and check the browser console.

SyntaxError: missing ) after argument list

@sokra
Copy link
Member

sokra commented Sep 21, 2014

ah ok... you applied the HotModuleReplacementPlugin twice. 1. with --hot and 2. in plugins.

@alvaro-cuesta
Copy link
Author

Woopsies, I'm sorry, thought --hot only added webpack/hot/dev-server.

@chosenvictim
Copy link

I am having the same issue, here is my webpack configuration:-

var webpack             = require('webpack');
var HtmlWebpackPlugin   = require('html-webpack-plugin');

module.exports = {
    devtool: 'cheap-module-eval-source-map',

    entry: {
        app: [
            'webpack-dev-server/client?http://localhost:8080',
            'webpack/hot/dev-server',
            './src/index.js',
        ],
        vendor: [
            'react',
            'react-dom',
        ],
    },

    output: {
        path: __dirname,
        pathinfo: true,
        filename: 'app.js',
        publicPath: '/',
    },

    resolve: {
        extensions: ['', '.js', '.jsx'],
        modules: [
            'src',
            'node_modules',
        ],
    },

    devServer: {
        stats: 'errors-only'
    },

    module: {
        loaders: [
            {
                test: /\.scss$/,
                loaders: ["style", "css", "sass"]
            }, {
                test: /\.jsx?$/,
                exclude: [/node_modules/, /.+\.config.js/],
                loader: 'babel',
                query: {
                    presets: ['es2015', 'react']
                }
            }, {
                test: /\.(jpe?g|gif|png|svg)$/i,
                loader: 'url-loader?limit=10000'
            }, {
                test: /\.json$/,
                loader: 'json-loader'
            },
        ],
    },

    plugins: [
        // Generates an `index.html` file with the <script> injected.
        new HtmlWebpackPlugin({
            inject: true,
            template: 'index.html',
        }),
        new webpack.HotModuleReplacementPlugin(),
        new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            minChunks: Infinity,
            filename: 'vendor.js',
        }),
        new webpack.DefinePlugin({
            'process.env': {
            CLIENT: JSON.stringify(true),
            'NODE_ENV': JSON.stringify('development'),
            }
        }),
    ]
};

And in the index.js, I am importing it as:-
import './index.scss'

index.scss file:-
body { margin: 0; background: cornsilk; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants