GMOD / jbrowse-plugin-template

Template to quickly start a new JBrowse 2 plugin
https://jbrowse.org/
Apache License 2.0
4 stars 0 forks source link

rollup-plugin-node-globals makes it impossible to use modern js #50

Open abcdw opened 1 month ago

abcdw commented 1 month ago

Describe the bug jbrowse depends on rollup-plugin-node-globals and it have hardcoded ecmascript version: https://github.com/calvinmetcalf/rollup-plugin-node-globals/blob/edbbbbd7c485452a0168b27caa5ad49e58cf3cfe/src/inject/index.js#L59

Thus if you have modern js in your project, it won't build.

To Reproduce

For example add a big int literal in the code jbrowse-plugin-template: -0x8000_0000_0000_0000n.

And try to build the plugin.

Expected behavior

To build successfully.

Screenshots

[!] (plugin at position 6) SyntaxError: Identifier directly after number (1335:18) in /data/abcdw/work/abcdw/jbrowse-plugin-hoot-gwa/src/js-runtime/reflect.js
src/js-runtime/reflect.js (1335:18)

Version:

https://github.com/GMOD/jbrowse-plugin-template/commit/0249180eb48b25ba7c8a1a7e630fe7c958cd7e71

cmdcolin commented 1 month ago

hi there :) i think specifically the jbrowse-plugin-template has this dependency.

here is an example of a plugin i made that does not use the jbrowse-plugin-template rollup approach, it actually uses esbuild https://github.com/GMOD/jbrowse-plugin-protein3d/blob/master/esbuild.mjs

i'm not sure if that approach would be ideal for your approach

we can try to also see if we can make a minimal and modern rollup setup

on a technical level, the only really custom things we do in jbrowse plugins is

a) make a single file bundle (generally umd) b) resolve a bunch of externals (we get the list of re-exports from the @jbrowse/core/ReExport/list) which prevents e.g. the plugin from loading a different version of react and other stuff. this is not strictly required, you can also manually use "jbrequire" to get those externals but the remapping of externals allows you to use plain import statements

cmdcolin commented 1 month ago

(moved issue to the jbrowse-plugin-template repo)

(might need to apply fix to @jbrowse/development-tools in the main repo, but probably best here)