Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addon/ng2/blueprints/ng2/files/__path__/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"mapRoot": "/",
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
Expand Down
10 changes: 2 additions & 8 deletions lib/broccoli/angular-broccoli-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,8 @@ class BundlePlugin extends Plugin {
build() {
var relativeRoot = path.relative(process.cwd(), this.inputPaths[0]);
var builder = new Builder(relativeRoot, `${relativeRoot}/system-config.js`);
return builder.bundle('main - [app/**/*]',
`${this.outputPath}/main.js`, {
minify: true
})
.then(() => builder.bundle('app - (app/**/*.js - [app/**/*.js])',
`${this.outputPath}/app/index.js`, {
minify: true
}))

return builder.bundle('main', `${this.outputPath}/main.js`, { minify: true })
.then(() => fse.copySync(`${this.inputPaths[0]}/system-config.js`,
`${this.outputPath}/system-config.js`));
}
Expand Down
32 changes: 26 additions & 6 deletions lib/broccoli/broccoli-typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class BroccoliTypeScriptCompiler extends Plugin {

_outputFile(absoluteFilePath, fileContent, registry) {
absoluteFilePath = path.resolve(this.cachePath, absoluteFilePath);
let inputFilePath = absoluteFilePath;
// Replace the input path by the output.
absoluteFilePath = absoluteFilePath.replace(this.inputPaths[0], this.cachePath);
const outputFilePath = absoluteFilePath.replace(this.cachePath, this.outputPath);
Expand All @@ -204,7 +205,7 @@ class BroccoliTypeScriptCompiler extends Plugin {
}

fse.mkdirsSync(path.dirname(absoluteFilePath));
const content = this.fixSourceMapSources(fileContent);
const content = this.fixSourceMapSources(fileContent, inputFilePath);
fs.writeFileSync(absoluteFilePath, content, FS_OPTS);

fse.mkdirsSync(path.dirname(outputFilePath));
Expand Down Expand Up @@ -242,12 +243,31 @@ class BroccoliTypeScriptCompiler extends Plugin {
* This issue is fixed in https://github.com/Microsoft/TypeScript/pull/5620.
* Once we switch to TypeScript 1.8, we can remove this method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm is this comment still accurate? We are on TS 1.8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need to fix sources. I need to spend much more time refactoring this plugin and the rest.

*/
fixSourceMapSources(content) {
fixSourceMapSources(content, inputFilePath) {
try {
var marker = '//# sourceMappingURL=data:application/json;base64,';
var index = content.indexOf(marker);
if (index == -1)
return content;
const marker = '//# sourceMappingURL=data:application/json;base64,';

let index = content.indexOf(marker);
if (index == -1) {
const pathMarker = '//# sourceMappingURL=';
index = content.indexOf(pathMarker);
if (index == -1) {
return content;
}

// We have a regular path, make it relative to the input path.
let base = content.substring(0, index + pathMarker.length);
let mapPath = content.substring(index + pathMarker.length);
if (mapPath.startsWith(this.outputPath)) {
mapPath = mapPath.replace(this.outputPath, this.inputPaths[0]);
} else if (!mapPath.startsWith(this.inputPaths[0])) {
mapPath = path.join(this.inputPaths[0], path.dirname(this._tsConfigPath), mapPath);
}

mapPath = path.relative(path.dirname(inputFilePath), mapPath);
return '' + base + mapPath;
}

var base = content.substring(0, index + marker.length);
var sourceMapBit = new Buffer(content.substring(index + marker.length), 'base64').toString('utf8');
var sourceMaps = JSON.parse(sourceMapBit);
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/e2e_workflow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ describe('Basic end-to-end Workflow', function () {
// stuck to the first build done
sh.exec(`${ngBin} build -prod`);
expect(existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
var appBundlePath = path.join(process.cwd(), 'dist', 'app', 'index.js');
var appBundleContent = fs.readFileSync(appBundlePath, { encoding: 'utf8' });
var mainBundlePath = path.join(process.cwd(), 'dist', 'main.js');
var mainBundleContent = fs.readFileSync(mainBundlePath, { encoding: 'utf8' });
// production: true minimized turns into production:!0
expect(appBundleContent).to.include('production:!0');
expect(mainBundleContent).to.include('production:!0');
// Also does not create new things in GIT.
expect(sh.exec('git status --porcelain').output).to.be.equal(undefined);
});
Expand Down Expand Up @@ -415,7 +415,7 @@ describe('Basic end-to-end Workflow', function () {
expect('build failed where it should have succeeded').to.equal('');
});
});

it('Serve and run e2e tests after all other commands', function () {
this.timeout(240000);

Expand Down