diff --git a/.eslintrc b/.eslintrc index 1c9210ea..fa7fcb81 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,8 +1,15 @@ { + "parserOptions": { + "ecmaVersion": 6 + }, + "ecmaFeatures": { + "modules": true + }, "env": { "browser": true, "node": true, - "amd": true + "amd": true, + "es6": true }, "rules": { diff --git a/js/main.js b/js/main.js index a1ed0125..0ed1e5f9 100644 --- a/js/main.js +++ b/js/main.js @@ -1,41 +1,31 @@ -define([ - 'browser', - 'main-window-dom', - '../css/winamp.css', - '../css/main-window.css', - '../css/context-menu.css', - 'winamp', - 'context', - 'hotkeys' -], function( - Browser, - mainWindowDom, - winampCss, - mainWindowCss, - contextMenuCss, - Winamp, - Context, - Hotkeys -) { - if (new Browser(window).isCompatible) { - var mainWindowElement = document.createElement('div'); - mainWindowElement.appendChild(mainWindowDom); - document.getElementById('winamp2-js').appendChild(mainWindowElement); +import Browser from './browser'; +import mainWindowDom from './main-window-dom'; +import Winamp from './winamp'; +import Context from './context'; +import Hotkeys from './hotkeys'; - var winamp = Winamp.init({ - volume: 50, - balance: 0, - mediaFile: { - url: 'https://cdn.rawgit.com/captbaritone/llama/master/llama-2.91.mp3', - name: "1. DJ Mike Llama - Llama Whippin' Intro" - }, - skinUrl: 'https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/base-2.91.wsz' - }); +import '../css/winamp.css'; +import '../css/main-window.css'; +import '../css/context-menu.css'; - new Hotkeys(winamp); - new Context(winamp); - } else { - document.getElementById('winamp').style.display = 'none'; - document.getElementById('browser-compatibility').style.display = 'block'; - } -}); +if (new Browser(window).isCompatible) { + var mainWindowElement = document.createElement('div'); + mainWindowElement.appendChild(mainWindowDom); + document.getElementById('winamp2-js').appendChild(mainWindowElement); + + var winamp = Winamp.init({ + volume: 50, + balance: 0, + mediaFile: { + url: 'https://cdn.rawgit.com/captbaritone/llama/master/llama-2.91.mp3', + name: "1. DJ Mike Llama - Llama Whippin' Intro" + }, + skinUrl: 'https://cdn.rawgit.com/captbaritone/winamp-skins/master/v2/base-2.91.wsz' + }); + + new Hotkeys(winamp); + new Context(winamp); +} else { + document.getElementById('winamp').style.display = 'none'; + document.getElementById('browser-compatibility').style.display = 'block'; +} diff --git a/package.json b/package.json index c5a67d57..d06439a9 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,9 @@ }, "homepage": "https://github.com/captbaritone/winamp2-js#readme", "devDependencies": { + "babel-core": "^6.10.4", + "babel-loader": "^6.2.4", + "babel-preset-es2015": "^6.9.0", "css-loader": "^0.23.1", "eslint": "1.*", "style-loader": "^0.13.1", diff --git a/webpack.config.js b/webpack.config.js index 9240af1d..2eca6e9e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -9,6 +9,14 @@ module.exports = { { test: /\.css$/, loader: 'style-loader!css-loader' + }, + { + test: /\.js$/, + exclude: /(node_modules|bower_components)/, + loader: 'babel', // 'babel-loader' is also a legal name to reference + query: { + presets: ['es2015'] + } } ], noParse: [