Webpack appears to be outputting the const keyword instead of the var keyword which is breaking PhantomJS (as it doesn't support ES6 syntax).
...
/* 2 */
/***/ function(module, exports, __webpack_require__) {
"use strict";
const testing_1 = __webpack_require__(3); // const keyword breaking PhantomJS
testing_1.describe('App', () => {
So PhantomJS reports
PhantomJS 2.1.1 (Windows 8 0.0.0) ERROR
SyntaxError: Unexpected token 'const'
The file in question (karma-shim.js) is being processed by the karma-webpack preprocessor
karma-shim.js
'use strict';
Error.stackTraceLimit = Infinity;
require('es6-shim');
require('angular2/bundles/angular2-polyfills.js');
require('angular2/testing');
var appContext = require.context('./src', true, /root\.spec\.ts/);
appContext.keys().forEach(appContext);
var testing = require('angular2/testing');
var browser = require('angular2/platform/testing/browser');
testing.setBaseTestProviders(browser.TEST_BROWSER_PLATFORM_PROVIDERS, browser.TEST_BROWSER_APPLICATION_PROVIDERS);
karma.conf.js
...
preprocessors: {
'./karma-shim.js': ['webpack', 'sourcemap']
},
tsconfig.json
{
"compilerOptions": {
"target": "ES5",
"module": "commonjs",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"sourceMap": true,
"moduleResolution": "node",
"jsx": "react"
},
"exclude": [
"node_modules"
],
"compileOnSave": false,
"buildOnSave": false
}
webpack.config.js Is part of generator-ng2-webpack (https://github.com/cmelion/generator-ng2-webpack) but doesn't appear to mention transpilation.
Why would webpack be outputting const instead of var and is there anything I can do about it to help PhantomJS?