javascript - Uncaught SyntaxError: Unexpected token import in "backbone.radio.js" -
i'm trying migrate application backbone marionette (v3), got stuck in point 2 days already.
when try run app in browser, error shows in console (and screen blank):
uncaught syntaxerror: unexpected token import in backbone.radio.js:1
first line in backbone.radio.js import statement underscore:
import _ 'underscore';
i use requirejs module loader. configuration in main.js:
require.config({ paths: { jquery: '../bower_components/jquery/dist/jquery', underscore: '../bower_components/underscore/underscore', backbone: '../bower_components/backbone/backbone', 'backbone.radio': '../bower_components/backbone.radio/build/backbone.radio', 'backbone.babysitter': '../bower_components/backbone.babysitter/src/build/backbone.babysitter', marionette: '../bower_components/marionette/lib/backbone.marionette', bootstrap: '../bower_components/bootstrap/dist/js/bootstrap', text: '../bower_components/requirejs-plugins/lib/text' }, map: { '*': { 'backbone.wreqr': 'backbone.radio' } }, shim: { jquery: { exports: '$' }, underscore: { exports: '_' }, backbone: { deps: [ 'underscore', 'jquery' ], exports: 'backbone' }, marionette: { deps: [ 'jquery', 'underscore', 'backbone' ], exports: 'marionette' }, bootstrap: { deps: [ 'jquery' ] } } }) require(['appinstance'], function (app) { app.start() })
this appinstance.js:
define(function (require) { var app = require('app') return new app() })
and app.js file:
define(function (require) { var $ = require('jquery') var _ = require('underscore') var backbone = require('backbone') var router = require('router') var controller = require('controller') var marionette = require('marionette') var commonheaderview = require('views/common/header') return marionette.application.extend({ /** * define regions application. * * @returns {object} */ regions: function () { return { header: '#header' } }, /** * * @param {object} options */ start: function (options) { var commonheaderview = new commonheaderview() marionette.application.prototype.start.apply(this, [options]) this.header.show(commonheaderview) this.router = new router({ controller: new controller() }) backbone.history.start() } }) })
does know why i'm having problem?
unfortunately ran out of ideas on how solve this, appreciated.
p.s.: use marionette v3.0.0, backbone v1.2.3 , requirejs v2.1.15
that complains import
-statement indication referencing source file. make sure backbone.radio
-path goes build file.
Comments
Post a Comment