{"action":"created","issue":{"url":"https://api.github.com/repos/eugeneware/replacestream/issues/26","repository_url":"https://api.github.com/repos/eugeneware/replacestream","labels_url":"https://api.github.com/repos/eugeneware/replacestream/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/eugeneware/replacestream/issues/26/comments","events_url":"https://api.github.com/repos/eugeneware/replacestream/issues/26/events","html_url":"https://github.com/eugeneware/replacestream/issues/26","id":144857046,"number":26,"title":"replacing create unexecutable javascript files","user":{"login":"EyMaddis","id":1409100,"avatar_url":"https://avatars.githubusercontent.com/u/1409100?v=3","gravatar_id":"","url":"https://api.github.com/users/EyMaddis","html_url":"https://github.com/EyMaddis","followers_url":"https://api.github.com/users/EyMaddis/followers","following_url":"https://api.github.com/users/EyMaddis/following{/other_user}","gists_url":"https://api.github.com/users/EyMaddis/gists{/gist_id}","starred_url":"https://api.github.com/users/EyMaddis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EyMaddis/subscriptions","organizations_url":"https://api.github.com/users/EyMaddis/orgs","repos_url":"https://api.github.com/users/EyMaddis/repos","events_url":"https://api.github.com/users/EyMaddis/events{/privacy}","received_events_url":"https://api.github.com/users/EyMaddis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-31T10:33:33Z","updated_at":"2016-04-07T22:32:53Z","closed_at":null,"body":"hi,\r\nI tried to create a simple server that replaces a string on file load and serves it (for development purposes).\r\nI noticed that whenever it does it's magic on javascript files, it will block their execution (tested in Chrome), even though the file is completely served and the headers (content-type) are correct.\r\n\r\nHere is my server to recreate this:\r\n\r\n```\r\n// jshint globalstrict:true, node:true, esnext:true\r\n'use strict';\r\n\r\nconst koa = require('koa');\r\nconst app = koa();\r\nconst replaceStream = require('stream-replace');\r\nconst staticServe = require('koa-static');\r\nconst sendFile = require('koa-send');\r\n\r\napp.use(function*(next) {\r\n    const url = this.req.url;\r\n    \r\n    yield* next; // file serve\r\n    \r\n    // applying replace to javascript is breaking execution\r\n        this.body = this.body\r\n            .pipe(replaceStream(/{{VERSION}}/g, 'some version'));\r\n});\r\n\r\napp.use(staticServe('files/', {}));\r\n\r\nconst port = process.env.PORT || 8000;\r\napp.listen(port, () => {\r\n    console.log('server started on port', port);\r\n});\r\n```\r\n\r\nit serves the files in the `files/` directory via http.\r\n\r\n\r\nI guess that it might have something to do that the end of files are altered."},"comment":{"url":"https://api.github.com/repos/eugeneware/replacestream/issues/comments/207120702","html_url":"https://github.com/eugeneware/replacestream/issues/26#issuecomment-207120702","issue_url":"https://api.github.com/repos/eugeneware/replacestream/issues/26","id":207120702,"user":{"login":"stevemao","id":6316590,"avatar_url":"https://avatars.githubusercontent.com/u/6316590?v=3","gravatar_id":"","url":"https://api.github.com/users/stevemao","html_url":"https://github.com/stevemao","followers_url":"https://api.github.com/users/stevemao/followers","following_url":"https://api.github.com/users/stevemao/following{/other_user}","gists_url":"https://api.github.com/users/stevemao/gists{/gist_id}","starred_url":"https://api.github.com/users/stevemao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevemao/subscriptions","organizations_url":"https://api.github.com/users/stevemao/orgs","repos_url":"https://api.github.com/users/stevemao/repos","events_url":"https://api.github.com/users/stevemao/events{/privacy}","received_events_url":"https://api.github.com/users/stevemao/received_events","type":"User","site_admin":false},"created_at":"2016-04-07T22:32:53Z","updated_at":"2016-04-07T22:32:53Z","body":"Any info on how to replicate your problem would be useful"}}