Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Liam-OShea opened this issue Jan 10, 2022 · 3 comments

Comments

@Liam-OShea
Copy link

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
Copy link
Author

I was able to solve this using the info in a recent issue posted here (thanks @domoritz): #15 (comment)

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.

@shellscape
Copy link
Contributor

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

@MiguelDebruyne
Copy link

MiguelDebruyne commented Apr 17, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants