GMOD / jbrowse

JBrowse 1, a full-featured genome browser built with JavaScript and HTML5. For JBrowse 2, see https://github.com/GMOD/jbrowse-components.
http://jbrowse.org
Other
461 stars 199 forks source link

Make a JBrowse entry point to allow manually calling the Browser contructor #1094

Closed cmdcolin closed 6 years ago

cmdcolin commented 6 years ago

It was previously that JBrowse's Browser constructor could be called manually. Wrapping the constructor up into src/JBrowse/main was our approach, but it could be made available again

import * as jbrowse from @gmod/jbrowse
var browser = new jbrowse()

It was brainstormed this way at GCCBOSC for Galaxy visualization templates to make this available again CC @dannon

potentially could be done slightly differently but this was the idea

cmdcolin commented 6 years ago

I thought maybe just adding a new entrypoint might help with this but I'm getting an error. Example

% git diff HEAD
diff --git a/src/JBrowse/standalone.js b/src/JBrowse/standalone.js
new file mode 100644
index 0000000..560ea69
--- /dev/null
+++ b/src/JBrowse/standalone.js
@@ -0,0 +1,6 @@
+import 'babel-polyfill'
+import 'css!../../css/genome.scss';
+
+import Browser from 'JBrowse/Browser';
+
+window.Browser = Browser;
diff --git a/webpack.config.js b/webpack.config.js
index e5762e7..4b1adc3 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -28,6 +28,7 @@ const AUTOPREFIXER_BROWSERS = [
 var webpackConf = {
     entry: {
         main: "src/JBrowse/main",
+        browser: "src/JBrowse/standalone"
     },
     plugins: [
         new CleanWebpackPlugin(['dist']),

Then I try using

<script src="dist/browser.bundle.js"></script>
<script>
var JBrowse = new Browser({
    containerID: 'GenomeBrowser'
});
</script>

However it says it can't find JB_json_v1 module. I can't remember if there was something that the main bundle has related to this that this new entry point might not...

rbuels commented 6 years ago

@cmdcolin the main entry point has some weird magic to load all of the modules that are not explicitly loaded by Browser and dependents. i think JB_json_v1 is a config driver, and it's loaded dynamically @cmdcolin you need to put the //!! glob-loader comment in your new entry point that is actually a command to the webpack loader i wrote that just pulls in all the jbrowse modules in the file tree

rbuels commented 6 years ago

if you are working on this, pull it into the current sprint

dannon commented 6 years ago

Nice! Looking forward to checking out the standalone entrypoint for a Galaxy viz.