Skip to content

Use go.mod ignore directive instead of postinstall #1585

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

Merged
merged 2 commits into from
Aug 14, 2025

Conversation

jakebailey
Copy link
Member

Before 1.25, we needed a postinstall to force Go to ignore node_modules. Now, we can just stick it in go.mod.

This also means we can now drop the _ prefix on the dirs, but it's probably too late to change that.

@Copilot Copilot AI review requested due to automatic review settings August 14, 2025 20:46
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes the project's Go module configuration by replacing a workaround for ignoring directories with the native go.mod ignore directive, available since Go 1.25.

  • Removes the postinstall script that manually created a go.mod file in node_modules to prevent Go from scanning it
  • Adds an ignore directive to go.mod that explicitly lists directories Go should ignore during module operations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
package.json Removes the postinstall script that was creating the Go workaround
go.mod Adds ignore directive listing directories to exclude from Go module operations
Herebyfile.mjs Removes the postinstall task implementation that wrote go.mod to node_modules

go.mod Outdated
@@ -28,3 +28,12 @@ tool (
golang.org/x/tools/cmd/stringer
mvdan.cc/gofumpt
)

ignore (
node_modules
Copy link
Member Author

@jakebailey jakebailey Aug 14, 2025

Choose a reason for hiding this comment

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

When specified without ./, this means "ignore node_modules at any level", which I think is correct in general.

@jakebailey jakebailey added this pull request to the merge queue Aug 14, 2025
Merged via the queue into main with commit 1370201 Aug 14, 2025
22 checks passed
@jakebailey jakebailey deleted the jabaile/go-mod-ignore branch August 14, 2025 21:30
andrewbranch pushed a commit to andrewbranch/typescript-go that referenced this pull request Aug 18, 2025
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