-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Find an alternative to Esprima #8056
Comments
It seems |
I think the most sensible thing to do is to make a concrete plan for TypeScript conversion. We won't need esprima after that. |
@joeyparrish totally agree, simple check shows that esprima -> espree is not a trivial transition. We need to make a plan for Typescript (& new build system?) conversion though, otherwise tech debt will become larger. |
Yes, I agree. I want to make a concrete plan, and soon. I will experiment with it to see if I can find a transition plan that allows for something other than "all or nothing" conversion, since it will take some time to rewrite everything. As for the build system, I'm open to suggestions. I have a little experience with TypeScript with eslint & webpack now, but I am not strongly opinionated about the bundler. |
I'm not super oriented in bundlers right now, but instead of webpack I'd consider rspack due to much better performance observed. |
I know you probably haven't reached the planning stage just yet, but I still hope it is okay to provide a few ideas and opinions on the migration :). As shaka-player's code base consists mainly of classes and the Closure Compiler is as far as I know the only bundler and mimifier that is able to properly mimify and treeshake classes, the bundle size will likely go up. It's not the end of the world though, as there are solutions to those problems in the modern JavaScript world. Any class that currently only contains static methods and properties, could be converted to just be a bunch of functions and variables. If you still want them grouped together when you import them into other files, you can just use the namespace object syntax While it might be tempting to use TypeScript's namespaces to recreate the current namespace structure, I would advise against it, as they just get transformed into objects at build time (aka more bloat). Even the TypeScript compiler has switched away from using TypeScript namespaces in their codebase. Please prefer top level exports instead of exporting everything inside one object like you currently do e.g. import * as shaka from 'shaka-player'
window.shaka = shaka It would also be great if shaka-player were more treeshaking friendly, as currently the only was to reduce the size of the bundle is to create a custom build. One obvious example is shaka-player's plugin system, which could be exposed to the library users so they only need to register what they need and the unused plugins (e.g. text parsers) could be treeshaken away. For users that want an easy way to start and don't care about the bundle size too much you could still make the default entry point ( import { registerTextParser, VttTextParser } from 'shaka-player/modular'
registerTextParser('text/vtt', VttTextParser) Alternate example that makes it easier to register a text parser for multiple mime type in one go, by providing arrays of standard mimetypes: import { registerTextParser, VttTextMimeTypes, VttTextParser } from 'shaka-player/modular'
registerTextParser(VttTextMimeTypes, VttTextParser)
// internally VttTextMimeTypes could be written as this:
export const VttTextMimeTypes = ['text/vtt', 'text/vtt; codecs="vtt"','text/vtt; codecs="wvtt"'] These are all just ideas and personal opinions, from someone that welcomes the modernisation of the code base and would love to see it being used as an oportunity to make shaka-player smaller without having to create custom builds, so please do not feel obliged to do any of these things |
Have you read the FAQ and checked for duplicate open issues?
Y
Is your feature request related to a problem? Please describe.
Esprima, the tool we're using during externs generation, is no longer supported. Due to that we are limited in terms of progressing with the codebase, i.e. we are not able to enable more modern JS syntax.
Describe the solution you'd like
Check can we use any of modern alternatives. Most natural seems to be espree which is based on Esprima and provides similar API.
Describe alternatives you've considered
Additional context
Are you planning to send a PR to add it?
The text was updated successfully, but these errors were encountered: