1

I have recently migrated from gulp 3 to gulp 4 in SPFx 1.13.1 project. Previously I had SPFx 1.10 and gulp 3.9.1 version. After migration when I did run Yarn dist I got an error because I was using below task:

gulp.task('dist', gulpSequence('clean', 'bundle', 'package-solution'));

And I got to know that gulpSequence is deprecated. So, now I am using below task:

gulp.task('dist', gulp.series('clean', 'bundle', 'package-solution'));

And now I am getting below error:

AssertionError: Task never defined: clean

Could someone help me to resolve this error, not able to understand how should I fix.

Update

I have got below info from gulp official documentation but did not understand how to solve for default gulp tasks.

Forward references A forward reference is when you compose tasks, using string references, that haven't been registered yet. This was a common practice in older versions, but this feature was removed to achieve faster task runtime and promote the use of named functions.

In newer versions, you'll get an error, with the message "Task never defined", if you try to use forward references. You may experience this when trying to use exports for your task registration and composing tasks by string. In this situation, use named functions instead of string references.

During migration, you may need to use the forward reference registry. This will add an extra closure to every task reference and dramatically slow down your build. Don't rely on this fix for very long.

Update

For workaround I have used below:

const FwdRef = require('undertaker-forward-reference');
gulp.registry(new FwdRef);
gulp.task('dist', gulp.series('clean','bundle','package-solution'));

It is actually starting the tasks but after completion of clean task, it is throwing below error:

Did you forget to signal async completion?

Please provide your help to resolve this. Let me know if you need any other info.

1 Answer 1

2

I'm having the exact same problem. Have you found any solution?

This is my workaround right now:

dist script in package.json

I added "dist": "gulp clean --ship && gulp bundle --ship && gulp package-solution --ship" to the scripts in my package.json and use npm run-script dist to run the three commands sequent

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.