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 { Promise } from 'sander';
import MagicString from 'magic-string'; import MagicString from 'magic-string';
import { blank, keys } from './utils/object'; import { blank, keys } from './utils/object';
@ -486,18 +486,14 @@ export default class Bundle {
let map = null; let map = null;
if ( options.sourceMap ) { if ( options.sourceMap ) {
const file = options.sourceMapFile || options.dest;
map = magicString.generateMap({ map = magicString.generateMap({
includeContent: true, includeContent: true,
file: options.sourceMapFile || options.dest file
// TODO // TODO
}); });
// make sources relative. TODO fix this upstream? map.sources = map.sources.map( unixizePath );
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;
});
} }
return { code, map }; return { code, map };

4
src/utils/path.js

@ -23,8 +23,8 @@ export function extname ( path ) {
} }
export function relative ( from, to ) { export function relative ( from, to ) {
const fromParts = from.split( /[\/\\]/ ); const fromParts = from.split( /[\/\\]/ ).filter( Boolean );
const toParts = to.split( /[\/\\]/ ); const toParts = to.split( /[\/\\]/ ).filter( Boolean );
while ( fromParts[0] && toParts[0] && fromParts[0] === toParts[0] ) { while ( fromParts[0] && toParts[0] && fromParts[0] === toParts[0] ) {
fromParts.shift(); fromParts.shift();

Loading…
Cancel
Save