rxaviers / globalize-webpack-plugin

Globalize.js webpack plugin
Other
33 stars 27 forks source link

Unexpected token [ in ProductionModePlugin.js:147 #79

Closed Moxh3 closed 6 years ago

Moxh3 commented 6 years ago

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:

Monohromnaya commented 6 years ago

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 commented 6 years ago

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