-
Notifications
You must be signed in to change notification settings - Fork 339
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
Split config, lib and tasks into npm packages #3399
Conversation
aed4bf1
to
8105618
Compare
8105618
to
b93cc04
Compare
09453b3
to
f9c4970
Compare
b93cc04
to
f144713
Compare
f144713
to
ab92da1
Compare
edeb6d7
to
a8b8cd6
Compare
ab92da1
to
b596c2d
Compare
a8b8cd6
to
3959731
Compare
b596c2d
to
3d1120b
Compare
b5ede3e
to
7e7840b
Compare
3d1120b
to
0cb66d3
Compare
0cb66d3
to
d39b44f
Compare
41dcecd
to
c43cdbc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Halfway through and looking nice so far, only one major comment 😊 I'll carry on tomorrow morning (note to self: just gone through "Add govuk-frontend-lib helpers package export").
config/jest/browser/download.mjs
Outdated
/** | ||
* Puppeteer browser downloader | ||
*/ | ||
export async function download () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that this has moved from the browser
tasks thanks to the reorganising 😍
lib/index.js
Outdated
const helpers = require('./helpers') | ||
|
||
/** | ||
* Shared library | ||
*/ | ||
module.exports = { | ||
helpers | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue I think this and the helpers/index.js
file get in the way more than they help the usage of the lib
workspace. Instead of a single import for reaching a specific helper, now we need two instructions: first to import govuk-frontend-lib
then to destructure helpers.xxx
. I think it'd be simpler to just import directly from govuk-frontend-lib/helpers/xxx.js
instead (that reorganisation is super neat), even if it means a little search and replace if we decide to move things inside lib
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep totally agree, there's a later commit that separated "helpers" from "lib" so we could flatten this
I'm happy with destructuring though as it's similar to const { dirname, join } = require('path')
But if we want to avoid it we have some options:
Namespace-style objects
import { files } from 'govuk-frontend-lib'
files.getComponentsData() // versus getComponentsData()
files.getDirectories() // versus getDirectories()
files.getFullPageExamples() // versus getFullPageExamples()
Named package exports
import { getComponentsData, getDirectories, getFullPageExamples } from 'govuk-frontend-lib/files'
getComponentsData()
getDirectories()
getFullPageExamples()
Let me know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replied on the main thread of comments 😄
Move to workspace makes imports so much tidier without the
Documentation wise, would it be worth having a little README file in each workspace to complement the |
@romaricpascal Brill, I'll add those named entries Do you want READMEs as a blocker for this PR or something we can improve later? Using |
I wasn't super strongly against We can add READMEs later, I think, but a line in |
aa710bc
to
6304ca1
Compare
@romaricpascal I've added commit 7dbff83 for subpath package exports Let me know if you're happy with the application-architecture.md edits Thanks 😊 |
For example, test and development packages were being deployed into our Review app Heroku `node_modules`
Adds package `chokidar` to the Review app as it’s required for Nunjucks watch mode
6304ca1
to
7dbff83
Compare
Was nice to use `URLSearchParams` (coming to Express in future) but the community types don’t expect that
Running `npm run build:types` (optional) will now check the review app
Include "Review app" in `npm run build:types` check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks for the amends! 🙌🏻 ⛵
This PR partially implements:
Where each package directory is set up with:
import { npm } from 'govuk-frontend-tasks'
To confirm everything works correctly this branch builds on:
Before
Everything at project level
After
Some dependencies (app, config, lib, tasks) moved to
./shared