Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove custom namespaced sourceRoot in sourcemaps #1652

Merged
merged 1 commit into from May 28, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions integration/samples/core/specs/sourcemaps.ts
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
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
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