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
15 changes: 9 additions & 6 deletions packages/webpack/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ function _replaceBootstrap(fileName: string,
}).then(() => sourceText);
}

function _transpile(plugin: AotPlugin, filePath: string, sourceText: string) {
function _transpile(plugin: AotPlugin, fileName: string, sourceText: string) {
const program = plugin.program;
if (plugin.typeCheck) {
const sourceFile = program.getSourceFile(filePath);
const sourceFile = program.getSourceFile(fileName);
const diagnostics = program.getSyntacticDiagnostics(sourceFile)
.concat(program.getSemanticDiagnostics(sourceFile))
.concat(program.getDeclarationDiagnostics(sourceFile));
Expand All @@ -127,11 +127,14 @@ function _transpile(plugin: AotPlugin, filePath: string, sourceText: string) {
}
}

const result = ts.transpileModule(sourceText, {
compilerOptions: plugin.compilerOptions,
fileName: filePath
// Force a few compiler options to make sure we get the result we want.
const compilerOptions: ts.CompilerOptions = Object.assign({}, plugin.compilerOptions, {
inlineSources: true,
inlineSourceMap: false,
sourceRoot: plugin.basePath
});

const result = ts.transpileModule(sourceText, { compilerOptions, fileName });
return {
outputText: result.outputText,
sourceMap: JSON.parse(result.sourceMapText)
Expand All @@ -151,7 +154,7 @@ export function ngcLoader(source: string) {
.then(() => _removeDecorators(this.resource, source))
.then(sourceText => _replaceBootstrap(this.resource, sourceText, plugin))
.then(sourceText => {
const result = _transpile(plugin, this.resource, sourceText);
const result = _transpile(plugin, this.resourcePath, sourceText);
cb(null, result.outputText, result.sourceMap);
})
.catch(err => cb(err));
Expand Down
1 change: 1 addition & 0 deletions packages/webpack/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class AotPlugin {

get basePath() { return this._basePath; }
get compilation() { return this._compilation; }
get compilerHost() { return this._compilerHost; }
get compilerOptions() { return this._compilerOptions; }
get done() { return this._donePromise; }
get entryModule() { return this._entryModule; }
Expand Down