-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Convert web/debugger.js
to a *basic* module
#14745
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
Conversation
The various functionality in `web/debugger.js` is currently *indirectly* added to the global scope, since that's how `var` works when it's used outside of any functions/closures. Given how this functionality is being accessed/used, not just in the viewer but also in the API and textLayer, simply converting the entire file to a module isn't trivial[1]. However, we can at least export the `PDFBug`-part properly and then `import` that dynamically in the viewer. Also, to improve the code a little bit, we're now *explicitly* exporting the necessary functionality globally. According to MDN, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility, all the browsers that we now support have dynamic `imports` implementations. --- [1] We could probably pass around references to the necessary functionality, but given how this is being used I'm just not sure it's worth the effort. Also, adding *official* support for these viewer-specific debugging tools in the API feels both unnecessary and unfortunate.
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.241.84.105:8877/e10e55cd5ee0a1b/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/e10e55cd5ee0a1b/output.txt Total script time: 2.57 mins Published |
Nice refactoring; thanks! |
This change is making a test failing in m-c: @Snuffleupagus, could you have a look please ? |
Given the name of the failing test, it seems that you'll need to add an entry for the |
Cool it's an easy fix, thank you. |
The various functionality in
web/debugger.js
is currently indirectly added to the global scope, since that's howvar
works when it's used outside of any functions/closures.Given how this functionality is being accessed/used, not just in the viewer but also in the API and textLayer, simply converting the entire file to a module isn't trivial[1]. However, we can at least export the
PDFBug
-part properly and thenimport
that dynamically in the viewer.Also, to improve the code a little bit, we're now explicitly exporting the necessary functionality globally.
According to MDN, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#browser_compatibility, all the browsers that we now support have dynamic
imports
implementations.[1] We could probably pass around references to the necessary functionality, but given how this is being used I'm just not sure it's worth the effort. Also, adding official support for these viewer-specific debugging tools in the API feels both unnecessary and unfortunate.