Skip to content

build: Detect vendored js package and return error. #572

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
Jan 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func importWithSrcDir(path string, srcDir string, mode build.ImportMode, install
return nil, err
}

// TODO: Resolve issue #415 and remove this temporary workaround.
if strings.HasSuffix(pkg.ImportPath, "/vendor/github.com/gopherjs/gopherjs/js") {
Copy link
Member

Choose a reason for hiding this comment

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

Does this condition work? path == "github.com/gopherjs/gopherjs/js" && pkg.ImportPath != path

Copy link
Member Author

@dmitshur dmitshur Jan 13, 2017

Choose a reason for hiding this comment

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

I know pkg.ImportPath will always be an absolute import path, but I'm not sure about path. It might be relative. E.g., consider:

cd $GOPATH/src/github.com/gopherjs/gopherjs
gopherjs install ./js

And:

pkg, err := buildContext.Import(path, srcDir, mode)

Is there some issue with the current approach, or do you dislike it because of a string comparison?

I think this is the canonical way to detect vendored packages, but I could be wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, path might be relative in the case you mentioned, but I don't think that case is relevant here. Still, on second thought I think your solution is also good. Let's merge.

return nil, fmt.Errorf("vendoring github.com/gopherjs/gopherjs/js package is not supported, see https://github.com/gopherjs/gopherjs/issues/415")
}

switch path {
case "runtime":
pkg.GoFiles = []string{"error.go"}
Expand Down