|
|
|
|
@ -343,19 +343,21 @@ export default class Component {
|
|
|
|
|
? { code: null, map: null }
|
|
|
|
|
: result.css;
|
|
|
|
|
|
|
|
|
|
const sourcemap_source_filename = get_sourcemap_source_filename(compile_options);
|
|
|
|
|
|
|
|
|
|
js = print(program, {
|
|
|
|
|
sourceMapSource: compile_options.filename
|
|
|
|
|
sourceMapSource: sourcemap_source_filename
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
js.map.sources = [
|
|
|
|
|
compile_options.filename ? get_relative_path(compile_options.outputFilename || '', compile_options.filename) : null
|
|
|
|
|
sourcemap_source_filename
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
js.map.sourcesContent = [
|
|
|
|
|
this.source
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
js.map = apply_preprocessor_sourcemap(this.file, js.map, compile_options.sourcemap as (string | RawSourceMap | DecodedSourceMap));
|
|
|
|
|
js.map = apply_preprocessor_sourcemap(sourcemap_source_filename, js.map, compile_options.sourcemap as (string | RawSourceMap | DecodedSourceMap));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
@ -1551,3 +1553,18 @@ function get_relative_path(from: string, to: string) {
|
|
|
|
|
|
|
|
|
|
return from_parts.concat(to_parts).join('/');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_basename(filename: string) {
|
|
|
|
|
return filename.split(/[/\\]/).pop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_sourcemap_source_filename(compile_options: CompileOptions) {
|
|
|
|
|
if (compile_options.filename) {
|
|
|
|
|
if (compile_options.outputFilename) {
|
|
|
|
|
return get_relative_path(compile_options.outputFilename, compile_options.filename);
|
|
|
|
|
} else {
|
|
|
|
|
return get_basename(compile_options.filename);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|