{"action":"created","issue":{"url":"https://api.github.com/repos/w0rm/gulp-svgstore/issues/61","repository_url":"https://api.github.com/repos/w0rm/gulp-svgstore","labels_url":"https://api.github.com/repos/w0rm/gulp-svgstore/issues/61/labels{/name}","comments_url":"https://api.github.com/repos/w0rm/gulp-svgstore/issues/61/comments","events_url":"https://api.github.com/repos/w0rm/gulp-svgstore/issues/61/events","html_url":"https://github.com/w0rm/gulp-svgstore/issues/61","id":140417919,"number":61,"title":"Symbols are empty after gulp-remember has populated it's cache","user":{"login":"AndyOGo","id":914443,"avatar_url":"https://avatars.githubusercontent.com/u/914443?v=3","gravatar_id":"","url":"https://api.github.com/users/AndyOGo","html_url":"https://github.com/AndyOGo","followers_url":"https://api.github.com/users/AndyOGo/followers","following_url":"https://api.github.com/users/AndyOGo/following{/other_user}","gists_url":"https://api.github.com/users/AndyOGo/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyOGo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyOGo/subscriptions","organizations_url":"https://api.github.com/users/AndyOGo/orgs","repos_url":"https://api.github.com/users/AndyOGo/repos","events_url":"https://api.github.com/users/AndyOGo/events{/privacy}","received_events_url":"https://api.github.com/users/AndyOGo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-03-12T21:21:21Z","updated_at":"2016-03-13T22:41:12Z","closed_at":"2016-03-12T21:54:43Z","body":"I'm currently utilizing `gulp-cached` and `gulp-remember` to make my build more incremental.\r\nUnfortunately `gulp-svgstore` is broken in conjunction with `gulp-remember`.\r\n\r\nI tracked the issue down, to the following lines of code:\r\n\r\n1. `gulp-svgstore` adds a JSDOM `cheerio` property to the current file, but only if it does not exist already.\r\n[file.cheerio](https://github.com/w0rm/gulp-svgstore/blob/master/index.js#L38-L40)\r\n2. This SVG document is cached in `$svg` [$svg](https://github.com/w0rm/gulp-svgstore/blob/master/index.js#L42)\r\n3. At the end the whole contens of the `$svg`variable is appended to the current [SVG symbol](https://github.com/w0rm/gulp-svgstore/blob/master/index.js#L111) `$symbol`.\r\nThis step removes all children of `$svg`and hence also of `file.cheerio`, which causes empty `<symbol>` tags in my sprite after `gulp-cached` and `gulp-remember` have done their magic (e.g. after a watch has triggered).\r\n\r\n## Suggested Fix 1\r\nCleanup file.cheerio reference in [stream._transform](https://github.com/w0rm/gulp-svgstore/blob/master/index.js#L30) function:\r\n```js\r\ndelete file.cheerio; \r\n```\r\n## Suggested Fix 2\r\nJust clone the entire svg before appending it to a symbol. This way the cache stays untouched.\r\n\r\n## Quick fix utilizing `gulp-intercept`\r\n```js\r\ngulp.src('src/icons/*.svg')\r\n    .pipe($.cached('sprites:svg'))\r\n    .pipe($.svgmin(function (file) {\r\n        var prefix = path.basename(file.relative, path.extname(file.relative));\r\n        return {\r\n            plugins: [{\r\n                cleanupIDs: {\r\n                    prefix: prefix + '-',\r\n                    minify: config.minifySVG\r\n                }\r\n            }]\r\n        }\r\n    }))\r\n    .pipe($.remember('sprites:svg'))\r\n    .pipe($.intercept(function(file) {\r\n        // this is IMPORTANT!!!!\r\n        // gulp-svgstore adds cheerio property to file, but does not clean up\r\n        // hence this breaks gulp-remember, who remembers an empty cheerio instance.\r\n        delete file.cheerio;\r\n        return file;\r\n    }))\r\n    .pipe($.svgstore())\r\n    .pipe(gulp.dest('dest/icons'))\r\n``"},"comment":{"url":"https://api.github.com/repos/w0rm/gulp-svgstore/issues/comments/196073470","html_url":"https://github.com/w0rm/gulp-svgstore/issues/61#issuecomment-196073470","issue_url":"https://api.github.com/repos/w0rm/gulp-svgstore/issues/61","id":196073470,"user":{"login":"AndyOGo","id":914443,"avatar_url":"https://avatars.githubusercontent.com/u/914443?v=3","gravatar_id":"","url":"https://api.github.com/users/AndyOGo","html_url":"https://github.com/AndyOGo","followers_url":"https://api.github.com/users/AndyOGo/followers","following_url":"https://api.github.com/users/AndyOGo/following{/other_user}","gists_url":"https://api.github.com/users/AndyOGo/gists{/gist_id}","starred_url":"https://api.github.com/users/AndyOGo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndyOGo/subscriptions","organizations_url":"https://api.github.com/users/AndyOGo/orgs","repos_url":"https://api.github.com/users/AndyOGo/repos","events_url":"https://api.github.com/users/AndyOGo/events{/privacy}","received_events_url":"https://api.github.com/users/AndyOGo/received_events","type":"User","site_admin":false},"created_at":"2016-03-13T22:41:12Z","updated_at":"2016-03-13T22:41:12Z","body":"@w0rm I see, thats true. Then I thing it's best just avoid caching as you did already."}}