-
Notifications
You must be signed in to change notification settings - Fork 0
[WIP] Convert code base to ESM #91
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
Draft
agibson-godaddy
wants to merge
41
commits into
master
Choose a base branch
from
mwc-17961
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
agibson-godaddy
commented
Mar 19, 2025
@@ -37,116 +40,12 @@ if (fs.existsSync(devEnv)) { | |||
// enable forward-referencing tasks, see https://github.com/gulpjs/gulp/issues/1028 | |||
gulp.registry(ForwardReference()) | |||
|
|||
// define default config | |||
let defaults = { |
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.
Config was moved to new, separate file lib/config.js
so that it can now be imported where required, instead of passing it around function parameters.
Note this PR is affected by this: gulpjs/gulp-cli#269 As such, it only works on Node <= v22.11.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: https://godaddy-corp.atlassian.net/browse/MWC-17961
Summary
This PR converts the codebase to ESM. The changes/impacts are:
Require => import
Instead of
const { spawn } = require('child_process')
we'd use this syntax:import { spawn } from 'node:child_process'
So moving from
require
toimport
Exports
module.exports
is no longer a thing, so all instances of that have been changed.Task registration
Although not strictly part of the ESM migration, I also updated our deprecated usage of the gulp
task()
function. See https://gulpjs.com/docs/en/api/taskPreviously we registered a task using
task('my-task-name', functionNameHere
. This is deprecated and the new way to do it is to simply export the function -- e.g.export function functionNameHere
One challenge was how to get our old task names back. Previously we could just specify the task name as a string, which allowed us to use characters like:
copy:build
. But we don't have that same flexibility when exporting a function directly, since a function can't contain some special characters. The way around that is to set thedisplayName
on the thing we're exporting. Example:Without the change, we'd have to run
sake validateReadmeHeaders
, but by setting the display name,sake validate:readme_headers
still works!Task Updates
I tested each of these as I went.
build.js
bump.js
bundle.js
clean.js
compile.js
config.js
copy.js
defacceinate.js
deploy.js
github.js
imagemin.js
lint.js
makepot.js
prerelease.js
prompt.js
scripts.js
shell.js
styles.js
upfw.js
validate.js
watch.js
wc.js
zip.js
QA
Build / zip
sake zip
using a plugin that includes blocks (like a payment gateway)Deployment
To be completed only once the above has been done successfully!
sake deploy
sake deploy
sake deploy
After merge