Skip to content

Commit e9ad100

Browse files
committed
fix(build): switch to cjs output for es5.
System output does not work at the current versions of TS and system.js. Will revisit after upgrading TS. Removes unused traceur tooling. Closes angular#3974
1 parent b025f94 commit e9ad100

39 files changed

+25
-1243
lines changed

docs/docs-package/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require('../../tools/transpiler/index.js').init();
2-
31
var Package = require('dgeni').Package;
42
var jsdocPackage = require('dgeni-packages/jsdoc');
53
var nunjucksPackage = require('dgeni-packages/nunjucks');

docs/typescript-package/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
require('../../tools/transpiler/index.js').init();
2-
31
var basePackage = require('dgeni-packages/base');
42
var Package = require('dgeni').Package;
53
var path = require('canonical-path');

gulpfile.js

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ var licenseWrap = require('./tools/build/licensewrap');
2020

2121
var watch = require('./tools/build/watch');
2222

23-
var transpile = require('./tools/build/transpile');
2423
var pubget = require('./tools/build/pubget');
2524
var linknodemodules = require('./tools/build/linknodemodules');
2625
var pubbuild = require('./tools/build/pubbuild');

karma-js.conf.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ module.exports = function(config) {
2525
'node_modules/reflect-metadata/Reflect.js',
2626
'tools/build/file2modulename.js',
2727
'test-main.js',
28-
{pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false}
28+
{pattern: 'modules/**/test/**/static_assets/**', included: false, watched: false}
2929
],
3030

3131
exclude: [
3232
'dist/js/dev/es5/**/e2e_test/**',
33+
'dist/js/dev/es5/rtts_assert/**',
3334
'dist/angular1_router.js'
3435
],
3536

@@ -40,11 +41,11 @@ module.exports = function(config) {
4041
startConnect: false,
4142
recordVideo: false,
4243
recordScreenshots: false,
43-
options: {
44-
'selenium-version': '2.45.0',
45-
'command-timeout': 600,
46-
'idle-timeout': 600,
47-
'max-duration': 5400
44+
options: {
45+
'selenium-version': '2.45.0',
46+
'command-timeout': 600,
47+
'idle-timeout': 600,
48+
'max-duration': 5400
4849
}
4950
},
5051

@@ -62,5 +63,3 @@ module.exports = function(config) {
6263
config.transports = ['xhr-polling'];
6364
}
6465
};
65-
66-

modules/angular2/test/compiler/eval_module.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ export function evalModule(moduleSource: string, moduleImports: string[][], args
1616
var modName = sourceImport[0];
1717
var modAlias = sourceImport[1];
1818
importModuleNames.push(modName);
19-
moduleSourceWithImports.push(`var ${modAlias} = require('${modName}');`);
19+
// Note: After transpilation to commonJS and loading this file in a browser
20+
// using SystemJS, the loader might get confused by the presence of require,
21+
// and attempt to load "+ modName +.js" !?!
22+
// A simple string concat manages to prevent that, but that is one compiler
23+
// optimaztion away from breaking again. Proceed with caution!
24+
moduleSourceWithImports.push(`var ${modAlias} = require` + `('${modName}');`);
2025
});
2126
moduleSourceWithImports.push(moduleSource);
2227

modules/angular2_material/src/components/input/input.ts

-23
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,3 @@ export class MdInput {
9393
ObservableWrapper.callNext(this.mdFocusChange, hasFocus);
9494
}
9595
}
96-
97-
/*
98-
@Directive({
99-
selector: 'md-input-container textarea',
100-
events: ['mdChange', 'mdFocusChange'],
101-
hostProperties: {
102-
'yes': 'class.md-input'
103-
},
104-
hostListeners: {
105-
'input': 'updateValue($event)',
106-
'focus': 'setHasFocus(true)',
107-
'blur': 'setHasFocus(false)'
108-
}
109-
})
110-
export class MdTextarea extends MdInput {
111-
constructor(
112-
@Attribute('value') value: string,
113-
@SkipSelf() @Host() container: MdInputContainer,
114-
@Attribute('id') id: string) {
115-
super(value, container, id);
116-
}
117-
}
118-
*/

modules/benchmarks_external/src/tree/react/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// tree benchmark in React
22
import {getIntParameter, bindAction} from 'angular2/src/test_lib/benchmark_util';
3-
import React from './react.min';
3+
import * as React from './react.min';
44

