-
Notifications
You must be signed in to change notification settings - Fork 489
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
Sane buildflow #703
Sane buildflow #703
Conversation
- Rename src/*.js to src/*.mjs and test/*.js to test/*.spec.mjs - Move misplaced "eslint-plugin-local-rules" to devDependencies - Remove unused reify now that we are fully .mjs - Deprecate load*/download functions and remove associated tests - Remove dead code (private load*() function, isNode/isBrowser...) - Support multiple test runner: ```sh npx mocha npx bun test npx jasmine "**/*.spec.mjs" # may fail on strict compare ```
There are currently 3 local rules: - ban forEach => migrate to a "selector" rule - prevent import loop => did nothing - force import extension => esbuild enforce it already This halves (226 => 139) our NPM dependencies
Use new configuration format since package.json based configuration have been droped
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.
See my comments - other than that, this looks good! Nice work getting rid of all those depedencies and moving towrds a more modern code base.
Props to @ILOVEPIE who did the initial migration. I just reused it PR but stopped before doing legacy-compatibility stuff so he could rebase it PR on it |
So, the point of this is to split my pr into two? |
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.
I can't approve of this in it's current state.
As my brain needed a break from trying to implement CFF2 writing for variable glyphs, I'm currently working on a slim (=really just a couple of lines) plugin API to offer support for standalone CFF1 and PS1/Adobe Type 1 files without bloating the main library. I think I would be on board with removing the load and download functions directly in 2.0.0 without prior depreciation notice if we were to offer a "browserhelper" and "nodehelper" plugin at the same time, references in a console message when trying to call the functions. The browserhelper could also provide the functionality for adding a preview of the font via CSS That way, all that users had to do would be to add or import another small file delivered together with our lib in order to keep the functionality. What do you guys think? |
for the load/download function, a simple line in the "usage" chapter of the readme would suffice as it is just demonstration of how user can integrate opentype.js in they environment. but I agree for a separation of concern This is what jasmine is doing (jasmine/jasmine-core) |
Hey, @yne can we get this rebased on the current head so that it can be reviewed and merged if it's ok? |
sure, I'll ping you once I get back home (~ end of week) |
@ILOVEPIE It is in fact, already rebased on master. So there was not much to do So instead I compiled opentype.mjs as binary using QuickJS and the following import { parse } from "../src/opentype.mjs";
import * as std from 'std';
const [_, path = null, opt = '{lowMemory:false}'] = scriptArgs;
function readFile(path) {
const rh = std.open(path, "rb");
rh.seek(0, std.SEEK_END);
const sz = rh.tell();
const ab = new ArrayBuffer(sz);
rh.seek();
rh.read(ab, 0, sz);
rh.close();
return ab;
}
try {
if (!path) throw ("USAGE:\n\topentype FILE [OPT_JSON]");
const font = parse(readFile(path), std.parseExtJSON(opt));
console.log(JSON.stringify(font.tables, null, '\t'));
} catch (e) {
console.log(e.stack || e)
} Then strip-compiled it with:
Now I can parse our 24 OTF test file and get they
Here is the binary opentype.linux_x64.gz (I had to add a fake .gz extension to bypass the upload file whitelist) maybe we could distribute opentype.js as standalone binary (but I don't see much use case except dumping the OTF as JSON for JQ post-processing) |
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.
Looks good to me.
We can merge if @Connum is satisfied with the current justifications |
Description
Based on existing work done by @ILOVEPIE in #693 this PR migrate to a sane build pipeline (which is urgent) while leaving any compatibility-related change to #693 (which is nice, but less urgent).
src/*.js
tosrc/*.mjs
andtest/*.js
totest/*.spec.mjs
npm i
BONUS: This PR also cleanup our ESLint rules:
Tip
This halves (243 => 144) our NPM dependencies
Motivation and Context
Lower our attack surface by half, while keeping the backward-compatibility improvment in #693
How Has This Been Tested?
Types of changes
Checklist:
npm run test
and all tests passed green (including code styling checks).