From bac6e9427fe3204196e4f1cb4f8d3ea0aeea551c Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 14 Jul 2015 10:40:09 -0400 Subject: [PATCH] path fixes --- src/Bundle.js | 12 ++++-------- src/utils/path.js | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Bundle.js b/src/Bundle.js index efcd1c9..c5f66f2 100644 --- a/src/Bundle.js +++ b/src/Bundle.js @@ -1,4 +1,4 @@ -import { basename, dirname, extname, relative } from './utils/path'; +import { basename, extname } from './utils/path'; import { Promise } from 'sander'; import MagicString from 'magic-string'; import { blank, keys } from './utils/object'; @@ -486,18 +486,14 @@ export default class Bundle { let map = null; if ( options.sourceMap ) { + const file = options.sourceMapFile || options.dest; map = magicString.generateMap({ includeContent: true, - file: options.sourceMapFile || options.dest + file // TODO }); - // make sources relative. TODO fix this upstream? - const dir = dirname( map.file ); - map.sources = map.sources.map( source => { - // TODO is unixizePath still necessary, given internal helper rather than node builtin? - return source ? unixizePath( relative( dir, source ) ) : null; - }); + map.sources = map.sources.map( unixizePath ); } return { code, map }; diff --git a/src/utils/path.js b/src/utils/path.js index 32df39c..d726b21 100644 --- a/src/utils/path.js +++ b/src/utils/path.js @@ -23,8 +23,8 @@ export function extname ( path ) { } export function relative ( from, to ) { - const fromParts = from.split( /[\/\\]/ ); - const toParts = to.split( /[\/\\]/ ); + const fromParts = from.split( /[\/\\]/ ).filter( Boolean ); + const toParts = to.split( /[\/\\]/ ).filter( Boolean ); while ( fromParts[0] && toParts[0] && fromParts[0] === toParts[0] ) { fromParts.shift();