-
Notifications
You must be signed in to change notification settings - Fork 7
refactor(shims): Optimize building and testing #40
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
Conversation
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 file needs to be updated to reflect the $c prefix from as well.
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.
FUDCo
left a comment
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.
On the whole this seems like a lovely cleanup. A couple minor nits that you can change or not as suits you.
packages/shims/scripts/bundle.js
Outdated
| for (const [name, specifier] of Object.entries({ | ||
| endoify: path.resolve(srcDir, 'endoify.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.
This construction seems very weird to me. Why not just assign specifier directly and omit wrapping everything in a loop? Is there some bizarro JS semantics singularity involved here or is this just an artifact of darwinian drift?
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 file is used to bundle things, and initially in my seeking to tease out how to best handle the sources, there were more bundled things.
But, yes, I think it is useful now to refactor this logic into an async function, and remove the for-loop until, and if, it is needed.
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.
grypez
left a comment
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.
"Let endo bundle their own code" makes sense; I think we can strengthen this principle to a guideline for the monorepo w.r.t. trusted headers.
The rollup plugin included is not invoked as a rollup plugin; in bundle.js, it is called directly via its transform method if a command line option is provided. Therefore this PR does not introduce vite / rollup into the TCB.
Changes not explicitly covered in this review are straightforwardly awesome.
Approved.
grypez
left a comment
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.
Approved! Added #44 so we remember to clean up.
|
Note @endojs/endo#2436 landed and soon enough we will be dropping packages/shims/scripts/helpers/rollup-plugin-endo-script-identifier-transform.js |
This is the third PR to land instead of #37 and after #39 and #40: - Adds `endoify.ts` and `endoify.test.ts` to `packages/extension/src` - For clarity — sibling files importing `./endoified.js` - Explicitly imports `./endoify.js` in `packages/extension/src/*.test.ts` - For clarity and flexibility — test files need to be explicit - Configures `vitest` to use `jsdom` with `vmThreads` for `packages/extension` - For consistency and reduced configuration overhead - Adds guards against inlining `script[src="endoify.ts"]` and `script[src="endoify.js"]` in `packages/extension/src/*.html` - For efficacy and efficiency — parsing before vs after a failure makes no difference in speed, only in accuracy --------- Co-authored-by: grypez <143971198+grypez@users.noreply.github.com>
This is the second PR to land instead of #37 after #39 and before #41:
endoify.mjstoendoify.jsinpackages/{shims,extension}.mjsfiles are renamed to.jsendoify.jstobundleSourceZWJ-prefixed identifiers introduced bybundleSourcewith conformingCGJalternativesrollupuntil endojs/endo#2436 rolls out../endoify.jsinpackages/shims/src/*.test.tsvitestto usejsdomwithvmThreadsforpackages/shimsvitestRecommended read: Cognitive dissonance