-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Refactor the build scripts #11787
Refactor the build scripts #11787
Conversation
6ae7b20
to
680f55f
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.
Nice tidy-ups. LGTM
scripts/rollup/build.js
Outdated
syncReactNative, | ||
syncReactNativeRT, | ||
syncReactNativeCS, | ||
} = require('./sync').syncReactDom; | ||
const Packaging = require('./packaging'); |
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.
Can we also deconstruct this object rather than using Packaging
?
I wanted to keep I'll do the same for |
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 just skimmed this really, but it looks good.
if (error.code) { | ||
console.error( | ||
`\x1b[31m-- ${error.code}${error.plugin ? ` (${error.plugin})` : ''} --` | ||
console.log(`${chalk.bgRed.black(' OH NOES! ')} ${logKey}\n`); |
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.
nit: console.error
?
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.
There's a further console.error too so I guess it doesn't matter? The diff makes it look like I replaced one with the other, but I just added an additional one.
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.
To be honest I'm not even sure what the difference on Node is 😅
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 think the only difference is that one outputs to stderr
and the other to stdout
. I don't think it actually matters in this case. 😁
return; | ||
} | ||
console.error( | ||
`\x1b[31m-- ${error.code}${error.plugin ? ` (${error.plugin})` : ''} --` |
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.
Why not use chalk.red()
?
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.
Copy paste of existing code, didn't look into how it works.
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.
Gotcha. Should be identical to chalk.red('string')
} | ||
return asyncMkDirP(path.dirname(to)).then( | ||
() => | ||
new Promise((resolve, reject) => { |
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.
Possible follow-up: We could remove this new Promise
boilerplate here and below using Promise.denodeify
This might be a bit hard to review since a few things moved around.
The code that produces the bundles is exactly the same (just split into a few methods).
This mostly changes the code that copies folders and shims:
process.exit()
all over the place, and instead use the normal try/catch flow.asyncCopyTo
function to do that automatically.Note I mostly rewrote the folder moving file from scratch.
I found it easier than refactoring the old one.