-
Notifications
You must be signed in to change notification settings - Fork 570
Include *.inc.js files in gopherjs build
mode.
#322
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
This simply copies the same functionality from ImportPackage(). Perhaps it should be factored into a common function.
The code seems to be copied from |
(How) should this change be auto-tested? Perhaps add gopherjs/jsbuiltin to the list of packages auto built/tested (since it includes a *.inc.js file)? Should I also add a build/build_test.go to test my new function, or is unit testing in this sort of case not a priority for this project? |
I've done as much as I know to do with tests. Is there anything else you'd like me to do on this before it's merged? |
@@ -574,6 +575,20 @@ func NewMappingCallback(m *sourcemap.Map, goroot, gopath string) func(generatedL | |||
} | |||
} | |||
|
|||
func jsFilesFromDir(dir string) ([]string, error) { | |||
files, err := ioutil.ReadDir(dir) |
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 just wanted to comment here. I realize it is not a regression since the code contained ioutil.ReadDir(pkg.Dir)
previously.
But this looks like it won't work in environments where direct disk access isn't available (e.g., the Go playground, or when using GopherJS as a library to compile in-memory without writing to disk).
It'd be outside the scope of this PR, but are there plans to try to make this operate/support virtual filesystems and avoid having duplicate code/logic for building with gopherjs-the-binary vs. gopherjs-the-library?
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.
Sure, if there is a need for it then we'll improve it. I haven't checked the playground yet, but I think it should not be affected by this change.
I think it is unlikely that the tests for If we want to keep the current test case, then the directory For now, I would also be okay with just dropping the test and merge the implementation. The |
Dropping tests seems quite reasonable to me, so I'll just remove that commit from the PR. |
Done... I think this is ready for merging then. |
Include *.inc.js files in `gopherjs build` mode.
Is the inclusion of *.inc.js documented anywhere? I didn't realize gopherjs did that, and spent awhile trying to figure out where it came from. |
Yes, see https://github.com/gopherjs/gopherjs/wiki/Bundle-additional-JavaScript-with-Go-packages. |
Thanks! |
This simply copies the same functionality from ImportPackage(). Perhaps it
should be factored into a common function.
This appears to solve bug #306, but causes some test failures, which I will investigate later.