Skip to content

Conversation

@SMotaal
Copy link
Contributor

@SMotaal SMotaal commented Aug 28, 2024

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
  • 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

Recommended read: Cognitive dissonance

@SMotaal SMotaal requested a review from a team as a code owner August 28, 2024 18:29
@SMotaal SMotaal changed the base branch from main to smotaal/test-endoify-vitest-split August 28, 2024 19:23
@SMotaal SMotaal requested review from FUDCo and grypez August 28, 2024 19:25
SMotaal added a commit that referenced this pull request Aug 28, 2024
…es (#39)

This is the first PR to land instead of #37 before #40 and #41:

- Removes extraneous files from `packages/shims/src`
  - For consistency — we will keep forgetting them otherwise
- Adds `typescript` in `devDependencies`
  - For consistency - needed since #34
Base automatically changed from smotaal/test-endoify-vitest-split to main August 28, 2024 21:04
Copy link
Contributor Author

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.

Copy link
Contributor Author

@SMotaal SMotaal Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FUDCo
FUDCo previously approved these changes Aug 28, 2024
Copy link
Contributor

@FUDCo FUDCo left a 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.

Comment on lines 21 to 23
for (const [name, specifier] of Object.entries({
endoify: path.resolve(srcDir, 'endoify.js'),
})) {
Copy link
Contributor

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?

Copy link
Contributor Author

@SMotaal SMotaal Aug 28, 2024

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.

Copy link
Contributor Author

@SMotaal SMotaal Aug 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grypez
grypez previously approved these changes Aug 31, 2024
Copy link
Contributor

@grypez grypez left a 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.

@SMotaal SMotaal dismissed stale reviews from grypez and FUDCo via a4b4357 August 31, 2024 18:02
@SMotaal SMotaal requested a review from grypez August 31, 2024 18:05
@SMotaal SMotaal requested a review from FUDCo August 31, 2024 18:41
@SMotaal SMotaal enabled auto-merge (squash) September 2, 2024 15:50
@SMotaal SMotaal disabled auto-merge September 3, 2024 10:03
@SMotaal SMotaal enabled auto-merge (squash) September 3, 2024 10:03
Copy link
Contributor

@grypez grypez left a 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.

@SMotaal SMotaal merged commit 1370add into main Sep 3, 2024
@SMotaal SMotaal deleted the smotaal/test-endoify-vitest-split-shims branch September 3, 2024 13:55
@SMotaal
Copy link
Contributor Author

SMotaal commented Sep 3, 2024

SMotaal added a commit that referenced this pull request Sep 3, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants