style(compiler): changed object-assign to spread (#507)
This commit is contained in:
parent
b87c05159b
commit
812a0626ce
@ -30,7 +30,7 @@ describe('compiler: transform', () => {
|
|||||||
// across calls
|
// across calls
|
||||||
const calls: any[] = []
|
const calls: any[] = []
|
||||||
const plugin: NodeTransform = (node, context) => {
|
const plugin: NodeTransform = (node, context) => {
|
||||||
calls.push([node, Object.assign({}, context)])
|
calls.push([node, { ...context }])
|
||||||
}
|
}
|
||||||
|
|
||||||
transform(ast, {
|
transform(ast, {
|
||||||
|
@ -132,14 +132,8 @@ function preprocess(
|
|||||||
options: StyleCompileOptions,
|
options: StyleCompileOptions,
|
||||||
preprocessor: StylePreprocessor
|
preprocessor: StylePreprocessor
|
||||||
): StylePreprocessorResults {
|
): StylePreprocessorResults {
|
||||||
return preprocessor.render(
|
return preprocessor.render(options.source, options.map, {
|
||||||
options.source,
|
filename: options.filename,
|
||||||
options.map,
|
...options.preprocessOptions
|
||||||
Object.assign(
|
})
|
||||||
{
|
|
||||||
filename: options.filename
|
|
||||||
},
|
|
||||||
options.preprocessOptions
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,13 @@ export interface StylePreprocessorResults {
|
|||||||
const scss: StylePreprocessor = {
|
const scss: StylePreprocessor = {
|
||||||
render(source, map, options) {
|
render(source, map, options) {
|
||||||
const nodeSass = require('sass')
|
const nodeSass = require('sass')
|
||||||
const finalOptions = Object.assign({}, options, {
|
const finalOptions = {
|
||||||
|
...options,
|
||||||
data: source,
|
data: source,
|
||||||
file: options.filename,
|
file: options.filename,
|
||||||
outFile: options.filename,
|
outFile: options.filename,
|
||||||
sourceMap: !!map
|
sourceMap: !!map
|
||||||
})
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = nodeSass.renderSync(finalOptions)
|
const result = nodeSass.renderSync(finalOptions)
|
||||||
@ -41,11 +42,10 @@ const scss: StylePreprocessor = {
|
|||||||
|
|
||||||
const sass: StylePreprocessor = {
|
const sass: StylePreprocessor = {
|
||||||
render(source, map, options) {
|
render(source, map, options) {
|
||||||
return scss.render(
|
return scss.render(source, map, {
|
||||||
source,
|
...options,
|
||||||
map,
|
indentedSyntax: true
|
||||||
Object.assign({}, options, { indentedSyntax: true })
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ const less: StylePreprocessor = {
|
|||||||
let error: Error | null = null
|
let error: Error | null = null
|
||||||
nodeLess.render(
|
nodeLess.render(
|
||||||
source,
|
source,
|
||||||
Object.assign({}, options, { syncImport: true }),
|
{ ...options, syncImport: true },
|
||||||
(err: Error | null, output: any) => {
|
(err: Error | null, output: any) => {
|
||||||
error = err
|
error = err
|
||||||
result = output
|
result = output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user