Skip to content
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

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

Open
abcdw opened this issue Jul 18, 2024 · 2 comments
Open

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

abcdw opened this issue Jul 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@abcdw
Copy link

abcdw commented Jul 18, 2024

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:

0249180

@abcdw abcdw added the bug Something isn't working label Jul 18, 2024
@cmdcolin
Copy link
Contributor

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

  • the good news is that there are alternatives to making plugins than this template
  • the "bad news" is jbrowse-plugin-template itself should get updated to try to avoid the problem you mention though

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 cmdcolin transferred this issue from GMOD/jbrowse-components Jul 19, 2024
@cmdcolin
Copy link
Contributor

cmdcolin commented Jul 19, 2024

(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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants