-
Notifications
You must be signed in to change notification settings - Fork 5.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
build: make rollup generate a depfile for the bundle build #1028
Conversation
4058fe2
to
15411cf
Compare
const typescriptPath = path.resolve( | ||
__dirname, | ||
"third_party/node_modules/typescript/lib/typescript.js" | ||
); |
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. That's cleaner.
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.
LGTM - nice improvement!
I'm a little weary of "beforeExit" hooks - but I assume you are too and had to resort to that.
// Save the depfile just before the node process exits. | ||
process.once("beforeExit", () => | ||
writeDepFile({ outputFile, sourceFiles, configFiles, timestamp }) | ||
); |
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.
Is this the only hook to do this sort of thing? What if there's an error in rollup?
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.
🤷♂️ ... node will crash before the depfile gets written I suppose?
load(sourceFile) { | ||
// The 'globals' plugin adds generated files that don't exist on disk. | ||
// Don't add them to the depfile. | ||
if (/^[0-9a-f]{30}$/.test(sourceFile)) { |
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.
ok? odd.
const outputDir = path.dirname(outputFile); | ||
|
||
// Assert that the discovered bundle inputs are files that exist on disk. | ||
sourceFiles.forEach(f => fs.accessSync(f)); |
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.
This throws if the file doesn't exist? I feel like assert(fs.existsSync(f))
would be more readable.
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.
Oh I was so entertained that I finally found a place where fs.access() had some modest utility.
// Use forward slashes on Windows. | ||
if (process.platform === "win32") { | ||
filename = filename.replace(/\\/g, "/"); | ||
} |
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.
This won't be necessary in deno, once #957 is done
15411cf
to
f471cb7
Compare
f471cb7
to
3a6b2f3
Compare
No description provided.