Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build tasks: Namespace tasks for import into workspaces #3404

Merged
merged 2 commits into from
Mar 23, 2023

Conversation

colinrotherham
Copy link
Contributor

@colinrotherham colinrotherham commented Mar 23, 2023

This PR exports all our build tools as groups:

  1. Assets (writing to disk, JSDoc types)
  2. Browser (download, launch, screenshots)
  3. Configs (writing to JSON)
  4. Files (delete, copy, versioning)
  5. npm (running npm scripts from JS)
  6. Scripts (compiling JS)
  7. Styles (compiling Sass)

This lets us reuse tasks in the Review app to support:

Before

Each task was a separate import

import { clean } from './tasks/clean.mjs'
import { compileConfig } from './tasks/compile-configs.mjs'
import { compileJavaScripts } from './tasks/compile-javascripts.mjs'
import { compileStylesheets } from './tasks/compile-stylesheets.mjs'
import { version } from './tasks/file.mjs'
import { copyAssets, copyFiles } from './tasks/gulp/copy-to-destination.mjs'
import { watch } from './tasks/gulp/watch.mjs'
import { npmScriptTask } from './tasks/run.mjs'

// Compile GOV.UK Frontend JavaScript (AMD modules)
compileJavaScripts('**/!(*.test).mjs', {
  srcPath: join(paths.src, 'govuk'),
  destPath: join(paths.package, 'govuk'),

  filePath (file) {
    return join(file.dir, `${file.name}.js`)
  }
}),

After

Each task is now part of a namespace

import { browser, files, scripts, styles, npm } from './tasks/index.mjs'

// Compile GOV.UK Frontend JavaScript (AMD modules)
scripts.compile('**/!(*.test).mjs', {
  srcPath: join(paths.src, 'govuk'),
  destPath: join(paths.package, 'govuk'),

  filePath (file) {
    return join(file.dir, `${file.name}.js`)
  }
}),

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3404 March 23, 2023 10:58 Inactive
Base automatically changed from build-tasks-gulpfile-tasks-browser to main March 23, 2023 12:39
import { compileStylesheets } from './tasks/compile-stylesheets.mjs'
import { watch } from './tasks/gulp/watch.mjs'
import { npmScriptTask } from './tasks/run.mjs'
import { browser, files, scripts, styles, npm } from './tasks/index.mjs'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question This is the only file that does a named import from index.mjs, I think. Why are the actual tasks not imporing from index.mjs (for consistency both of method and names)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just to avoid potential circular dependency issues in future. Happy to change it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How's this? 712fa61

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3404 March 23, 2023 14:59 Inactive
@colinrotherham colinrotherham merged commit 6bc43fd into main Mar 23, 2023
@colinrotherham colinrotherham deleted the build-tasks-gulpfile-tasks-namespace branch March 23, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants