Browse Source

path fixes

contingency-plan
Rich Harris 10 years ago
parent
commit
bac6e9427f
  1. 12
      src/Bundle.js
  2. 4
      src/utils/path.js

12
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 };

4
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();

Loading…
Cancel
Save