{"action":"created","issue":{"url":"https://api.github.com/repos/tivac/modular-css/issues/291","repository_url":"https://api.github.com/repos/tivac/modular-css","labels_url":"https://api.github.com/repos/tivac/modular-css/issues/291/labels{/name}","comments_url":"https://api.github.com/repos/tivac/modular-css/issues/291/comments","events_url":"https://api.github.com/repos/tivac/modular-css/issues/291/events","html_url":"https://github.com/tivac/modular-css/pull/291","id":226492429,"number":291,"title":"Fix webpack watch cache staleness","user":{"login":"tivac","id":49545,"avatar_url":"https://avatars3.githubusercontent.com/u/49545?v=3","gravatar_id":"","url":"https://api.github.com/users/tivac","html_url":"https://github.com/tivac","followers_url":"https://api.github.com/users/tivac/followers","following_url":"https://api.github.com/users/tivac/following{/other_user}","gists_url":"https://api.github.com/users/tivac/gists{/gist_id}","starred_url":"https://api.github.com/users/tivac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tivac/subscriptions","organizations_url":"https://api.github.com/users/tivac/orgs","repos_url":"https://api.github.com/users/tivac/repos","events_url":"https://api.github.com/users/tivac/events{/privacy}","received_events_url":"https://api.github.com/users/tivac/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-05T07:19:24Z","updated_at":"2017-05-05T09:41:35Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/tivac/modular-css/pulls/291","html_url":"https://github.com/tivac/modular-css/pull/291","diff_url":"https://github.com/tivac/modular-css/pull/291.diff","patch_url":"https://github.com/tivac/modular-css/pull/291.patch"},"body":"This is a copy of the very brute-force approach the rollup plugin takes, it simply throws away the entire Processor instance after each run. There may be a better way to handle this within webpack (`watchify` fires very useful file change events we can use to precisely purge the cache, for instance) but for now this will remove a lot of badness at the cost of some speed.\r\n\r\ncc @TrySound \r\n\r\nFixes #290 "},"comment":{"url":"https://api.github.com/repos/tivac/modular-css/issues/comments/299423640","html_url":"https://github.com/tivac/modular-css/pull/291#issuecomment-299423640","issue_url":"https://api.github.com/repos/tivac/modular-css/issues/291","id":299423640,"user":{"login":"TrySound","id":5635476,"avatar_url":"https://avatars3.githubusercontent.com/u/5635476?v=3","gravatar_id":"","url":"https://api.github.com/users/TrySound","html_url":"https://github.com/TrySound","followers_url":"https://api.github.com/users/TrySound/followers","following_url":"https://api.github.com/users/TrySound/following{/other_user}","gists_url":"https://api.github.com/users/TrySound/gists{/gist_id}","starred_url":"https://api.github.com/users/TrySound/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TrySound/subscriptions","organizations_url":"https://api.github.com/users/TrySound/orgs","repos_url":"https://api.github.com/users/TrySound/repos","events_url":"https://api.github.com/users/TrySound/events{/privacy}","received_events_url":"https://api.github.com/users/TrySound/received_events","type":"User","site_admin":false},"created_at":"2017-05-05T09:41:35Z","updated_at":"2017-05-05T09:41:35Z","body":"The problem is that we can't relay only on watcher events. We use gulp with its watcher and run webpack in task. So webpack's events won't be triggered. There's a solution in webpack stuff.\r\nHere's a bit modified example from https://webpack.js.org/development/plugin-patterns/#monitoring-the-watch-graph\r\n\r\n```js\r\nclass MyPlugin {\r\n    constructor() {\r\n      this.startTime = Date.now();\r\n      this.prevTimestamps = {};\r\n    }\r\n\r\n    apply(compiler) {\r\n      compiler.plugin('emit', (compilation, callback) => {\r\n        const changedFiles = Object.keys(compilation.fileTimestamps).filter(watchfile => {\r\n            const prevTime = (this.prevTimestamps[watchfile] || this.startTime);\r\n            const nextTime = (compilation.fileTimestamps[watchfile] || Infinity);\r\n            return prevTime < nextTime;\r\n        });\r\n        const removedFiles = Object.keys(this.prevTimestamps)\r\n            .filter(watchfile => !compilation.fileTimestamps[watchfile]);\r\n        console.log('changed or added files', changedFiles);\r\n        console.log('removed files', removedFiles);\r\n\r\n        this.prevTimestamps = compilation.fileTimestamps;\r\n        callback();\r\n      });\r\n    }\r\n}\r\n```"}}
{"actor":{"display_login":"TrySound"}}