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

Possible plan for node compatibility etc #37

Open
curiousdannii opened this issue Mar 29, 2020 · 1 comment
Open

Possible plan for node compatibility etc #37

curiousdannii opened this issue Mar 29, 2020 · 1 comment

Comments

@curiousdannii
Copy link
Contributor

Many years ago I sent a PR for node support (#18). I think I've come up with a better plan now.

So the main problem with how the various components are organised at present is that the references to the other components are hardcoded using globals. I think it's much better if each component is a factory function rather than a singleton, so that the framework that uses GlkOte can construct the components in the order it wants, and pass in the references to the other components dynamically.

So like my old PR, I'd like to keep that aspect of it. The differences from the old PR would be:

  • use ES modules rather than CommonJS modules
  • provide a file that would load the components and set them up
  • use Rollup to bundle that file and the component files to produce an output file that would be a drop-in replacement for the current concatenated glkote.js used by Quixe

It should be possible to do this with literally no other changes required for classic Quixe usage, but to then give Parchment/Lectrote/etc the flexible to use the components as they need.

@erkyrath
Copy link
Owner

I went through a process of node compatibility last year. Now every file ends with a line like

try { exports.GlkOte = GlkOte; } catch (ex) {};

This is clunky but it allows Lectrote to load everything in with "require" statements. But then it has to assign all the modules as window globals, because that's how they refer to each other internally.

I agree that ES modules are the way to go. I need to comb through the entire set of projects and shift them over to modules and "require". This is not going to happen this release, though. (I am aiming at a glkote/quixe/lectrote release today or tomorrow.)

Keeping this open for the next major release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants