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: make rollup generate a depfile for the bundle build #1028

Merged
merged 1 commit into from
Oct 20, 2018

Conversation

piscisaureus
Copy link
Member

No description provided.

@piscisaureus piscisaureus force-pushed the rollupdeps branch 10 times, most recently from 4058fe2 to 15411cf Compare October 20, 2018 01:08
@piscisaureus piscisaureus requested a review from ry October 20, 2018 01:14
const typescriptPath = path.resolve(
__dirname,
"third_party/node_modules/typescript/lib/typescript.js"
);
Copy link
Member

Choose a reason for hiding this comment

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

Nice. That's cleaner.

Copy link
Member

@ry ry left a 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 })
);
Copy link
Member

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?

Copy link
Member Author

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)) {
Copy link
Member

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));
Copy link
Member

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.

Copy link
Member Author

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, "/");
}
Copy link
Member

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

@piscisaureus piscisaureus merged commit 3a6b2f3 into denoland:master Oct 20, 2018
@piscisaureus piscisaureus deleted the rollupdeps branch October 20, 2018 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants