Skip to content

Commit

Permalink
fix: remove custom namespaced sourceRoot in sourcemaps
Browse files Browse the repository at this point in the history
Closes #1622
  • Loading branch information
alan-agius4 committed May 28, 2020
1 parent b2ac9a2 commit 481dd8f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 35 deletions.
14 changes: 0 additions & 14 deletions integration/samples/core/specs/sourcemaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ describe(`@sample/core`, () => {
expect(sourceMap.sourcesContent).to.be.an('array').that.is.not.empty;
expect(sourceMap.sources).to.have.lengthOf(sourceMap.sourcesContent.length);
});

it(`should reference each 'sources' path with a common prefix`, () => {
const everyUeveryMe = (sourceMap.sources as string[]).every(
(fileName) => fileName.startsWith('ng://@sample/core') && fileName.endsWith('.ts'),
);
expect(everyUeveryMe).to.be.true;
});
});

describe(`bundles/sample-core.umd.min.js.map`, () => {
Expand All @@ -46,12 +39,5 @@ describe(`@sample/core`, () => {
expect(sourceMap.sourcesContent).to.be.an('array').that.is.not.empty;
expect(sourceMap.sources).to.have.lengthOf(sourceMap.sourcesContent.length);
});

it(`should reference each 'sources' path with a common prefix`, () => {
const sourceMapPaths = (sourceMap.sources as string[])
.filter((fileName) => fileName !== 'null' && !fileName.includes('node_modules'))
.every((fileName) => fileName.startsWith('ng://@sample/core') && fileName.endsWith('.ts'));
expect(sourceMapPaths).to.be.true;
});
});
});
19 changes: 0 additions & 19 deletions src/lib/flatten/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as log from '../utils/log';
import { ExternalModuleIdStrategy, DependencyList } from './external-module-id-strategy';
import { umdModuleIdStrategy } from './umd-module-id-strategy';
import { TransformHook } from 'rollup';
import { ensureUnixPath } from '../utils/path';

/**
* Options used in `ng-packagr` for writing flat bundle files.
Expand Down Expand Up @@ -75,23 +74,5 @@ export async function rollupBundleFile(opts: RollupOptions): Promise<void> {
banner: '',
globals: moduleId => umdModuleIdStrategy(moduleId, opts.umdModuleIds || {}),
sourcemap: true,
sourcemapPathTransform: (sourcePath: string) => {
sourcePath = ensureUnixPath(sourcePath);
// relocate sourcemaps
if (!sourcePath) {
return sourcePath;
}

// the replace here is because during the compilation one of the `/` gets lost sometimes
const sourceRoot = ensureUnixPath(opts.sourceRoot);
const mapRootUrl = sourceRoot.replace('//', '/');
if (sourcePath.indexOf(mapRootUrl) >= 0) {
return `${sourceRoot}${sourcePath.substr(sourcePath.indexOf(mapRootUrl) + mapRootUrl.length)}`;
} else if (sourcePath.indexOf(sourceRoot) >= 0) {
return sourcePath.substr(sourcePath.indexOf(mapRootUrl));
} else {
return sourcePath;
}
},
});
}
3 changes: 1 addition & 2 deletions src/lib/ts/tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const initializeTsConfig = (defaultTsConfig: ng.ParsedConfiguration, entr
throw ng.formatDiagnostics(defaultTsConfig.errors);
}

entryPoints.forEach((currentEntryPoint) => {
entryPoints.forEach(currentEntryPoint => {
const { entryPoint } = currentEntryPoint.data;
log.debug(`Initializing tsconfig for ${entryPoint.moduleId}`);
const basePath = path.dirname(entryPoint.entryFilePath);
Expand All @@ -88,7 +88,6 @@ export const initializeTsConfig = (defaultTsConfig: ng.ParsedConfiguration, entr
basePath,
rootDir: basePath,
declarationDir: basePath,
sourceRoot: `ng://${entryPoint.moduleId}`,
};

tsConfig.rootNames = [entryPoint.entryFilePath];
Expand Down

0 comments on commit 481dd8f

Please sign in to comment.