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

Unexpected token [ in ProductionModePlugin.js:147 #79

Closed
Moxh3 opened this issue Dec 26, 2017 · 2 comments
Closed

Unexpected token [ in ProductionModePlugin.js:147 #79

Moxh3 opened this issue Dec 26, 2017 · 2 comments

Comments

@Moxh3
Copy link

Moxh3 commented Dec 26, 2017

Error when running webpack with production set to false:

globalize-webpack-plugin\ProductionModePlugin.js:147
for (let [locale, chunk] of compiledDataChunks.entries()) {
^
SyntaxError: Unexpected token [
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (globalize-webpack-plugin\index.js:4:30)
at Module._compile (module.js:397:26)
at Object.Module._extensions..js (module.js:404:10)

webpack-config.js:

const path = require('path');
const webpack = require('webpack');
const CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const extractCSS = new ExtractTextPlugin('allstyles.css');
const GlobalizePlugin = require("globalize-webpack-plugin");

module.exports = {
    entry: {
        main: './wwwroot/source/app.js',
        vendor: [
            "globalize",
            "globalize/dist/globalize-runtime/number",
            "globalize/dist/globalize-runtime/currency",
            "globalize/dist/globalize-runtime/date",
            "globalize/dist/globalize-runtime/message",
            "globalize/dist/globalize-runtime/plural",
            "globalize/dist/globalize-runtime/relative-time",
            "globalize/dist/globalize-runtime/unit"
        ]
    },
    output: {
        path: path.resolve(__dirname, 'wwwroot/dist'),
        filename: 'bundle.js',
        publicPath: 'dist/'
    },
    plugins: [
        extractCSS,
        new webpack.ProvidePlugin({
            $: 'jquery',
            jQuery: 'jquery',
            'window.jQuery': 'jquery',
            Popper: ['popper.js', 'default'],
        }),
        new GlobalizePlugin({
            production: false, // true: production, false: development
            developmentLocale: "en", // locale to be used for development.
            supportedLocales: ["en", "nl", "fr"], // locales that should be built support for.
            output: "globalize-compiled-data-[locale].[hash].js", // build output.
            tmpdirBase: ".", // optional for non create-react-apps
        }),       
    ].concat([
            new CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.bundle.js' }),
            new webpack.optimize.UglifyJsPlugin()
        ]),
    module: {
        rules: [
            {
                test: /\.css$/,
                use: extractCSS.extract({
                    fallback: 'style-loader',
                    use: 'css-loader?minimize'
                })
            },
            {
                test: /\.js$/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['@babel/preset-env']
                    }
                }
            },
            {
                test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                loader: "url-loader?limit=10000&mimetype=application/font-woff"
            },
            {
                test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
                loader: "file-loader"
            },
            {
                test: /\.(png|jpg|gif)$/,
                use: [
                    {
                        loader: 'url-loader',
                        options: {
                            limit: 8192
                        }
                    }
                ]
            }

        ]
    }
};

Versions:

  • webpack: 3.10.0
  • globalize-webpack-plugin: 2.0.1
  • extract-text-webpack-plugin: 3.0.2
@Monohromnaya
Copy link

Monohromnaya commented Feb 6, 2018

same problem:

C:\work\dashboard\Ginger\Ginger.Ui\node_modules\globalize-webpack-plugin\ProductionModePlugin.js:147
for (let [locale, chunk] of compiledDataChunks.entries()) {
^
SyntaxError: Unexpected token [
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object. (C:\work\dashboard\Ginger\Ginger.Ui\node_modules\globalize-webpack-plugin\index.js:4:30)
at Module._compile (module.js:397:26)
at Object.Module._extensions..js (module.js:404:10)

` plugins: [

    new GlobalizePlugin({
        developmentLocale: "ru",
        supportedLocales: ["ar", "de", "en", "es", "pt", "ru", "zh"],
        messages: "messages/[locale].json",
        output: "i18n/[locale].[hash].js",

      
        tmpdirBase: "." // optional for non create-react-apps
    })
]`

@rxaviers
Copy link
Owner

In your development environment, you need to use Node >= 6.

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