Skip to content

Commit eaf06b6

Browse files
committed
fix: Pass a copy of sass options for sync setup.
1 parent 2c35c05 commit eaf06b6

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

packages/@css-blocks/eyeglass/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@
5050
"yarn": "1.22.0"
5151
},
5252
"devDependencies": {
53+
"@types/lodash.clonedeep": "^4.5.6",
5354
"@types/node-sass": "^4.11.0",
5455
"@types/sinon": "^7.5.1",
5556
"eyeglass": "^2.4.2",
5657
"mocha": "^7.0.1",
5758
"node-sass": "^4.13.1",
5859
"sinon": "^8.0.4"
60+
},
61+
"dependencies": {
62+
"lodash.clonedeep": "^4.5.0"
5963
}
6064
}

packages/@css-blocks/eyeglass/src/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { EyeglassOptions, default as Eyeglass } from "eyeglass"; // works,
33
import type { Result, SassError } from "node-sass";
44
import type SassImplementation from "node-sass";
55
import { sep as PATH_SEPARATOR } from "path";
6+
import cloneDeep = require("lodash.clonedeep");
67

78
export type Adaptor = (sass: typeof SassImplementation, eyeglass: typeof Eyeglass, options: EyeglassOptions) => Preprocessor;
89
export type AdaptorSync = (sass: typeof SassImplementation, eyeglass: typeof Eyeglass, options: EyeglassOptions) => PreprocessorSync;
@@ -123,7 +124,10 @@ export class DirectoryScopedPreprocessor implements PreprocessorProvider {
123124
*/
124125
init(sass: typeof SassImplementation, eyeglass: typeof Eyeglass, options: EyeglassOptions = {}) {
125126
let sassOptions = this.setupOptions(options);
126-
let sassOptionsSync = this.setupOptionsSync ? this.setupOptionsSync(sassOptions) : sassOptions;
127+
128+
let sassOptionsSync = cloneDeep(sassOptions);
129+
sassOptionsSync = this.setupOptionsSync ? this.setupOptionsSync(sassOptionsSync) : sassOptionsSync;
130+
127131
this.scssProcessor = adaptor(sass, eyeglass, sassOptions);
128132
this.scssProcessorSync = adaptorSync(sass, eyeglass, sassOptionsSync);
129133
}
@@ -146,7 +150,7 @@ export class DirectoryScopedPreprocessor implements PreprocessorProvider {
146150
* provided from the application that will be used for compiling this
147151
* package's block files synchronously.
148152
*
149-
* The options passed into this function are those returned by
153+
* The options passed into this function are a copy of those returned by
150154
* setupOptions(), so this method only needs to update those options as
151155
* appropriate to support synchronous compilation.
152156
*

yarn.lock

+7
Original file line numberDiff line numberDiff line change
@@ -3013,6 +3013,13 @@
30133013
"@types/node" "*"
30143014
"@types/webpack" "*"
30153015

3016+
"@types/lodash.clonedeep@^4.5.6":
3017+
version "4.5.6"
3018+
resolved "https://registry.npmjs.org/@types/lodash.clonedeep/-/lodash.clonedeep-4.5.6.tgz#3b6c40a0affe0799a2ce823b440a6cf33571d32b"
3019+
integrity sha512-cE1jYr2dEg1wBImvXlNtp0xDoS79rfEdGozQVgliDZj1uERH4k+rmEMTudP9b4VQ8O6nRb5gPqft0QzEQGMQgA==
3020+
dependencies:
3021+
"@types/lodash" "*"
3022+
30163023
"@types/lodash.merge@^4.6.6":
30173024
version "4.6.6"
30183025
resolved "https://registry.npmjs.org/@types/lodash.merge/-/lodash.merge-4.6.6.tgz#b84b403c1d31bc42d51772d1cd5557fa008cd3d6"

0 commit comments

Comments
 (0)