From: Stas Vilchik Date: Wed, 6 Apr 2016 09:57:10 +0000 (+0200) Subject: expose js libs through global variables X-Git-Tag: 5.5-RC1~27 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6dd7963bfe3673255800e2adb38fe05f53a80eef;p=sonarqube.git expose js libs through global variables --- diff --git a/server/sonar-web/src/main/js/main/app.js b/server/sonar-web/src/main/js/main/app.js index 331e5429d71..10de904d972 100644 --- a/server/sonar-web/src/main/js/main/app.js +++ b/server/sonar-web/src/main/js/main/app.js @@ -21,16 +21,11 @@ import 'babel-polyfill'; import $ from 'jquery'; import _ from 'underscore'; import Backbone from 'backbone'; -import Marionette from 'backbone.marionette'; import 'whatwg-fetch'; import moment from 'moment'; -import numeral from 'numeral'; import './processes'; import Navigation from './nav/app'; import { installGlobal, requestMessages } from '../helpers/l10n'; -import React from 'react'; -import ReactDOM from 'react-dom'; -import d3 from 'd3'; import * as measures from '../helpers/measures'; import * as request from '../helpers/request'; @@ -83,28 +78,5 @@ window.sonarqube.appStarted = Promise.resolve() .then(startNavigation) .then(prepareAppOptions); -// expose libraries -window.require = module => { - switch (module) { - case 'backbone': - return Backbone; - case 'backbone.marionette': - return Marionette; - case 'moment': - return moment; - case 'numeral': - return numeral; - case 'react': - return React; - case 'react-dom': - return ReactDOM; - case 'd3': - return d3; - case 'sonar-measures': - return measures; - case 'sonar-request': - return request; - default: - return null; - } -}; +window.SonarMeasures = measures; +window.SonarRequest = request; diff --git a/server/sonar-web/webpack.config.js b/server/sonar-web/webpack.config.js index 4589431a6b1..c70942bef74 100644 --- a/server/sonar-web/webpack.config.js +++ b/server/sonar-web/webpack.config.js @@ -85,22 +85,18 @@ module.exports = { helperDirs: path.join(__dirname, 'src/main/js/helpers/handlebars') } }, - { - test: require.resolve('jquery'), - loader: 'expose?$!expose?jQuery' - }, - { - test: require.resolve('underscore'), - loader: 'expose?_' - }, - { - test: require.resolve('d3'), - loader: 'expose?d3' - }, { test: /\.css/, loader: 'style-loader!css-loader!postcss-loader' - } + }, + { test: require.resolve('jquery'), loader: 'expose?$!expose?jQuery' }, + { test: require.resolve('underscore'), loader: 'expose?_' }, + { test: require.resolve('backbone'), loader: 'expose?Backbone' }, + { test: require.resolve('backbone.marionette'), loader: 'expose?Marionette' }, + { test: require.resolve('d3'), loader: 'expose?d3' }, + { test: require.resolve('react'), loader: 'expose?React' }, + { test: require.resolve('react-dom'), loader: 'expose?ReactDOM' }, + { test: require.resolve('react-dom'), loader: 'expose?ReactDOM' } ] }, postcss: function () {