diff --git a/addon/ng2/blueprints/ng2/files/__path__/test.ts b/addon/ng2/blueprints/ng2/files/__path__/test.ts index 5255aeee5d09..e61005825b11 100644 --- a/addon/ng2/blueprints/ng2/files/__path__/test.ts +++ b/addon/ng2/blueprints/ng2/files/__path__/test.ts @@ -23,18 +23,14 @@ Promise.all([ let testing = providers[0]; let testingBrowser = providers[1]; - testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, - testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); + testing.setBaseTestProviders( + testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS + ); }); -let testContext = require.context('../src', true, /\.spec\.ts/); - -/* - * get all the files, for each file, call the context function - * that will require the file and load it up here. Context will - * loop and require those spec files here - */ -function requireAll(requireContext) { +let testContext: any = require.context('../src', true, /\.spec\.ts/); +function requireAll(requireContext: any) { return requireContext.keys().map(requireContext); } diff --git a/addon/ng2/blueprints/ng2/files/__path__/tsconfig.json b/addon/ng2/blueprints/ng2/files/__path__/tsconfig.json index 1c55b6264b90..e0831213e64c 100644 --- a/addon/ng2/blueprints/ng2/files/__path__/tsconfig.json +++ b/addon/ng2/blueprints/ng2/files/__path__/tsconfig.json @@ -10,15 +10,10 @@ "rootDir": ".", "sourceMap": true, "target": "es5", - "mapRoot": "/", - "inlinesource": true + "mapRoot": "/" }, "compileOnSave": false, "buildOnSave": false, - "exclude": [ - "node_modules", - "bower_components" - ], "includes": [ "**.d.ts" ] diff --git a/addon/ng2/models/webpack-build-common.ts b/addon/ng2/models/webpack-build-common.ts index 146671ed5501..c41045021b8f 100644 --- a/addon/ng2/models/webpack-build-common.ts +++ b/addon/ng2/models/webpack-build-common.ts @@ -1,5 +1,5 @@ import * as webpack from 'webpack'; -import {LoaderConfig} from '../utilities/ts-path-mappings-webpack-plugin'; +import {LoaderConfig, PathsPlugin} from '../utilities/ts-path-mappings-webpack-plugin'; const path = require('path'); const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin; @@ -18,7 +18,10 @@ export function getWebpackCommonConfig(projectRoot: string) { resolve: { extensions: ['', '.ts', '.js'], root: path.resolve(projectRoot, './src'), - moduleDirectories: ['node_modules'] + moduleDirectories: ['node_modules'], + plugins: [ + new PathsPlugin(awesomeTypescriptLoaderConfig); + ] }, context: path.resolve(__dirname, './'), entry: { diff --git a/addon/ng2/models/webpack-build-test.ts b/addon/ng2/models/webpack-build-test.ts index 6a1d15bf4410..455b5960c6c0 100644 --- a/addon/ng2/models/webpack-build-test.ts +++ b/addon/ng2/models/webpack-build-test.ts @@ -44,7 +44,6 @@ export const getWebpackTestConfig = function(projectRoot: string) { query: { useWebpackText: true, tsconfig: path.resolve(projectRoot, './src/tsconfig.json'), - // resolveGlobs: false, module: "commonjs", target: "es5", useForkChecker: true, @@ -67,7 +66,7 @@ export const getWebpackTestConfig = function(projectRoot: string) { ], postLoaders: [ { - test: /\.(js|ts)$/, loader: 'istanbul-instrumenter-loader', + test: /\.(js|ts)$/, loader: 'sourcemap-istanbul-instrumenter-loader', exclude: [ /\.(e2e|spec)\.ts$/, /node_modules/ diff --git a/addon/ng2/tasks/test.js b/addon/ng2/tasks/test.js index 5fbbcea453e5..dcf28c2f7e55 100644 --- a/addon/ng2/tasks/test.js +++ b/addon/ng2/tasks/test.js @@ -36,7 +36,7 @@ module.exports = Task.extend({ // Single test entry file. Will run the test.ts bundle and track it. options.files = [{ pattern: './src/test.ts', watched: false }]; - options.preprocessors = { './src/test.ts': ['coverage','webpack','sourcemap'] }; + options.preprocessors = { './src/test.ts': ['webpack','sourcemap'] }; options.webpack = webpackTestConfig(projectRoot); options.webpackMiddleware = { noInfo: true, // Hide webpack output because its noisy. diff --git a/addon/ng2/utilities/ts-path-mappings-webpack-plugin.ts b/addon/ng2/utilities/ts-path-mappings-webpack-plugin.ts index 13bdeb057703..6c35b7fd3183 100644 --- a/addon/ng2/utilities/ts-path-mappings-webpack-plugin.ts +++ b/addon/ng2/utilities/ts-path-mappings-webpack-plugin.ts @@ -183,9 +183,6 @@ export class PathsPlugin implements ResolverPlugin { this.baseUrl ); - console.log("CONFIG FILE AND BASE URL"); - console.log(this.configFilePath, this.absoluteBaseUrl); - this.mappings = []; let paths = this.options.paths || {}; Object.keys(paths).forEach(alias => { diff --git a/package.json b/package.json index 9894e868d372..a93ccae5ae3d 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "shelljs": "^0.7.0", "silent-error": "^1.0.0", "source-map-loader": "^0.1.5", + "sourcemap-istanbul-instrumenter-loader": "^0.2.0", "style-loader": "^0.13.1", "stylus": "^0.54.5", "stylus-loader": "^2.1.0", @@ -97,7 +98,7 @@ "typescript": "^2.0.0", "typings": "^0.8.1", "url-loader": "^0.5.7", - "webpack": "2.1.0-beta.17", + "webpack": "2.1.0-beta.18", "webpack-dev-server": "2.1.0-beta.0", "webpack-md5-hash": "0.0.5", "webpack-merge": "^0.14.0" diff --git a/tests/e2e/e2e_workflow.spec.js b/tests/e2e/e2e_workflow.spec.js index 17679fc63532..3864e7fc9c89 100644 --- a/tests/e2e/e2e_workflow.spec.js +++ b/tests/e2e/e2e_workflow.spec.js @@ -43,7 +43,7 @@ describe('Basic end-to-end Workflow', function () { this.timeout(300000); sh.exec('npm link', { silent: true }); - + return tmp.setup('./tmp').then(function () { process.chdir('./tmp'); expect(existsSync(path.join(process.cwd(), 'bin', 'ng'))); @@ -446,7 +446,7 @@ describe('Basic end-to-end Workflow', function () { }); }); - xit('Turn on path mapping in tsconfig.json and rebuild', function () { + it('Turn on path mapping in tsconfig.json and rebuild', function () { this.timeout(420000); const configFilePath = path.join(process.cwd(), 'src', 'tsconfig.json'); @@ -454,28 +454,29 @@ describe('Basic end-to-end Workflow', function () { config.compilerOptions.baseUrl = ''; - // This should fail. + // #TODO: When https://github.com/Microsoft/TypeScript/issues/9772 is fixed this should fail. config.compilerOptions.paths = { '@angular/*': [] }; fs.writeFileSync(configFilePath, JSON.stringify(config, null, 2), 'utf8'); - return ng(['build']) - .catch(() => { - return true; - }) - .then((passed) => { - expect(passed).to.equal(true); - }) - .then(() => { - // This should succeed. - config.compilerOptions.paths = { - '@angular/*': [ '*' ] - }; - fs.writeFileSync(configFilePath, JSON.stringify(config, null, 2), 'utf8'); - }) - .then(() => ng(['build'])) - .catch(() => { - expect('build failed where it should have succeeded').to.equal(''); - }); + sh.exec(`${ngBin} build`); + // #TODO: Uncomment these lines when https://github.com/Microsoft/TypeScript/issues/9772 is fixed. + // .catch(() => { + // return true; + // }) + // .then((passed) => { + // expect(passed).to.equal(true); + // }) + + // This should succeed. + config.compilerOptions.paths = { + '@angular/*': [ '../node_modules/@angular/*' ] + }; + fs.writeFileSync(configFilePath, JSON.stringify(config, null, 2), 'utf8'); + sh.exec(`${ngBin} build`); + + expect(existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true); + const indexHtml = fs.readFileSync(path.join(process.cwd(), 'dist/index.html'), 'utf-8'); + expect(indexHtml).to.include('main.bundle.js'); }); it('Serve and run e2e tests after all other commands', function () {