Closed ghost closed 7 years ago
gulp-rollup isn't allowed to access files that weren't gathered ahead of time and passed down the stream. Your node_modules/
isn't included in your gulp.src
, so gulp-rollup can't see it.
This problem one of my favorite examples of why you should almost never actually use gulp-rollup. gulp-rollup isn't meant to be used just to roll up some files on the filesystem. It's meant for the extremely narrow case where you actually need to roll up some files that don't exist outside of gulp.
You should use rollup-stream, period. gulp-rollup is way more plugin than you need here, and even if you get this working with it, it will just keep giving you grief down the line. If you need multiple entry points, you can do it like this.
I always get "but could not be resolved – treating it as an external dependency" and in the IIFE the import is treated as external variable, even if I use the rollup-plugin-node-resolve.
const rollup = require('gulp-rollup'); const resolve = require('rollup-plugin-node-resolve');
gulp.task('rollup', function () { return gulp.src('_01_src/js/form/*.js') .pipe(rollup({ entry: '_01_src/js/form/controller.js', format: 'iife', plugins: [ resolve({ jsnext: true, main: true, browser: true }) ] }) )
});