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
base: master
Are you sure you want to change the base?
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.
|
||
let thaiFont; | ||
let bidiThai; | ||
|
||
before(()=> { | ||
beforeEach(()=> { | ||
thaiFont = loadSync('./test/fonts/NotoSansThai-Medium-Testing-v1.ttf'); |
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.
Why do we need to load/parse the font before each test? If it's not being modified and therefore interfering with following tests, this just adds overhead and increases testing runtime.
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.
it allows to use the same codebase on the 3 most popular test runner
yet it has no significant impact on the overall test execution time
https://mochajs.org/#hooks use .before()
/.after()
😢
https://bun.sh/docs/test/lifecycle use .beforeAll()
/.afterAll()
https://jasmine.github.io/api/edge/global use .beforeAll()
/.afterAll()
I could also switch from mocha to bun test
(and save even more NPM dependencies)
npx mocha
npx bun test
npx jasmine "**/*.spec.mjs"
Or just create a wrapper in test/testutil.mjs
with before = before||beforeAll
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.
@@ -84,23 +57,6 @@ describe('opentype.js', function() { | |||
assert.equal(aGlyph.path.commands.length, 14); | |||
}); | |||
|
|||
it('[deprecated] .load() handles a parseBuffer error', function(done) { |
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 thought we agreed that this would still function in 2.0.0 with a warning, and be removed in a subsequent release.
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.
the 2.0.0 is a major release
major release does break things
so if we are brewing the 2.0.0 it make more sense to put the warning now to ease this major transition
test/opentype.spec.mjs
Outdated
@@ -119,7 +75,7 @@ describe('opentype.js', function() { | |||
}); | |||
}); | |||
|
|||
describe('opentype.js on low memory mode', function() { | |||
describe('opentype.mjs on low memory mode', function() { |
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.
Error here, this should still read opentype.js
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) |
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).