-
Notifications
You must be signed in to change notification settings - Fork 51
use ES6 modules #178
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
base: main
Are you sure you want to change the base?
use ES6 modules #178
Conversation
| import "./variety-common/Answer.js"; | ||
| import "./variety-common/BoardExec.js"; | ||
| import "./variety-common/Encode.js"; | ||
| import "./variety-common/FileData.js"; |
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.
All of these change common in the classmgr. It's likely nicer to do this differently, but it works for now.
| var userlang = pzpr.env.node | ||
| ? process.env.LANG | ||
| var userlang = env.node | ||
| ? "XXX" // process.env.LANG |
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.
This one I have no idea how to fix. There is no process variable when using rollup, which is something which comes from nodejs.
These objects are sometimes "frozen", which raises an error in strict mode: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Read-only
(tried grunt-rollup, but it was... weird)
From 6? That looks ancient.
This changes the
pzprmodule to hang together usingimport ... from ...(the modern way to do imports nowadays, it seems).Previously the
pzprmodule was build by concating all files together, and then use Grunt to uglify the result. Now there is a single/src/pzpr.jswhichimports all required modules. It's converted to something the browser can use viarollup. Thepzpr.jsfile still builds a globalpzprobject, since the UI module andrules.htmlexpect that. The idea is that nothing changes in the final JS file.You can kinda use this directly from nodejs now, but support for the ES6 modules seems iffy.
mochauses theesmmodule which works nicely.notes
All variants must still be ported. I only did 2 of them so far. Until then tests will breakedit: done, and tests passgit.versionstring inpzpr/core.jsyetrollupcan do "chunks", if you prefer smaller files over something huge.deploy
rollupaction a makefile target, but there is a rolllup grunt module, so that could be used instead(I had some troubles with it, will try again later)edit: I tried again and fails. Makefile it is.candlefile doesn't get bundled, so that's an explicit copy to ./dist/ nowES6 modules crash course
Either there are multiple things exported:
Or there is a single thing:
Evaluation
I do think using the ES6 modules is a good goal. It's a nice modernization step. It's unfortunately way too many changes for a single PR. What I can do is break this up in smaller PRs, which would still use some concatenation, and then work towards the state in this PR in a few separate, smaller, steps.