{"action":"created","issue":{"url":"https://api.github.com/repos/rollup/rollup/issues/2305","repository_url":"https://api.github.com/repos/rollup/rollup","labels_url":"https://api.github.com/repos/rollup/rollup/issues/2305/labels{/name}","comments_url":"https://api.github.com/repos/rollup/rollup/issues/2305/comments","events_url":"https://api.github.com/repos/rollup/rollup/issues/2305/events","html_url":"https://github.com/rollup/rollup/issues/2305","id":336660425,"node_id":"MDU6SXNzdWUzMzY2NjA0MjU=","number":2305,"title":"onwrite/generateBundle hook execution order not guaranteed any more","user":{"login":"kryops","id":1042594,"node_id":"MDQ6VXNlcjEwNDI1OTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1042594?v=4","gravatar_id":"","url":"https://api.github.com/users/kryops","html_url":"https://github.com/kryops","followers_url":"https://api.github.com/users/kryops/followers","following_url":"https://api.github.com/users/kryops/following{/other_user}","gists_url":"https://api.github.com/users/kryops/gists{/gist_id}","starred_url":"https://api.github.com/users/kryops/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kryops/subscriptions","organizations_url":"https://api.github.com/users/kryops/orgs","repos_url":"https://api.github.com/users/kryops/repos","events_url":"https://api.github.com/users/kryops/events{/privacy}","received_events_url":"https://api.github.com/users/kryops/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-06-28T15:02:52Z","updated_at":"2018-08-06T16:43:52Z","closed_at":"2018-08-06T16:43:52Z","author_association":"NONE","body":"Hi everyone,\r\n\r\nit seems like the onwrite plugin hook does not execute in the order that the plugins were defined any more.\r\n\r\nI got the following issue report today:\r\nhttps://github.com/kryops/rollup-plugin-gzip/issues/2\r\n\r\nThis seems to be a regression from 0.60 - I followed it to this commit:\r\nhttps://github.com/rollup/rollup/commit/a329517f309a3b6a2309a9240ed24cd6a251ed20\r\n\r\nIt breaks cases like the following:\r\n\r\n- plugin 1 hooks into the `onwrite` callback, writes an additional file and then resolves the promise it returned\r\n- plugin 2 hooks into the `onwrite` callback as well, and wants to do something with the file written by plugin 1\r\n\r\nWhat is the intended behavior in this case?\r\n\r\n- Should we be able to rely on the plugin definition order?\r\n- Will all this be superseded by the new asset definition workflow anyway? (so plugin 1 will have to define its file as an asset)\r\n\r\nRight now the only thing I could do in plugin 2 is to wait a certain amount of time and hope that plugin 1 is done :confused: \r\n\r\nReproduction:\r\n```\r\nimport * as fs from 'fs'\r\n\r\nrollup\r\n        .rollup({\r\n            input: 'test/sample/index.js',\r\n            plugins: [\r\n                {\r\n                    name: 'test1',\r\n                    onwrite: (options, bundle) => {\r\n                        return new Promise(resolve => {\r\n                            setTimeout(() => {\r\n                                fs.writeFile('test/__output/test.txt', 'This is a test', () => resolve());\r\n                            }, 1000);\r\n                        });\r\n                    }\r\n                },\r\n                {\r\n                    name: 'test2',\r\n                    onwrite: (options, bundle) => {\r\n                        return new Promise((resolve, reject) => {\r\n                            fs.stat('test/__output/test.txt', (err, stats) => {\r\n                                if(err) reject('File not written!');\r\n                                else resolve();\r\n                            });\r\n                        });\r\n                    }\r\n                },\r\n            ]\r\n        })\r\n        .then(bundle => {\r\n            return bundle.write({\r\n                file: 'test/__output/bundle.js',\r\n                format: 'cjs'\r\n            });\r\n        })\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/rollup/rollup/issues/comments/410772339","html_url":"https://github.com/rollup/rollup/issues/2305#issuecomment-410772339","issue_url":"https://api.github.com/repos/rollup/rollup/issues/2305","id":410772339,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMDc3MjMzOQ==","user":{"login":"guybedford","id":598730,"node_id":"MDQ6VXNlcjU5ODczMA==","avatar_url":"https://avatars1.githubusercontent.com/u/598730?v=4","gravatar_id":"","url":"https://api.github.com/users/guybedford","html_url":"https://github.com/guybedford","followers_url":"https://api.github.com/users/guybedford/followers","following_url":"https://api.github.com/users/guybedford/following{/other_user}","gists_url":"https://api.github.com/users/guybedford/gists{/gist_id}","starred_url":"https://api.github.com/users/guybedford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guybedford/subscriptions","organizations_url":"https://api.github.com/users/guybedford/orgs","repos_url":"https://api.github.com/users/guybedford/repos","events_url":"https://api.github.com/users/guybedford/events{/privacy}","received_events_url":"https://api.github.com/users/guybedford/received_events","type":"User","site_admin":false},"created_at":"2018-08-06T16:43:52Z","updated_at":"2018-08-06T16:43:52Z","author_association":"CONTRIBUTOR","body":"This was merged in #2364."}}
{"actor":{"display_login":"guybedford"}}