stream icon indicating copy to clipboard operation
stream copied to clipboard

Error: You must supply an options object - but options object is being supplied

Open Liam-OShea opened this issue 2 years ago • 3 comments

I am trying to use this module but it seems to have an issue with the options object. Even though I am providing one, it is returning Error: You must supply an options object. Please see report below.

  • @rollup/stream Version: ^2.0.0
  • Rollup Version:
  • "peerDependencies": { "rollup": "^2.35.1" }
  • Operating System (or Browser): Macbook Air M1
  • Node Version: 16

How Do We Reproduce?

Minimal repository reproduction: https://github.com/Liam-OShea/RollupIssueReproduction

Expected Behavior

Bundling works without issue

Actual Behavior

Error: You must supply an options object at getOutputOptionsAndPluginDriver (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/rollup/dist/shared/rollup.js:23604:15) at handleGenerateWrite (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/rollup/dist/shared/rollup.js:23587:74) at Object.generate (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/rollup/dist/shared/rollup.js:23548:20) at build (/Users/liam/Documents/Work/ProofOfConcept/gulpinject/node_modules/@rollup/stream/dist/index.js:10:37)

Liam-OShea avatar Jan 10 '22 17:01 Liam-OShea

I was able to solve this using the info in a recent issue posted here (thanks @domoritz): https://github.com/rollup/stream/issues/15#issue-1096693378

It seems like the error handling should be updated to inform that the output options are missing, rather than returning an error that the options object is missing.

Liam-OShea avatar Jan 10 '22 18:01 Liam-OShea

This isn't a very frequently maintained package. We'd be happy to review a PR from the community to resolve the issue.

shellscape avatar Jun 07 '23 18:06 shellscape

I've just had this problem to. You need to add a output option as well, like this:

const options = { 
    input: 'src/js/test.js', 
    output: { sourcemap: false }
  };

That's all it took to get it work. You can even pass through an empty object and it will work. Though I just started using it so I can't say if things will break or not when using more complex code. The example given, which is outdated as well as it's using Gulp 3, is not working anymore. I deleted terser because I don't use it, but using terser like this will also not work.

import rollupStream from '@rollup/stream';
import gulp from 'gulp';
import terser from 'gulp-terser';
import source from 'vinyl-source-stream';

gulp.task('rollup', () => {
  const options = { input: 'src/index.js' };
  return rollupStream(options)
    .pipe(source('bundle.js'))
    .pipe(terser({ keep_fnames: true, mangle: false }))
    .pipe(gulp.dest('dist'));
});

While I'm at it the example to use sourcemaps doesn't work as well because of this:

.pipe(sourcemaps.init({ loadMaps: true }))

You need a existing sourcemap or this task fails. Since this is a simple example to set things up maybe it would be better to leave the { loadMaps: true } out of this.

MiguelDebruyne avatar Apr 17 '24 11:04 MiguelDebruyne