Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Include *.inc.js files consistently #330

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

Closed
wants to merge 2 commits into from
Closed

Conversation

flimzy
Copy link
Member

@flimzy flimzy commented Oct 18, 2015

An alternative proposal to finish fixing #306, in response to comments on #328.

Moving the call to jsFilesFromDir() into Import() doesn't work with the current code layout, as Import() doesn't know anything about the gbuild.Package data structure, only the official Go build.Package structure. So I instead moved it to BuildPackage().

The only (potential) drawback to this, is that it means we include *.inc.js files completely consistently for all call methods. The one place where this causes a change of behavior is when calling gopherjs build <files>. Under the old behavior, executing gopherjs build foo.go would not include foo.inc.js in the final output. Under the new behavior, it will. If the old behavior is important to preserve*, something more clever needs to be done (which I'm willing to tackle myself, too, if it's deemed important).

*The only way I can imagine the old behavior being useful is for testing... someone might want to choose which JS file(s), among many, to include at build time. But I don't know if that was actually the intention, or if this "feature" was unintentional.

@neelance
Copy link
Member

I considered this solution, but I think it breaks architecture too much. Import and ImportDir are meant for gathering all information about a package. Adding the code to BuildPackage adds functionality to the function which does not belong there. It might solve the current problem, but such solutions can hurt in the long term. You can already see right now that it breaks the gopherjs build <files> case and you would need to add a workaround for this case. Those workarounds tend to stack over time and become a burden. That's why I'd rather go for the bigger change and improve Import, which would in fact involve changing its return type.

@flimzy
Copy link
Member Author

flimzy commented Oct 18, 2015

Would you like me to work on that solution? It sounds like you have a pretty good idea of what should happen, so if you have the time to tackle it, no doubt your time spent would be more efficient. But I'm willing to try my hand at it if you want me to, and if it wouldn't actually be a bigger use of your time responding to my changes.

@flimzy flimzy closed this Oct 21, 2015
@flimzy flimzy deleted the incjs branch October 21, 2015 08:21
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