55
var TreeComponent = React.createClass({
66
displayName: 'TreeComponent',
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
declare var React: any;
2-
export default React;
1+
export var createElement: Function;
2+
export var render: Function;

modules/examples/e2e_test/sourcemap/sourcemap_spec.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,10 @@ describe('sourcemaps', function() {
3434

3535
var originalPosition = decoder.originalPositionFor({line: errorLine, column: errorColumn});
3636

37-
var finalMapData = fs.readFileSync('dist/js/prod/es6/examples/src/sourcemap/index.js.map');
38-
var finalDecoder = new sourceMap.SourceMapConsumer(JSON.parse(finalMapData));
39-
40-
var finalPosition = finalDecoder.originalPositionFor(originalPosition);
41-
4237
var sourceCodeLines =
4338
fs.readFileSync('modules/examples/src/sourcemap/index.ts', {encoding: 'UTF-8'})
4439
.split('\n');
45-
expect(sourceCodeLines[finalPosition.line - 1])
40+
expect(sourceCodeLines[originalPosition.line - 1])
4641
.toMatch(/throw new BaseException\(\'Sourcemap test\'\)/);
4742
});
4843
});

tools/broccoli/traceur/index.ts

-56
This file was deleted.

tools/broccoli/trees/browser_tree.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
var Funnel = require('broccoli-funnel');
44
var htmlReplace = require('../html-replace');
5-
var jsReplace = require("../js-replace");
5+
var jsReplace = require('../js-replace');
66
var path = require('path');
77
var stew = require('broccoli-stew');
8+
var traceur = require('traceur');
89

910
import compileWithTypescript from '../broccoli-typescript';
1011
import destCopy from '../broccoli-dest-copy';
1112
import flatten from '../broccoli-flatten';
1213
import mergeTrees from '../broccoli-merge-trees';
1314
import replace from '../broccoli-replace';
14-
import {default as transpileWithTraceur, TRACEUR_RUNTIME_PATH} from '../traceur/index';
1515

1616

1717
var projectRootDir = path.normalize(path.join(__dirname, '..', '..', '..', '..'));
@@ -83,13 +83,10 @@ module.exports = function makeBrowserTree(options, destinationPath) {
8383
],
8484
destDir: '/'
8585
});
86-
86+
8787
var es5ModulesTree = new Funnel('modules', {
8888
include: ['**/**'],
89-
exclude: [
90-
'**/*.cjs',
91-
'benchmarks/e2e_test/**'
92-
],
89+
exclude: ['**/*.cjs', 'angular1_router/**', 'benchmarks/e2e_test/**'],
9390
destDir: '/'
9491
});
9592

@@ -117,23 +114,23 @@ module.exports = function makeBrowserTree(options, destinationPath) {
117114
sourceRoot: '.',
118115
target: 'ES6'
119116
});
120-
117+
121118
// Use TypeScript to transpile the *.ts files to ES5
122119
var es5Tree = compileWithTypescript(es5ModulesTree, {
123120
allowNonTsExtensions: false,
124121
declaration: false,
125122
emitDecoratorMetadata: true,
126123
experimentalDecorators: true,
127124
mapRoot: '', // force sourcemaps to use relative path
128-
module: 'System',
125+
module: 'CommonJS',
129126
noEmitOnError: false,
130127
rootDir: '.',
131128
sourceMap: true,
132129
sourceRoot: '.',
133130
target: 'ES5'
134131
});
135132

136-
// Now we add a few more files to the es6 tree that Traceur should not see
133+
// Now we add a few more files to the es6 tree that the es5 tree should not see
137134
['angular2', 'rtts_assert'].forEach(function(destDir) {
138135
var extras = new Funnel('tools/build', {files: ['es5build.js'], destDir: destDir});
139136
es6Tree = mergeTrees([es6Tree, extras]);
@@ -147,7 +144,7 @@ module.exports = function makeBrowserTree(options, destinationPath) {
147144
'node_modules/rx/dist/rx.js',
148145
'node_modules/base64-js/lib/b64.js',
149146
'node_modules/reflect-metadata/Reflect.js',
150-
path.relative(projectRootDir, TRACEUR_RUNTIME_PATH)
147+
path.relative(projectRootDir, traceur.RUNTIME_PATH)
151148
]
152149
}));
153150

tools/build/transpile.js

-16
This file was deleted.

tools/transpiler/gulp-traceur.js

-62
This file was deleted.

0 commit comments

Comments
 (0)