1 | 'use strict';
|
2 |
|
3 | var stream$1 = require('stream');
|
4 | var rollup = require('rollup');
|
5 |
|
6 | const build = async (options, stream) => {
|
7 | const bundle = await rollup.rollup(options);
|
8 | stream.emit('bundle', bundle);
|
9 | const { output } = await bundle.generate(options);
|
10 | for (const chunk of output) {
|
11 | if (chunk.type === 'asset') {
|
12 | stream.push(chunk.source);
|
13 | }
|
14 | else {
|
15 | stream.push(chunk.code);
|
16 | if (chunk.map) {
|
17 | stream.push(`\n//# sourceMappingURL=${chunk.map.toUrl()}`);
|
18 | }
|
19 | }
|
20 | }
|
21 |
|
22 | stream.push(null);
|
23 | };
|
24 | const stream = (options) => {
|
25 | const result = new stream$1.Readable({
|
26 |
|
27 | read: () => { }
|
28 | });
|
29 | build(options, result).catch((error) => {
|
30 | result.emit('error', error);
|
31 | });
|
32 | return result;
|
33 | };
|
34 |
|
35 | module.exports = stream;
|