mcasimir / gulp-rollup

gulp plugin for Rollup ES6 module bundler
MIT License
93 stars 12 forks source link

Multiple module name for multiple entry point #54

Open krimeshu opened 7 years ago

krimeshu commented 7 years ago

With multiple entry point, and use IIFE format output, but I found I can not set multiple module name for each one.

Here is my situation:

gulp.src('./src/js/*.js')
    .pipe(rollup({
        entry: ['module-entry-1.js', 'module-entry-2.js'],
        format: 'iife',
        moduleName: ['moduleEntry1', 'moduleEntry2']
    })
    .pipe(gulp.desc('./desc'));

gulp-rollup just cloned the original options, and reset entry in a map function. Count moduleName be processed in the map function together?

krimeshu commented 7 years ago

55

lemmabit commented 7 years ago

Oh, dear. I had a feeling I should have been taking a more general-purpose approach when I implemented options.separateCaches.

I think I'll address this with a default/override system. Something like this (though the option will likely have some other name which I haven't come up with yet, rather than options.options, which is weird):

gulp.src('./src/js/*.js')
    .pipe(rollup({
        options: [
          {
            entry: 'module-entry-1.js',
            moduleName: 'moduleEntry1'
          },
          {
            entry: 'module-entry-2.js',
            moduleName: 'moduleEntry2'
          }
        ],
        format: 'iife'
    })
    .pipe(gulp.desc('./desc'));

What do you think?

krimeshu commented 7 years ago

It's also a good idea. With this options, we can set more options for each entry file. But it might bring some compatibility issues, if someone use old options with a new version module.

lemmabit commented 7 years ago

Old options won't have the new property, so they'll behave just like they always have.

krimeshu commented 7 years ago

:) That will be nice, hope to see the new solutions soon~