Skip to content

Instantly share code, notes, and snippets.

@joeeames
Created July 22, 2017 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeeames/e8ff78b42437f13160aff2025858fb4c to your computer and use it in GitHub Desktop.
Save joeeames/e8ff78b42437f13160aff2025858fb4c to your computer and use it in GitHub Desktop.
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ var parentJsonpFunction = window["webpackJsonp"];
/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, resolves = [], result;
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId])
/******/ resolves.push(installedChunks[chunkId][0]);
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
/******/ while(resolves.length)
/******/ resolves.shift()();
/******/ if(executeModules) {
/******/ for(i=0; i < executeModules.length; i++) {
/******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]);
/******/ }
/******/ }
/******/ return result;
/******/ };
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // objects to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 3: 0
/******/ };
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
/******/ if(installedChunks[chunkId] === 0)
/******/ return Promise.resolve();
/******/
/******/ // an Promise means "currently loading".
/******/ if(installedChunks[chunkId]) {
/******/ return installedChunks[chunkId][2];
/******/ }
/******/ // start chunk loading
/******/ var head = document.getElementsByTagName('head')[0];
/******/ var script = document.createElement('script');
/******/ script.type = 'text/javascript';
/******/ script.charset = 'utf-8';
/******/ script.async = true;
/******/ script.timeout = 120000;
/******/
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = __webpack_require__.p + "" + chunkId + ".chunk.js";
/******/ var timeout = setTimeout(onScriptComplete, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ function onScriptComplete() {
/******/ // avoid mem leaks in IE.
/******/ script.onerror = script.onload = null;
/******/ clearTimeout(timeout);
/******/ var chunk = installedChunks[chunkId];
/******/ if(chunk !== 0) {
/******/ if(chunk) chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
/******/ installedChunks[chunkId] = undefined;
/******/ }
/******/ };
/******/
/******/ var promise = new Promise(function(resolve, reject) {
/******/ installedChunks[chunkId] = [resolve, reject];
/******/ });
/******/ installedChunks[chunkId][2] = promise;
/******/
/******/ head.appendChild(script);
/******/ return promise;
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/ __webpack_require__.i = function(value) { return value; };
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 473);
/******/ })
/************************************************************************/
/******/ ({
/***/ 141:
/***/ (function(module, exports) {
angular.module('app').component('userDetails', {
templateUrl: './userDetails.html',
bindings: {
allUsers: '='
},
controller: function ($routeParams) {
this.user = this.allUsers.find(function (user) {
return user.id === parseInt($routeParams.id);
});
}
});
//# sourceMappingURL=userDetails.js.map
/***/ }),
/***/ 142:
/***/ (function(module, exports) {
var app = angular.module('app', ['ngRoute', 'toastr']);
app.run(function ($rootScope, $location) {
$rootScope.$on("$routeChangeError", function (e, next, prev, err) {
if (err === "AUTH_REQUIRED") {
$location.path("/login");
}
if (err === 'NOT_AUTHORIZED') {
$location.path("/home");
}
});
});
// angular.element(document).ready(() => {
// angular.bootstrap(document.body, ['app'])
// });
//# sourceMappingURL=app.js.map
/***/ }),
/***/ 143:
/***/ (function(module, exports) {
angular.module('app').config(function ($routeProvider) {
var routeResolvers = {
loggedIn: function (auth) {
return auth.requireLogin();
},
waitForAuth: function (auth) {
return auth.waitForAuth();
},
requireAdmin: function (auth) {
return auth.requireAdmin();
},
userSessions: function (sessions, currentIdentity, auth) {
return auth.requireLogin().then(function () {
return sessions.getSessionsByUser(currentIdentity.currentUser.id);
});
},
allSessions: function (sessions, auth) {
return auth.requireLogin().then(function () {
return sessions.getAllSessions();
});
},
allUsers: function (users, auth) {
return auth.requireLogin().then(function () {
return users.getAllUsers();
});
}
};
$routeProvider
.when('/admin/login', {
template: '<admin-login></admin-login>',
resolve: {
currentAuth: routeResolvers.waitForAuth
}
})
.when('/admin/results', {
template: '<results all-sessions="$resolve.allSessions"></results>',
resolve: {
admin: routeResolvers.requireAdmin,
allSessions: routeResolvers.allSessions
}
})
.when('/admin/users/:id', {
template: '<user-details all-users="$resolve.allUsers"></user-details>',
resolve: {
admin: routeResolvers.requireAdmin,
allUsers: routeResolvers.allUsers
}
})
.when('/users', {
template: '<user-list all-users="$resolve.allUsers"></user-list>',
resolve: {
admin: routeResolvers.requireAdmin,
allUsers: routeResolvers.allUsers
}
})
.when('/admin/createusers', {
template: '<create-users></create-users>',
resolve: {
admin: routeResolvers.requireAdmin
}
})
.when('/home', {
template: '<home user-sessions="$resolve.userSessions"></home>',
resolve: {
login: routeResolvers.loggedIn,
userSessions: routeResolvers.userSessions
}
})
.when('/profile', {
template: '<profile></profile>',
resolve: {
userProfile: routeResolvers.loggedIn,
}
})
.when('/createsession', {
template: '<create-new-session user-sessions="$resolve.userSessions"></create-new-user>',
resolve: {
userSessions: routeResolvers.userSessions,
}
})
.when('/login', {
template: '<login></login>',
resolve: {
currentAuth: routeResolvers.waitForAuth
}
})
.when('/logout', {
template: '<logout></logout>'
})
.otherwise('/home');
});
//# sourceMappingURL=routes.js.map
/***/ }),
/***/ 148:
/***/ (function(module, exports) {
angular.module('app').component('adminLogin', {
templateUrl: './adminLogin.html',
bindings: {},
controller: function ($location, currentIdentity, auth, toastr) {
this.loggedIn = currentIdentity.authenticated();
if (this.loggedIn) {
$location.path('/home');
}
this.login = function () {
auth.login({
username: this.email,
password: this.password
}).then(function () {
$location.path('/home');
}, function (err) {
toastr.error(err);
});
};
}
});
//# sourceMappingURL=adminLogin.js.map
/***/ }),
/***/ 149:
/***/ (function(module, exports) {
angular.module('app').component('createUsers', {
templateUrl: './createUsers.html',
bindings: {},
controller: function (nameParser, users, toastr) {
this.import = function () {
var people = nameParser.parse(this.namesblob);
people.forEach((function (person) {
users.createNewUser({
email: person.email,
password: "pass",
firstName: person.firstName,
lastName: person.lastName
}).catch(function (error) {
toastr.error("User already exists: " + person.email);
}.bind(this));
}).bind(this));
toastr.success("Users Created!");
};
}
});
//# sourceMappingURL=createUsers.js.map
/***/ }),
/***/ 150:
/***/ (function(module, exports) {
angular.module('app').component('results', {
templateUrl: './results.html',
bindings: {
sessionsByVoteDesc: '=allSessions'
},
controller: function () {
this.sessionsByVoteDesc.sort(function (session1, session2) {
// reverse order
return session2.voteCount - session1.voteCount;
});
}
});
//# sourceMappingURL=results.js.map
/***/ }),
/***/ 151:
/***/ (function(module, exports) {
angular.module('app').component('userList', {
templateUrl: './userList.html',
bindings: {
users: '=allUsers'
},
controller: function () {
this.users.sort(function (user1, user2) {
if (user1.firstName < user2.firstName)
return -1;
if (user1.firstName === user2.firstName)
return 0;
if (user1.firstName > user2.firstName)
return 1;
});
}
});
//# sourceMappingURL=userList.js.map
/***/ }),
/***/ 152:
/***/ (function(module, exports) {
angular.module('app').filter('talkDuration', function () {
return function (duration) {
return "Duration: " + duration + " minutes";
};
});
//# sourceMappingURL=talkDuration.js.map
/***/ }),
/***/ 153:
/***/ (function(module, exports) {
angular.module('app').directive('zoomIn', function () {
return {
restrict: 'A',
link: function (scope, el, attrs) {
el.on('mouseenter', function () {
el[0].style.transform = "scale(1.1,1.1)";
});
el.on('mouseleave', function () {
el[0].style.transform = "scale(1,1)";
});
}
};
});
//# sourceMappingURL=zoomIn.js.map
/***/ }),
/***/ 154:
/***/ (function(module, exports) {
angular.module('app').component('createNewSession', {
templateUrl: './createNewSession.html',
bindings: {
userSessions: '='
},
controller: function (toastr, currentIdentity, sessions) {
this.create = function () {
var newUserSession = {
title: this.title,
length: parseInt(this.length),
abstract: this.abstract,
userFirstName: currentIdentity.currentUser.firstName,
userLastName: currentIdentity.currentUser.lastName,
userId: currentIdentity.currentUser.id,
};
sessions.createNewSession(newUserSession).then(function (response) {
this.userSessions.push(response);
}.bind(this));
};
}
});
//# sourceMappingURL=createNewSession.js.map
/***/ }),
/***/ 155:
/***/ (function(module, exports) {
angular.module('app').component('home', {
templateUrl: './home.html',
bindings: {
userSessions: '='
},
controller: function (currentIdentity, sessions, toastr, unreviewedSessionCount) {
this.currentUser = currentIdentity.currentUser;
this.setNextSessionToReview = function () {
var _this = this;
sessions.getNextUnreviewedSession(currentIdentity.currentUser.id).then(function (response) {
_this.currentSessionToReview = response;
});
};
this.setNextSessionToReview();
this.voteYes = function () {
var _this = this;
sessions.incrementVote(this.currentSessionToReview.id)
.then(function () { return sessions.addReviewedSession(_this.currentUser.id, _this.currentSessionToReview.id); })
.then(function () {
this.setNextSessionToReview();
// pull updated value
unreviewedSessionCount.updateUnreviewedSessionCount();
}.bind(this));
};
this.voteNo = function () {
sessions.addReviewedSession(this.currentUser.id, this.currentSessionToReview.id)
.then(function () {
this.setNextSessionToReview();
// pull updated value
unreviewedSessionCount.updateUnreviewedSessionCount();
}.bind(this));
};
}
});
//# sourceMappingURL=home.js.map
/***/ }),
/***/ 156:
/***/ (function(module, exports) {
angular.module('app').component('nav', {
templateUrl: './nav.html',
bindings: {},
controller: function (currentIdentity, sessions, unreviewedSessionCount) {
this.currentUser = currentIdentity.currentUser;
unreviewedSessionCount.updateUnreviewedSessionCount();
this.unreviewedSessionCount = unreviewedSessionCount;
}
});
//# sourceMappingURL=nav.js.map
/***/ }),
/***/ 157:
/***/ (function(module, exports) {
angular.module('app').service('auth', (function () {
function Auth($q, $http, currentIdentity) {
this.$q = $q;
this.$http = $http;
this.currentIdentity = currentIdentity;
}
Auth.prototype.login = function (credentials) {
var _this = this;
var dfd = this.$q.defer();
this.$http.post('/api/login', credentials).then(function (response) {
_this.currentIdentity.setUser(response.data.user);
dfd.resolve();
}, function (response) {
dfd.reject("Invalid Credentials");
});
return dfd.promise;
};
Auth.prototype.logout = function () {
var _this = this;
var dfd = this.$q.defer();
this.$http.post('/api/logout').then(function (response) {
_this.currentIdentity.clearUser();
dfd.resolve();
}, function (response) {
dfd.reject("Error Logging Out");
});
return dfd.promise;
};
Auth.prototype.waitForAuth = function () {
var _this = this;
var dfd = this.$q.defer();
this.$http.get('/api/currentIdentity').then(function (response) {
if (!!response.data) {
_this.currentIdentity.setUser(response.data);
}
dfd.resolve(_this.currentIdentity);
});
return dfd.promise;
};
Auth.prototype.requireLogin = function () {
var _this = this;
return this.waitForAuth().then(function () {
if (_this.currentIdentity.authenticated()) {
return true;
}
else {
return _this.$q.reject('AUTH_REQUIRED');
}
});
};
Auth.prototype.requireAdmin = function () {
var _this = this;
return this.waitForAuth().then(function () {
if (_this.currentIdentity.authenticated() && _this.currentIdentity.currentUser.isAdmin) {
return true;
}
else {
return _this.$q.reject('AUTH_REQUIRED');
}
});
};
return Auth;
}()));
//# sourceMappingURL=auth.js.map
/***/ }),
/***/ 158:
/***/ (function(module, exports) {
angular.module('app').service('currentIdentity', (function () {
function CurrentIdentity($http, $q) {
this.$http = $http;
this.$q = $q;
this.currentUser = null;
}
CurrentIdentity.prototype.setUser = function (user) {
this.currentUser = user;
};
CurrentIdentity.prototype.clearUser = function () {
this.currentUser = null;
};
CurrentIdentity.prototype.authenticated = function () {
return !!this.currentUser;
};
CurrentIdentity.prototype.updateUser = function (newUserObj) {
var _this = this;
var dfd = this.$q.defer();
this.$http.put('/api/users/' + this.currentUser.id, newUserObj).then(function (response) {
_this.currentUser.firstName = newUserObj.firstName;
_this.currentUser.lastName = newUserObj.lastName;
dfd.resolve();
}, function (response) {
dfd.reject("Error Logging Out");
});
return dfd.promise;
};
return CurrentIdentity;
}()));
//# sourceMappingURL=currentIdentity.js.map
/***/ }),
/***/ 159:
/***/ (function(module, exports) {
angular.module('app').component('login', {
templateUrl: './login.html',
bindings: {},
controller: (function () {
function LoginCtrl($location, currentIdentity, auth, toastr) {
this.$location = $location;
this.auth = auth;
this.toastr = toastr;
if (currentIdentity.authenticated()) {
$location.path('/home');
}
}
LoginCtrl.prototype.login = function () {
var _this = this;
this.auth.login({
username: this.email,
password: "pass"
}).then(function () {
_this.$location.path('/home');
}, function (err) {
_this.toastr.error(err);
});
};
return LoginCtrl;
}())
});
//# sourceMappingURL=login.js.map
/***/ }),
/***/ 160:
/***/ (function(module, exports) {
angular.module('app').component('logout', {
controller: function ($location, auth) {
auth.logout();
$location.path('/login');
}
});
//# sourceMappingURL=logout.js.map
/***/ }),
/***/ 161:
/***/ (function(module, exports) {
angular.module('app').service('users', (function () {
function Users($http, $q) {
this.$http = $http;
this.$q = $q;
}
Users.prototype.createNewUser = function (newUser) {
return this.$http.post('/api/users', newUser);
};
Users.prototype.getAllUsers = function () {
var dfd = this.$q.defer();
this.$http.get('/api/users').then(function (response) {
dfd.resolve(response.data);
});
return dfd.promise;
};
return Users;
}()));
//# sourceMappingURL=users.js.map
/***/ }),
/***/ 162:
/***/ (function(module, exports) {
angular.module('app').component('sessionDetail', {
templateUrl: './sessionDetail.html',
bindings: {
session: '=',
initialCollapsed: '<'
},
controller: function () {
}
});
//# sourceMappingURL=sessionDetail.js.map
/***/ }),
/***/ 163:
/***/ (function(module, exports) {
angular.module('app').component('sessionDetailWithVotes', {
templateUrl: './sessionDetailWithVotes.html',
bindings: {
session: '=',
initialCollapsed: '<'
},
controller: function () {
}
});
//# sourceMappingURL=sessionDetailWithVotes.js.map
/***/ }),
/***/ 164:
/***/ (function(module, exports) {
angular.module('app').service('unreviewedSessionCount', (function () {
function UnreviewedSessionCount(sessions, currentIdentity) {
this.value = 0;
this.sessions = sessions;
this.currentIdentity = currentIdentity;
}
UnreviewedSessionCount.prototype.updateUnreviewedSessionCount = function () {
var _this = this;
this.sessions.getUnreviewedCount(this.currentIdentity.currentUser.id)
.then(function (response) {
_this.value = response.count;
});
};
return UnreviewedSessionCount;
}()));
//# sourceMappingURL=unreviewedSessionCount.js.map
/***/ }),
/***/ 165:
/***/ (function(module, exports) {
(function () {
var toastrModule = angular.module('toastr', []);
toastr.options.timeOut = 1000;
toastrModule.value('toastr', toastr);
}());
//# sourceMappingURL=toastr.js.map
/***/ }),
/***/ 473:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// import './vendor/jquery.min.js';
// import './vendor/1.5.5/angular.min.js';
// import './vendor/1.5.5/angular-route.min.js';
// import './vendor/toastr.min.js';
__webpack_require__(165);
__webpack_require__(142);
__webpack_require__(143);
__webpack_require__(148);
__webpack_require__(150);
__webpack_require__(149);
__webpack_require__(151);
__webpack_require__(141);
__webpack_require__(156);
__webpack_require__(160);
__webpack_require__(159);
__webpack_require__(157);
__webpack_require__(158);
__webpack_require__(161);
__webpack_require__(155);
__webpack_require__(154);
__webpack_require__(164);
__webpack_require__(162);
__webpack_require__(163);
__webpack_require__(152);
__webpack_require__(153);
//# sourceMappingURL=index.js.map
/***/ })
/******/ });
so the problem is that my angular 1 code is being run through the @ngtools/webpack loader which doesn't really process it right.
When I'm not using the AOT, then I use the awesome-typescript-loader and then the angular2-template-loader.
This works for both antular 1 and angular 2, and replaces templateUrl with a require statement that has the inlined template
But when using the AOT, of course the angular 2 code has to go through the aot loader, but the angular 1 code isn't handled right if it does. it just leaves the code unmodified.
check out line 610 in the ng1.bundle.js file.
I tried copying in the results of the dev build ng1 file to see if that was jsut a drop in replacement,
and then I can just use the dev loaders for the ng1 code, but when I do that I get the error "Angular requires zone.js polyfill"
but zone is definitely there. it's in the polyfills file.
Not sure how to handle this properly.
const path = require('path');
const webpack = require('webpack');
const helpers = require('./helpers');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const AotPlugin = require('@ngtools/webpack').AotPlugin;
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
module.exports = {
entry: {
'polyfills': './public/polyfills.ts',
'vendor': './public/vendor-aot.ts',
'app': './public/main-aot.ts',
'ng1': './public/index.ts'
},
output: {
path: helpers.root('dist/aot'),
publicPath: '/',
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js'
},
resolve: {
extensions: ['.js', '.ts']
},
module: {
loaders: [
{
test: /\.ts$/,
loader: '@ngtools/webpack'
},
{
test: /\.html$/,
loader: 'html-loader'
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills', 'ng1']
}),
new AotPlugin({
tsConfigPath: './tsconfig.aot.json',
entryModule: helpers.root('public/app/app.module#AppModule')
}),
new HtmlWebpackPlugin({
template: 'public/index.html'
}),
// new webpack.optimize.UglifyJsPlugin({
// beautify: false,
// comments: false,
// compress: {
// screw_ie8: true,
// warnings: false
// },
// mangle: {
// keep_fnames: true,
// screw_i8: true
// }
// }),
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment