style(compiler): changed object-assign to spread (#507)

This commit is contained in:
Gabriel Loiácono 2019-11-28 12:49:39 -03:00 committed by Evan You
parent b87c05159b
commit 812a0626ce
3 changed files with 13 additions and 19 deletions

View File

@ -30,7 +30,7 @@ describe('compiler: transform', () => {
// across calls
const calls: any[] = []
const plugin: NodeTransform = (node, context) => {
calls.push([node, Object.assign({}, context)])
calls.push([node, { ...context }])
}
transform(ast, {

View File

@ -132,14 +132,8 @@ function preprocess(
options: StyleCompileOptions,
preprocessor: StylePreprocessor
): StylePreprocessorResults {
return preprocessor.render(
options.source,
options.map,
Object.assign(
{
filename: options.filename
},
options.preprocessOptions
)
)
return preprocessor.render(options.source, options.map, {
filename: options.filename,
...options.preprocessOptions
})
}

View File

@ -14,12 +14,13 @@ export interface StylePreprocessorResults {
const scss: StylePreprocessor = {
render(source, map, options) {
const nodeSass = require('sass')
const finalOptions = Object.assign({}, options, {
const finalOptions = {
...options,
data: source,
file: options.filename,
outFile: options.filename,
sourceMap: !!map
})
}
try {
const result = nodeSass.renderSync(finalOptions)
@ -41,11 +42,10 @@ const scss: StylePreprocessor = {
const sass: StylePreprocessor = {
render(source, map, options) {
return scss.render(
source,
map,
Object.assign({}, options, { indentedSyntax: true })
)
return scss.render(source, map, {
...options,
indentedSyntax: true
})
}
}
@ -58,7 +58,7 @@ const less: StylePreprocessor = {
let error: Error | null = null
nodeLess.render(
source,
Object.assign({}, options, { syncImport: true }),
{ ...options, syncImport: true },
(err: Error | null, output: any) => {
error = err
result = output