{"id":20514489,"url":"https://github.com/rollup/stream","last_synced_at":"2025-04-14T00:13:39.240Z","repository":{"id":55663172,"uuid":"229515958","full_name":"rollup/stream","owner":"rollup","description":"🍣  Stream Rollup build results","archived":false,"fork":false,"pushed_at":"2023-10-14T05:12:53.000Z","size":415,"stargazers_count":21,"open_issues_count":2,"forks_count":12,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-14T00:13:13.835Z","etag":null,"topics":["readable","readable-stream","rollup","rollup-js","rollupjs","stream"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rollup.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"open_collective":"rollup"}},"created_at":"2019-12-22T04:03:52.000Z","updated_at":"2025-02-05T02:12:25.000Z","dependencies_parsed_at":"2024-01-26T21:01:59.954Z","dependency_job_id":null,"html_url":"https://github.com/rollup/stream","commit_stats":{"total_commits":32,"total_committers":8,"mean_commits":4.0,"dds":0.40625,"last_synced_commit":"91306a4a240d3d5ec820fec94ebaf3f26108c560"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollup%2Fstream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollup%2Fstream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollup%2Fstream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rollup%2Fstream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rollup","download_url":"https://codeload.github.com/rollup/stream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799956,"owners_count":21163404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["readable","readable-stream","rollup","rollup-js","rollupjs","stream"],"created_at":"2024-11-15T21:16:50.092Z","updated_at":"2025-04-14T00:13:39.196Z","avatar_url":"https://github.com/rollup.png","language":"TypeScript","readme":"[cover]: https://codecov.io/gh/rollup/stream/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/rollup/stream\n[tests]: https://img.shields.io/circleci/project/github/rollup/stream.svg\n[tests-url]: https://circleci.com/gh/rollup/stream\n[npm]: https://img.shields.io/npm/v/@rollup/stream\n[npm-url]: https://www.npmjs.com/package/@rollup/stream\n[size]: https://packagephobia.now.sh/badge?p=@rollup/stream\n[size-url]: https://packagephobia.now.sh/result?p=@rollup/stream\n\n[![tests][tests]][tests-url]\n[![cover][cover]][cover-url]\n[![npm][npm]][npm-url]\n[![size][size]][size-url]\n[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)\n\n# @rollup/stream\n\n🍣 Stream Rollup build results\n\nThis package exists to provide a streaming interface for Rollup builds. This is useful in situations where a build system is working with [vinyl files](https://github.com/gulpjs/vinyl), such as [`gulp.js`](https://gulpjs.com/).\n\n## Requirements\n\nThis plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+.\n\n## Install\n\nUsing npm:\n\n```console\nnpm install @rollup/stream --save-dev\n```\n\n## Usage\n\nAssume a `src/index.js` file exists and contains code like the following:\n\n```js\nexport default 'jingle bells, batman smells';\n```\n\nWe can bundle `src/index.js` using streams such like:\n\n```js\nimport rollupStream from '@rollup/stream';\n\nconst { log } = console;\nconst options = {\n  input: 'src/index.js',\n  output: { format: 'cjs' },\n};\nconst stream = rollupStream(options);\nlet bundle = '';\n\nstream.on('data', (data) =\u003e (bundle += data));\nstream.on('end', () =\u003e log(bundle));\n```\n\nThe preceding code will concatenate each chunk (or asset) and output the entire bundle's content when Rollup has completed bundling and the stream has ended.\n\n## Options\n\nAll [Rollup options](https://www.rollupjs.org/guide/en/#configuration-files) are valid to pass as options to `@rollup/stream`.\n\n### Usage with Gulp\n\nUsing Gulp requires piping. Suppose one wanted to take the bundle content and run it through a minifier, such as [`terser`](https://www.npmjs.com/package/terser):\n\n```js\nimport rollupStream from '@rollup/stream';\nimport gulp from 'gulp';\nimport terser from 'gulp-terser';\nimport source from 'vinyl-source-stream';\n\ngulp.task('rollup', () =\u003e {\n  const options = { input: 'src/index.js' };\n  return rollupStream(options)\n    .pipe(source('bundle.js'))\n    .pipe(terser({ keep_fnames: true, mangle: false }))\n    .pipe(gulp.dest('dist'));\n});\n```\n\n### Using Sourcemaps\n\nRollup can produce source maps by specifying the `sourcemap` output option. For example; to use the generated sourcemaps with Gulp and `@rollup/stream`:\n\n```js\nimport rollupStream from '@rollup/stream';\nimport buffer from 'vinyl-buffer';\nimport gulp from 'gulp';\nimport sourcemaps from 'gulp-sourcemaps';\nimport source from 'vinyl-source-stream';\n\ngulp.task('rollup', () =\u003e {\n  const options = { input: 'src/index.js', output: { sourcemap: true } };\n  return rollupStream(options)\n    .pipe(source('bundle.js'))\n    .pipe(buffer())\n    .pipe(sourcemaps.init({ loadMaps: true }))\n    .pipe(sourcemaps.write('dist'))\n    .pipe(gulp.dest('dist'));\n});\n```\n\n### Caching\n\nThe ability to cache a build is already [built into Rollup](https://www.rollupjs.org/guide/en/#cache), so users of `@rollup/stream` get that for free. Caching can be useful to reduce or optimize build times, and is often used when watching files that are part of a build. For example; to utilize caching with Gulp and `@rollup/stream`:\n\n```js\nimport rollupStream from '@rollup/stream';\nimport buffer from 'vinyl-buffer';\nimport gulp from 'gulp';\nimport source from 'vinyl-source-stream';\n\n// declare the cache variable outside of task scopes\nlet cache;\n\ngulp.task('rollup', () =\u003e {\n  return rollupStream({\n    input: 'src/index.js',\n    // define the cache in Rollup options\n    cache,\n  })\n    .on('bundle', (bundle) =\u003e {\n      // update the cache after every new bundle is created\n      cache = bundle;\n    })\n    .pipe(source('bundle.js'))\n    .pipe(buffer())\n    .pipe(gulp.dest('dist'));\n});\n\ngulp.task('watch', (done) =\u003e {\n  gulp.watch('./src/**/*.js', gulp.series('rollup'));\n\n  // or, with Gulp v3\n  // gulp.watch('./src/**/*.js', ['rollup']);\n\n  done();\n});\n```\n\n_(Example based on the [rollup-stream README](https://github.com/Permutatrix/rollup-stream#readme))_\n\n## Meta\n\n[CONTRIBUTING](/.github/CONTRIBUTING.md)\n\n[LICENSE (MIT)](/LICENSE)\n","funding_links":["https://opencollective.com/rollup"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frollup%2Fstream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frollup%2Fstream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frollup%2Fstream/lists"}