Skip to content

build tags not honored in *.inc.js files #468

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

Open
flimzy opened this issue May 28, 2016 · 4 comments
Open

build tags not honored in *.inc.js files #468

flimzy opened this issue May 28, 2016 · 4 comments
Labels
enhancement gopherjs-tool Related to the gopherjs tool or its build system (but not the compiler itself). NeedsHelp Community contributions are welcome for this feature!

Comments

@flimzy
Copy link
Member

flimzy commented May 28, 2016

My testing indicates that build tags are not honored in *.inc.js files, but they probably should be, to honor upstream functionality documented here:

Constraints may appear in any kind of source file (not just Go), but they must appear near the top of the file, preceded only by blank lines and other line comments.

@flimzy
Copy link
Member Author

flimzy commented Feb 26, 2017

As a work-around, until this issue is resolved, one can achieve similar results with a multiple-package approach. Suppose my package needs to load a *.inc.js file only when the debug flag is present:

// +build debug

package main

import ".../debug"

Then in your debug package, create your main *.go file(s), as well as your *.inc.js file(s).

@dmitshur
Copy link
Member

@flimzy Is that a typo in your comment above, did you mean // +build !debug?

@flimzy
Copy link
Member Author

flimzy commented Feb 28, 2017

I think I meant // +build debug. Thanks for catching my mistake (now updated).

@nevkontakte
Copy link
Member

Go 1.17 added https://pkg.go.dev/go/build/constraint package, which should make implementing this feature fairly straightforward.

func jsFilesFromDir(bctx *build.Context, dir string) ([]JSFile, error) {
would be the right place to add this functionality and should already have all the information necessary.

@nevkontakte nevkontakte added enhancement gopherjs-tool Related to the gopherjs tool or its build system (but not the compiler itself). NeedsHelp Community contributions are welcome for this feature! labels Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement gopherjs-tool Related to the gopherjs tool or its build system (but not the compiler itself). NeedsHelp Community contributions are welcome for this feature!
Projects
None yet
Development

No branches or pull requests

3 participants