Skip to content
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

Fix build #48

Merged
merged 30 commits into from
Sep 19, 2024
Merged

Fix build #48

merged 30 commits into from
Sep 19, 2024

Conversation

JayPanoz
Copy link
Contributor

@JayPanoz JayPanoz commented Sep 10, 2024

This PR should fix the build script for all packages/workspaces in the repository, and make shared models testable again.

It takes care of the following issues:

For consistency, ViteJS is now used across the board and tsc only emits definition types. Note the existing Github Workflow targeting Shared was slightly edited so checks can be passed, it doesn’t handle other packages ATM.

Note Vite will emit a warning because of ReadiumCSS inlined in Navigator but it hasn’t any negative effect:

[WARNING] "@namespace" rules are not supported [unsupported-@namespace]

As a sidenote, to do things properly the fonts’ license that are present in ReadiumCSS should be output with static assets in dist so this is something to keep in mind.

Note: vendor > hypothesis is missing shared types
Emit definition types + module resolution in testapp
Remove exports from packages as they wreak havoc AS-IS
Shared tests needs cjs ext cos type module
Vite’s Library mode can’t export static assets and defaults to Base64. So we currently need a plugin to handle that: vitejs/vite#3295

Note: to do things properly, we should also bundle the fonts’ licenses.
Possibly a review of what and how should be exposed/exported is warranted. But at the moment, it offers a baseline while making packages imports more consistent.
@JayPanoz JayPanoz marked this pull request as ready for review September 12, 2024 15:07
@JayPanoz
Copy link
Contributor Author

OK so I’m not expecting to commit more changes at the moment, and I guess the PR is ready for review – and additions for npm.

Tried to follow package.json recommendations from ViteJS docs but maybe you see a better solution.

@@ -46,7 +46,7 @@ export class FrameComms {
} catch (error) {
this.channelId = mid();
}
this.gc = setInterval(() => {
this.gc = window.setInterval(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Why did you add window (here and other places)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That looked like the easiest way to fix TypeScript complaining of the number type as it thought it could be NodeJS.Timer.

An alternative would be ReturnType<typeof setTimeout> but considering navigator is only intended to be used in browsers, it seemed like a more obvious option. Although I’d prefer to reach some agreement, obviously.

Copy link
Member

Choose a reason for hiding this comment

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

It seems like having gc be of type number makes sense -especially since clearInterval takes a number -and that window. facilitates that. Just my two cents. :)

Copy link
Member

Choose a reason for hiding this comment

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

@JayPanoz OK, thanks for explaining. The reason why I ask is technically the frame communications part of the navigator is something that could be re-used in a non-browser scenario (like Thorium's Node.JS) to communicate with an iFrame. But that's a very theoretical case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chocolatkey Thanks for pointing that out. Removed it from navigator-html-injectables and changed the type so that it adapts to ts-config, kept it in navigator.

@JayPanoz
Copy link
Contributor Author

Thanks for your feedback. 🙏

@JayPanoz JayPanoz added this pull request to the merge queue Sep 19, 2024
Merged via the queue into develop with commit 69e8561 Sep 19, 2024
@JayPanoz JayPanoz deleted the vite-build branch September 19, 2024 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants