types: use RawSourceMap types
This commit is contained in:
parent
20ea67c834
commit
3de7315b7a
@ -8,12 +8,13 @@ import {
|
|||||||
StylePreprocessorResults,
|
StylePreprocessorResults,
|
||||||
PreprocessLang
|
PreprocessLang
|
||||||
} from './stylePreprocessors'
|
} from './stylePreprocessors'
|
||||||
|
import { RawSourceMap } from 'source-map'
|
||||||
|
|
||||||
export interface StyleCompileOptions {
|
export interface StyleCompileOptions {
|
||||||
source: string
|
source: string
|
||||||
filename: string
|
filename: string
|
||||||
id: string
|
id: string
|
||||||
map?: object
|
map?: RawSourceMap
|
||||||
scoped?: boolean
|
scoped?: boolean
|
||||||
trim?: boolean
|
trim?: boolean
|
||||||
preprocessLang?: PreprocessLang
|
preprocessLang?: PreprocessLang
|
||||||
@ -28,9 +29,9 @@ export interface AsyncStyleCompileOptions extends StyleCompileOptions {
|
|||||||
|
|
||||||
export interface StyleCompileResults {
|
export interface StyleCompileResults {
|
||||||
code: string
|
code: string
|
||||||
map: object | void
|
map: RawSourceMap | undefined
|
||||||
rawResult: LazyResult | Result | undefined
|
rawResult: LazyResult | Result | undefined
|
||||||
errors: string[]
|
errors: Error[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compileStyle(
|
export function compileStyle(
|
||||||
@ -89,7 +90,7 @@ export function doCompileStyle(
|
|||||||
let code: string | undefined
|
let code: string | undefined
|
||||||
let outMap: ResultMap | undefined
|
let outMap: ResultMap | undefined
|
||||||
|
|
||||||
const errors: any[] = []
|
const errors: Error[] = []
|
||||||
if (preProcessedSource && preProcessedSource.errors.length) {
|
if (preProcessedSource && preProcessedSource.errors.length) {
|
||||||
errors.push(...preProcessedSource.errors)
|
errors.push(...preProcessedSource.errors)
|
||||||
}
|
}
|
||||||
@ -102,14 +103,14 @@ export function doCompileStyle(
|
|||||||
return result
|
return result
|
||||||
.then(result => ({
|
.then(result => ({
|
||||||
code: result.css || '',
|
code: result.css || '',
|
||||||
map: result.map && result.map.toJSON(),
|
map: result.map && (result.map.toJSON() as any),
|
||||||
errors,
|
errors,
|
||||||
rawResult: result
|
rawResult: result
|
||||||
}))
|
}))
|
||||||
.catch(error => ({
|
.catch(error => ({
|
||||||
code: '',
|
code: '',
|
||||||
map: undefined,
|
map: undefined,
|
||||||
errors: [...errors, error.message],
|
errors: [...errors, error],
|
||||||
rawResult: undefined
|
rawResult: undefined
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -123,7 +124,7 @@ export function doCompileStyle(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
code: code || ``,
|
code: code || ``,
|
||||||
map: outMap && outMap.toJSON(),
|
map: outMap && (outMap.toJSON() as any),
|
||||||
errors,
|
errors,
|
||||||
rawResult: result
|
rawResult: result
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ export interface StylePreprocessor {
|
|||||||
export interface StylePreprocessorResults {
|
export interface StylePreprocessorResults {
|
||||||
code: string
|
code: string
|
||||||
map?: object
|
map?: object
|
||||||
errors: Array<Error>
|
errors: Error[]
|
||||||
}
|
}
|
||||||
|
|
||||||
// .scss/.sass processor
|
// .scss/.sass processor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user