Skip to content

Commit

Permalink
Allow JavaScript compilation to restart after gulp dev errors
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Nov 28, 2022
1 parent 656ac5c commit 5944234
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tasks/gulp/compile-assets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,20 @@ compileJavaScripts.displayName = 'compile:js'
*/
function compileJavaScript (stream, moduleName) {
return stream
.pipe(plumber(function (cause) {
const error = new PluginError('compile:js', cause)
console.error(error.toString())

// Gulp continue (watch)
if (isDev) {
return this.emit('end')
}

// Gulp exit with error
return stream.emit('error', error)
}))

// Compile JavaScript ESM to CommonJS
.pipe(rollup({
// Used to set the `window` global and UMD/AMD export name
// Component JavaScript is given a unique name to aid individual imports, e.g GOVUKFrontend.Accordion
Expand All @@ -160,6 +174,8 @@ function compileJavaScript (stream, moduleName) {
ie8: true
})))

.pipe(plumber.stop())

// Rename
.pipe(gulpif(isDist,
rename({
Expand Down

0 comments on commit 5944234

Please sign in to comment.