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

Conversation

dmitshur
Copy link
Member

@dmitshur dmitshur commented Jan 12, 2017

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.

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.
@@ -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.

@dmitshur dmitshur changed the title compiler/typesutil: Detect vendored js package and exit. build: Detect vendored js package and return error. Jan 13, 2017
@@ -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.

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.

@dmitshur
Copy link
Member Author

Still, on second thought I think your solution is also good.

If you look at 42e6459, this solution is effectively taken from our existing code to detect js package and vendored versions thereof in IsJsPackage.

@dmitshur dmitshur merged commit 0203db2 into master Jan 13, 2017
@dmitshur dmitshur deleted the detect-vendored-js-pkg branch January 13, 2017 01:51
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