-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Error using array of importers #1168
Comments
Please either provide a fully functional example of this error or provide a Also at the very minimum provide us with the version of node sass you're
|
I'm attempting to use node-sass-json-importer, and node-sass-import-once. This error occurs in any case in which the importer(s) are specified within an array, regardless of which importer(s) are declared. I am using Here is my target use case: return gulp.src(config.styles.src)
.pipe(sass({
importer: [importOnce, jsonImporter],
includePaths: [config.appRoot],
sourceComments: 'map',
outputStyle: 'nested'
})) The error also occurs in these use cases: return gulp.src(config.styles.src)
.pipe(sass({
importer: [jsonImporter],
...
})) return gulp.src(config.styles.src)
.pipe(sass({
importer: [importOnce],
...
})) However, these use cases work just fine: return gulp.src(config.styles.src)
.pipe(sass({
importer: jsonImporter,
...
})) return gulp.src(config.styles.src)
.pipe(sass({
importer: importOnce,
...
})) |
Assuming you have meant
your examples result in
Please provide a self-contained, working script - preferably without gulp-sass, if that's possible. |
Have same bug using gulp-sass
returns error:
with adding some console.log-s in |
I'm also having this issue too |
I need a way to reproduce this without gulp-sass. Please post a self-contained, complete example of how to reproduce this bug. |
tried this but it works ok var sass = require('node-sass');
var importer = function (url, file, done) {
return done({file: url});
};
console.log(sass.renderSync({
data: "body{ color:red; }",
importer: [importer,importer]
})) |
That's why I think gulp-sass is interfering... |
@safareli I am unable to produce your error with gulp-sass.
|
@ruslansavenok I am unable to reproduce your error.
|
@SpenceDiNicolantonio I am unable to reproduce your error.
|
Closing until there is more information. |
issue was with node-sass 2.0.4 you are using newer version of it. so it looks like it that hase been fixed |
I have the same bug. This code works fine: var nodeSass = require('node-sass'),
sassCssImporter = require('node-sass-css-importer');
var scssFilename = 'app/styles.css.scss';
var importPaths = [
'bower_components/magnific-popup/dist'
];
var result = nodeSass.renderSync({
file: scssFilename,
// not array:
importer: sassCssImporter({
import_paths: importPathes
})
}); However, when I pass an array then i get an error: var nodeSass = require('node-sass'),
sassCssImporter = require('node-sass-css-importer');
var scssFilename = 'app/styles.css.scss';
var importPaths = [
'bower_components/magnific-popup/dist'
];
var result = nodeSass.renderSync({
file: scssFilename,
// array:
importer: [sassCssImporter({
import_paths: importPathes
})]
}); Versions from
|
@antixrist I think this is likely a bug in |
Hi. I got a same issue with gulp-sass. One file is work fine, but more than one file will throw this error.
// index.scss & index2.scss
@import 'lib/test'
// lib/_test.scss
.test { color: pink; } const gulp = require('gulp')
const sass = require('gulp-sass')
gulp.task('default', () => {
return gulp.src('src/*.scss')
.pipe(sass({
importer: [url => ({ file: url })]
}))
.pipe(gulp.dest('tmp'))
}) Got this output:
Versions:
Any help Thanks :) |
@yuffiy thank you for your thorough update. I have long suspected there was an issue here but was unable to track it down until now. |
Currently options are leaking between compilation runs. This is most evident when using an array of importers. The array is shallow copied internally, and the children of that array are wrapped by Node Sass. When the next file is compiled the options are shallow copied once again however this time the importer array contains the wrapped importers not the original ones. Instead of shallow copying with `Object.assign` this patch does a full deep clone. Node Sass should also do this to prevent mutating the options being passed in. Related sass/node-sass#1168 Fixes dlmanning#467 (probably)
There is a bug with both gulp-sass and node-sass when using an array of importers. The importers array is mutated each time The problem is exaggerated when gulp-sass is used. See dlmanning/gulp-sass#509 |
Currently options are leaking between compilation runs. This is most evident when using an array of importers. The array is shallow copied internally, and the children of that array are wrapped by Node Sass. When the next file is compiled the options are shallow copied once again however this time the importer array contains the wrapped importers not the original ones. Instead of shallow copying with `Object.assign` this patch does a full deep clone. Node Sass should also do this to prevent mutating the options being passed in. Related sass/node-sass#1168 Fixes dlmanning#467 (probably)
gulp-sass@v2.3.2 has been release which should address this issue for gulp-sass users. |
@xzyfer ❤️ |
The options object passed into `render` and `renderSync` is only shallow copied. This is an issue when nested objects and arrays like custom importer and functions. In the case of custom function we wrap the provided function. This wrapped version replaces the provided one which can then leak back into the calling code. This is an issue if `render*` is called in a loop like in gulp-sass. Fixes sass#1168
The options object passed into `render` and `renderSync` is only shallow copied. This is an issue when nested objects and arrays like custom importer and functions. In the case of custom function we wrap the provided function. This wrapped version replaces the provided one which can then leak back into the calling code. This is an issue if `render*` is called in a loop like in gulp-sass. Fixes sass#1168
The options object passed into `render` and `renderSync` is only shallow copied. This is an issue when nested objects and arrays like custom importer and functions. In the case of custom function we wrap the provided function. This wrapped version replaces the provided one which can then leak back into the calling code. This is an issue if `render*` is called in a loop like in gulp-sass. Fixes sass#1168
The options object passed into `render` and `renderSync` is only shallow copied. This is an issue when nested objects and arrays like custom importer and functions. In the case of custom function we wrap the provided function. This wrapped version replaces the provided one which can then leak back into the calling code. This is an issue if `render*` is called in a loop like in gulp-sass. Fixes sass#1168
The options object passed into `render` and `renderSync` is only shallow copied. This is an issue when nested objects and arrays like custom importer and functions. In the case of custom function we wrap the provided function. This wrapped version replaces the provided one which can then leak back into the calling code. This is an issue if `render*` is called in a loop like in gulp-sass. Fixes #1168
This fix will be released in v3.8.0 tomorrow. |
@xzyfer 😘 |
I get the following error when providing an array of importers (including when the array contains a single importer):
The text was updated successfully, but these errors were encountered: