-
Notifications
You must be signed in to change notification settings - Fork 423
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
Have actual functioning example in readme #1321
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1321 +/- ##
==========================================
- Coverage 69.30% 69.24% -0.06%
==========================================
Files 59 59
Lines 5082 5089 +7
Branches 1069 1072 +3
==========================================
+ Hits 3522 3524 +2
- Misses 1533 1538 +5
Partials 27 27 ☔ View full report in Codecov by Sentry. |
Huh. I have some questions
I guess if I'm going forward with path to include Book Reader only by iframe -- I'm bothered less by just blindly copying and pasting what you suggest here, since it will not effect the rest of my app. So if the answers to some of this are not at your fingertips, so be it! But I was curious to ask, I like to try to understand what I'm copy pasting and what it's doing. |
Thanks for the review @jrochkind !
|
Thank you! |
And, oh, re unpkg.com, it's not that I actually want to use local copies included with BookReader. Rather, instead of doing (eg) I would like to add to my local package.json, This makes it easier for me to manage all my dependencies, scan them for known vulnerabilities in certain versions, upgrade them, etc. i don't really want to use versions that are bundled with bookreader though, and I don't plan to have a local copy of bookreader, right! On the other hand, if these are kind of dependencies of bookreader, but bookreader doesn't actually specify them in it's own package.json, so it's hard to keep track of what versions might be compatible... I guess I have that problem either way, even with the |
Ah yes, the current bookreader flow bundles its dependencies; the use case being making it easy for folks who might not have their own build step. We have a line item on our roadmap this year to generate es6 compatible modules of bookreader; that'll enable your usecase where you want to run things through your own bundler. |
I guess I probably CAN list the dependencies through my own bundler on my own now, instead of using unpkg.com -- I just need to keep track of version compatibility myself, either way in fact. Or maybe this won't work? I may experiment with it! With the earlier approach from the README before this PR -- I was succesfully setting it up as an ES6 module already! You do of course already express some dependencies in your own package.json. Maybe just not the "optional" ones like polyfills etc? Lines 28 to 40 in 2d19d55
I am still curious what you are actually doing in production at archive.org itself, although maybe it doesn't exactly transfer being the main authors/use case of the reader who are responsible for determining version compatibility yourself in the first place! OK, I think I just to experiment at this point. Although there's something to be said for just doing it exactly the way you suggest and have tested -- especially if I'm including via |
Can you give an example of what your es6 But yeah, for experimenting, I think either will work! We need to tighten up this flow on our end, too. If you're curious, on prod we do something like this: await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]/BookReader/BookReader.js');
await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]/BookReader/plugins/plugin.search.js');
await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]/BookReader/plugins/plugin.tts.js');
await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]/BookReader/plugins/plugin.url.js');
await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]/BookReader/plugins/plugin.autoplay.js');
await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]/BookReader/plugins/plugin.resume.js');
await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]/BookReader/plugins/plugin.archive_analytics.js');
await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]/BookReader/plugins/plugin.chapters.js');
await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]/BookReader/plugins/plugin.text_selection.js');
// load the web component
await import('{{INTERNAL_ESM_SERVER}}/@internetarchive/[email protected]');
// other init code similar to the above |
^ And this code runs through a bundler on our production side (there it's esbuild). So we have the same bloating issue, which we need to resolve. |
Those dynamic imports with in my original proof of concept where I wasn't using the custom element, but just setting up the
So I think that is along the same lines of what you are importing? And then: var br = new BookReader(options);
// Let's go!
br.init(); You can see that version of proof of concept code here: https://github.com/sciencehistory/scihist_digicoll/blob/b1d109a2aaf5f29eea42fc3fc7d29211be78b2ef/app/frontend/entrypoints/ia_book_reader.js That also demonstrates my current custom |
OK, separetely... with the The earlier This new example... it's also not clear to me... I haven't yet tried to exec it to see if it's actually working, I guess I probably should. The previous README example I just had a div container, and mentioned that div container id in the In this new way of doing things, how is this |
OK, I'm trying to get a version using the custom element working integrated into my app -- it is unfortunately giving me a lot more trouble than the approach outlined in this README (and most of the included examples) previous to this PR! Original question answered about
|
Ahhh I see, there was a magic default! I'll update the example. It should be: new BookReader({
el: '#BookReader',
....
})
Hmm I didn't test this code on safari! Let me give it a test there. Oh and I fixed that metadata error you found in the latest release, so change to Yep your setup looks perfectly reasonable, I'll update the example to include two versions; one with HTML and one with esm like yours does 👍 |
Oh and about the CSS yeah I need to untangle what's happening there :/ There are way too many variables! :P |
polyfill.io is insecure
This example is so convoluted! We need to improve the setup flow. But this is the currently accurate setup :/