-
Notifications
You must be signed in to change notification settings - Fork 6
refactor(shims, extension): Optimize building and testing workflows #37
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
| if (!process.argv.includes('--without-rollup-transform')) { | ||
| source = endoScriptIdentifierTransformPlugin({ | ||
| scopedRoot: path.resolve(rootDir, '../..'), | ||
| }).transform(source, specifier).code; | ||
| } |
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.
May be better to opt into the transform than to opt out.
| if (!process.argv.includes('--without-rollup-transform')) { | |
| source = endoScriptIdentifierTransformPlugin({ | |
| scopedRoot: path.resolve(rootDir, '../..'), | |
| }).transform(source, specifier).code; | |
| } | |
| if (process.argv.includes('--with-rollup-transform')) { | |
| source = endoScriptIdentifierTransformPlugin({ | |
| scopedRoot: path.resolve(rootDir, '../..'), | |
| }).transform(source, specifier).code; | |
| } |
I'm in favour of keeping it in for now. The transform is deliberate, speedy and includes opt-in options for validation and debugging for if and when they would be needed.
Some of the cons is that this is still an extra step, and that it uses regular expressions instead of AST to rewrite the bundled sources, which I am arguing against myself.
Ideally, we could upstream the replacements to @endojs/endo and avoiding needing this step all together.
Either way, the flag needs to be renamed to --without-rollup-parser-optimizations or --with-rollup-parser-optimizations or something more reflective of what is actually taking place 🤷
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 drafted endojs/endo#2436 today to see if this can be upstreamed!
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.
-
Correct with proper
git rmandgit mvbefore landing to avoid incorrectly aliasing file history!For context: From this diff, it seems that the file operations are being wrongly inferred. Instead, it seems to infer that
apply-lock.mjsis being renamed toendoify.js, and thatendoify.mjsis being deleted. If this lands, the history for those files will likely be misaligned with what we are explicitly intending in this PR.
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.
Nope, history is still not picked up sadly!
Possible solution:
- Remove
apply-lockdown.mjsonmain. - Rebase against main.
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 is wonderful news
…kflows" This reverts commit 26d3c5e.
rekmarks
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.
This PR makes a lot of distinct changes, which makes it difficult to understand. It would benefit from being split into multiple, smaller PRs. Here's one possible way to slice this that would make the changes more digestible:
- Changes specific to
/shims - Changes specific to tests
- Changes specific to building the extension
This is the second PR to land instead of #37 after #39 and before #41: - Renames `endoify.mjs` to `endoify.js` in `packages/{shims,extension}` - For consistency — now all `.mjs` files are renamed to `.js` - Delegates bundling of `endoify.js` to `bundleSource` - For reliability and predictability — avoids making assumptions and resolving paths inside third-party packages - Optionally subs `ZWJ`-prefixed identifiers introduced by `bundleSource` with conforming `CGJ` alternatives - For conformance — makes it possible to [experiment with `rollup`](https://www.smotaal.io/experimental/#/experimental/modules/shim/README.md) until [endojs/endo#2436](endojs/endo#2436) rolls out. - Explicitly imports `./endoify.js` in `packages/shims/src/*.test.ts` - For clarity and flexibility — test files need to be explicit - Configures `vitest` to use `jsdom` with `vmThreads` for `packages/shims` - For consistency and reduced configuration overhead — thanks to @grypez's exploration putting us on this path of least resistance with `vitest`
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 optimizes the building and testing workflows for
endoifyusingvitest.This PR is now split out into:
package.jsonentries #39packages/shims/srctypescriptindevDependenciesendoify.mjstoendoify.jsinpackages/{shims,extension}.mjsfiles are renamed to.jsendoify.jstobundleSourceZWJ-prefixed identifiers introduced bybundleSourcewith conformingCGJalternativesrollupuntil endojs/endo#2436 lands./endoify.jsinpackages/shims/src/*.test.tsvitestto usejsdomwithvmThreadsforpackages/shimsendoify.tsandendoify.test.tstopackages/extension/src./endoified.js./endoify.jsinpackages/extension/src/*.test.tsvitestto usejsdomwithvmThreadsforpackages/extensionscript[src="endoify.ts"]andscript[src="endoify.js"]inpackages/extension/src/*.html