-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
feat(build): add standalone and peer builds #85
Conversation
Linting fails because @typescript-eslint/member-ordering rule doesn't work well, disabled through #93. |
Also ditches rollup-plugin-babel-minify in favor of directly configuring babel plugin as the former doesn't work with core-js 3.
Hi @mojoaxel, do you have any plans to review this? I need to update to core-js 3 to resolve #57. This already uses core-js 3 so merging this would save me some work. Plus I could rewrite the build process this way everywhere to also resolve visjs/vis-timeline#67. |
To be honest, I'm a little overwhelmed. I have problems fully understanding this PR and all the effects it may have.
|
import { DataSet } from 'vis-data/dist/esm.peer.js'
import { Network } from 'vis-network/dist/esm.peer.js'
import { Graph3d } from 'vis-graph3d/dist/esm.peer.js' With package prefixes it would work too of course, no problem there, it just seems a bit redundant to me: import { DataSet } from 'vis-data/dist/vis-data.esm.peer.js'
import { Network } from 'vis-network/dist/vis-network.esm.peer.js'
import { Graph3d } from 'vis-graph3d/dist/vis-graph3d.esm.peer.js' Although this would maybe be a bit easier for people who copy paste these files into their projects as they wouldn't conflict with each other.
|
https://github.com/visjs/vis-network/blob/7c758785819f12905ae0512e10243ef2763fd0e1/lib/header.js uses moment.js only to create header. Maybe we just drop it and create string UTC date inline? |
The question isn't how to replace Moment in header.js, that's not part of runtime, that's only part of build process. The question is whether we should continue bundling and exporting Moment for backwards compatibility or release a breaking change without it. |
@Thomaash For me the new visjs split by modules looks like completely new and I expect that it can be incompatible with the old vis.js |
If we haven't released any version of Vis Network yet this would be a valid argument. However now it's not about compatibility with the original Vis, it's about compatibility with the Vis Network versions we've already released. |
To prevent this we created vis-charts. The idea was to have something like a plug&play replacement for people who have no idea what they are actually doing. |
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.
Im not sure if I stayed it before. But I'm not a big fan of this generic filename. It's really hard to debug files that are just calles "esm.js" or "esm.min.js". Please add the a prefix e.g. "vis-timeline.esm.min.js" to all files in the future.
Here is an example of the problem i'm just having in IE11:
Yeah/ THis is really bad thing. It's like |
My idea was something like: import { Network } from 'vis-network/peer.esm' This will give you: import { Network } from 'vis-network/vis-network.peer.esm' Seems pretty idiotic from user's point of view. On the other hand opening dev tools and seeing some mysterious esm.js or whatnot sucks. However this is only a problem if source maps fail as source maps would give you the actual source file it came from. Atop of that you can get the full path (at least in Chrome but this seems like an of course thing to me) from the tooltip of the tab and in the sidebar (unless you close it of course). Not ideal but still there. We could make this a breaking change and have the peer build default. This would import directly from Another variation is having both. With the name of the library for use directly in browsers and without it for use with bundlers. Though it's questionable whether people would follow this pattern or just get confused on what is the difference between these identical files. |
Okay so the examples are in place, the docs are updated and I tested it in vis-charts (it works 🎉, we no longer have to build Network from source files). So @mojoaxel and @yotamberk this is ready for review and if you won't find any bugs I'll start preparing this for the other packages. |
This ensures that all dependencies match our browser list.
Thanks @Thomaash for your work here! This is one of the biggest changes we had in since splitting up the library and I really would like to ask @yotamberk and the other @visjs/maintainer to think about if this is the future we want to go with the visjs libraries, During the almende/vis times we basically had ONE single JS file and one CSS file that the user could add to his HTML. If this PR gets merged we would have the following: I see that there may be use-cases for every of these bundles but I'm not sure if this is practical and the right way to go. But I'm also not an expert or something... |
Well to put it shortly:
All exist in UMD and ESM versions, have accompanying d.ts entry files ( |
This greatly increases compatibility as Array.prototype.flatMap is quite new and only recently supported by Node.
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 still don'z like this change. It looks to me like it over-complicates thinks and I'm sure it's making it even harder to use this library for normal users.
@Thomaash Can you point to any other project who follow this approach of supporting multible bundles?
Anyway I see no other way to solve the bundling issues other than adding the sources to the distributed package. I don't want to stand in the way of progress so here is my approval!
For example Vue.js has several variants in it's package https://unpkg.com/browse/vue@2.6.10/dist/. |
I had to merge the changes from the master (there was a lot of it). |
🎉 This PR is included in version 6.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
We need the same data set to be used in all modules. The way it is now is disfunctional for multiple modules used at the same time. For example in UMD the network data set will be overwritten by the timeline data set causing network to not recognize passed data sets as data sets and throw an error (this is simply broken at the moment, no way around this). In ESM the bundled data set is used and the user has to take great care to use the network data set for network and the timeline data set for timeline etc. Data set from vis-data package won't work anywhere. The same applies to data view.
The original files including module and main props in package.json are kept for backwards compatibility (they work just fine when only one module is used on it's own). However maybe it would be better to make this a breaking change to have peer version as default (good for npm packages and multiple module usage) and standalone as a convenience build for single module projects, JSFiddle etc.
To do
Solutions that do not work
module.exports = window.vis.DataSet || require('vis-data').DataSet
Using the source code instead of builds.
Closes #57, closes #97, closes #123, closes #166.