-
Notifications
You must be signed in to change notification settings - Fork 570
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
Conversation
@@ -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") { |
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.
Does this condition work? path == "github.com/gopherjs/gopherjs/js" && pkg.ImportPath != path
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 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.
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.
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.
@@ -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") { |
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.
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.
If you look at 42e6459, this solution is effectively taken from our existing code to detect |
This follows #538.
Vendoring
github.com/gopherjs/gopherjs/js
package is not supported, and can cause hard to understand runtime errors. Better catch it earlier and print a clear error message.Helps #569.