gulpjs / gulp

A toolkit to automate & enhance your workflow

Home Page:https://gulpjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option no-sort doesn't seem to work on gulp 5.0.0

tallenglish opened this issue · comments

What were you expecting to happen?

Only changing between gulp v4.0.2 and v5.0.0 (all other plugins stay the same and latest versions).

Issue is only really a problem for JavaScript files where the order of the files being concat is vital for plugins that depend on others - like jQuery needing to be first.

I am using ESM gulpfile, as required by latest gulp-autoprefixer v9.0.0 now.

Using the following to keep the order of input sources unsorted (mainly required for JavaScript dependencies).

What actually happened?

Works as expected for gulp v4.0.2 with "no-sort" option, however array is still sorted when using v5.0.0 with same option.

Please give us a sample of your gulpfile

return gulp.src(src, { "no-sort": true })
	.pipe(gulp_concat(file))
	.pipe....

In this case the src is an array of files similar to the following, and need to be concat in the same order:

const src = [
	"a.js",
	"b.js",
	"c.js",
	"d.js"
];

Only change needed to break is upgrading from gulp v4.0.2 to v5.0.0

Terminal output / screenshots

None

Please provide the following information:

  • OS & version: Debian Linux bookworm (all latest updates)
  • node version (run node -v): 20.11.0
  • npm version (run npm -v): 10.5.1
  • gulp version (run gulp -v): 5.0.0

Additional information

None

I have tried using gulp-order plugin to fix the order in a pipe after gulp.src, however it doesn't seem to work either on v5.0.0, or has no effect at least.

One final note I forgot to mention, the documentation says the option is "nosort" (no dash), I tried that and it didn't work on either v4.0.2 or v5.0.0. I found the dash option from other documentation.

I'm seeing the same. When given an array of ["path/filename.js", ...], the output from gulp.src appears sorted in alphabetical order using the base filename without the leading path.

I never needed the "nosort" option with gulp 4.02. I also tried src options no-sort, nosort, and noSort without success.

To resolve this issue, try this option. Create an array with paths in the order you need, as you wrote above.

const scriptsList = [
	'node_modules/vanilla-lazyload/dist/lazyload.js',
	'node_modules/lightgallery/lightgallery.min.js',
	'app/js/main.js'
]

In order for the gulp-order plugin to work correctly and create a strict order like in an array, you need to specify the names of specific files

return src(scriptsList, { allowEmpty: true })
.pipe(order([
	'lightgallery.min.js',
	'lazyload.js',
	'main.js',
]))

In gulp 5, we no longer use node-glob as our globbing library. I've removed the options that looked exclusive to that library in #2786 and added docs for created an ordered stream in #2788