Skip to content

Bundaling ES class with static field lead to [Error: Line 5: Unexpected token =] #1008

@luboid

Description

@luboid

Hi,
I'm using
gulp-requirejs:1.4.0
which uses :
requirejs: ^2.3.6
Here is JS code that produces [Error: Line 5: Unexpected token =]
It runs perfectly fine in a browser

define(['$prcbPlugins', 'js/trnsl'], function ($, trnsl) {
	var actionHandlerUrl = '/api/external-notifications';

	class DAL {
		static contentReport = class ContentReport {
			static get(parameters) {
				return $.prcbExecute({
					url: actionHandlerUrl + '/contentreport',
					data: parameters,
					method: 'get'
				}).asPromise();
			}
		};

		static services = class Services {
			static all() {
				return $.prcbExecute({
					url: actionHandlerUrl + '/services',
					method: 'get'
				}).asPromise();
			}
			static get(id) {
				return $.prcbExecute({
					url: actionHandlerUrl + '/services/:id',
					data: { id: id },
					method: 'get'
				}).asPromise();
			}
		};

		static eventTypes = class EventTypes {
			static all() {
				return $.prcbExecute({
					url: actionHandlerUrl + '/eventtypes',
					method: 'get'
				}).asPromise();
			}
			static get(id) {
				return $.prcbExecute({
					url: actionHandlerUrl + '/eventtypes/:id',
					data: { id: id },
					method: 'get'
				}).asPromise();
			}
		};

		static channels = class Channels {
			static all() {
				return new Promise((resolve) => {
					let channels = [
						{ id: 0, title: 'SMS' },
						{ id: 1, title: 'EMail' }
					];
					resolve(channels);
				});
			}

			static providers() {
				return new Promise((resolve) => {
					let channels = [
						{ id: 0, title: 'ProCredit' },
						{ id: 1, title: 'Teracom' },
						{ id: 2, title: 'Mobica' },
					];
					resolve(channels);
				});
			}

			static enum = class Enum {
				static SMS = 0;
				static Email = 1;
			}
		}

		static statuses = class Statuses {
			static all() {
				return new Promise((resolve) => {
					let statuses = [
						{ id: 0, title: trnsl.gettext('за формиране') },
						{ id: 1, title: trnsl.gettext('формиран') },
						{ id: 2, title: trnsl.gettext('завършена комуникация') },
						{ id: 3, title: trnsl.gettext('липсващ или невалиден темплейт') },
						{ id: 4, title: trnsl.gettext('грешка при комуникация') },
						{ id: 5, title: trnsl.gettext('твърде много грешки') },
					];
					resolve(statuses);
				});
			}
		}

		static utils = class Utils {
			static toHash(array, id, descr) {
				if (id === undefined) {
					id = 'id';
				}
				if (descr === undefined) {
					descr = 'title';
				}

				let o = {};
				array.forEach(i => o[i[id]] = i[descr]);

				return o;
            }
        }
	}

	return DAL;
})

Here is config

module.exports = ({
    baseUrl: "../",
    mainConfigFile: 'default.js', //???
    paths: {
        'services': '../../scripts/services',
        'toastr': 'empty:',
        'resources': '../../scripts/jq/requirejs.plugins/resources',
        '$plugins': '../../scripts/jq/plugins',
        'jquery': 'empty:',
        '$prcbPlugins': 'empty:',
        'knockout': 'empty:',
        'knockout.prcb': 'empty:',
        'durandal/activator': 'empty:',
        'durandal/app': 'empty:',
        'durandal/binder': 'empty:',
        'durandal/composition': 'empty:',
        'durandal/events': 'empty:',
        'durandal/history': 'empty:',
        'durandal/http': 'empty:',
        'durandal/observable': 'empty:',
        'durandal/serializer': 'empty:',
        'plugins/widget': 'empty:',
        'durandal/system': 'empty:',
        'durandal/entrance': 'empty:',
        'durandal/viewEngine': 'empty:',
        'durandal/viewLocator': 'empty:',
        'plugins/dialog': 'empty:',
        'plugins/prcb': 'empty:',
        'plugins/prcbroutes': 'empty:',
        'plugins/prcbmessagelistener': 'empty:',
        'plugins/history': 'empty:',
        'plugins/router': 'empty:',
        'globalize': 'empty:',
        'translations': 'empty:',
        'bctx': 'empty:',
        'underscore': 'empty:',
        '$ui': 'empty:'
    },
    optimize: 'none',
    generateSourceMaps: false,
    preserveLicenseComments: true,
    optimizeCss: "none",
    removeCombined: true,
    name: "js/default",
    exclude: [
        // ако при dependency-тата има някой, който не трябва да бъде включен във файла
		'resources'
    ],
    out: 'app.js',
    wrap: true,
    rawText: {
        'translations': 'define(function () { return {}; });',
        'bctx': 'define(function () { return {}; });'
    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions