Skip to content
This repository has been archived by the owner on May 1, 2020. It is now read-only.

Commit

Permalink
feat(sourcemaps): copy for prod and dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed Aug 15, 2017
1 parent ee3e41b commit a1ccc17
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/util/source-maps.ts
Expand Up @@ -4,11 +4,7 @@ import * as Constants from './constants';
import { copyFileAsync, getBooleanPropertyValue, readDirAsync, unlinkAsync } from './helpers';
import { BuildContext } from './interfaces';

export function purgeSourceMapsIfNeeded(context: BuildContext): Promise<any> {
if (getBooleanPropertyValue(Constants.ENV_VAR_GENERATE_SOURCE_MAP)) {
// keep the source maps and just return
return Promise.resolve([]);
}
function copySourcemaps(context: BuildContext, shouldPurge: boolean) {
return readDirAsync(context.buildDir).then((fileNames) => {
const sourceMaps = fileNames.filter(fileName => fileName.endsWith('.map'));
const fullPaths = sourceMaps.map(sourceMap => join(context.buildDir, sourceMap));
Expand All @@ -18,14 +14,25 @@ export function purgeSourceMapsIfNeeded(context: BuildContext): Promise<any> {
if (copyBeforePurge) {
mkdirpSync(context.sourcemapDir)
const relativeTo = relative(fullPath, context.sourcemapDir)
const fileName = basename(fullPath)
promises.push(copyFileAsync(fullPath, join(context.sourcemapDir, fileName)).then(() => {
return unlinkAsync(fullPath)
}))
} else {
const fileName = basename(fullPath);
if (fileName.indexOf('vendor.js') < 0) {

This comment has been minimized.

Copy link
@Nilos

Nilos Nov 24, 2017

Contributor

But why? Why not copy the vendor.js sourcemap?

This comment has been minimized.

Copy link
@ippeiukai

ippeiukai Feb 2, 2018

It is annoying to find stacktraces with 'vendor.js' lines in Ionic Pro error mails. (which library is throwing the error?)
Maybe this is the cause?

This comment has been minimized.

Copy link
@Nilos

Nilos Feb 2, 2018

Contributor

Likely

promises.push(copyFileAsync(fullPath, join(context.sourcemapDir, fileName)));
}
}

if (shouldPurge) {
promises.push(unlinkAsync(fullPath))
}
}
return Promise.all(promises);
});
}

export function purgeSourceMapsIfNeeded(context: BuildContext): Promise<any> {
if (getBooleanPropertyValue(Constants.ENV_VAR_GENERATE_SOURCE_MAP)) {
// keep the source maps and just return
return copySourcemaps(context, false);
}

return copySourcemaps(context, true);
}

0 comments on commit a1ccc17

Please sign in to comment.