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

Sitelet debug with npm packages STEP 3 #1408

Open
Jand42 opened this issue May 22, 2024 · 2 comments
Open

Sitelet debug with npm packages STEP 3 #1408

Jand42 opened this issue May 22, 2024 · 2 comments

Comments

@Jand42
Copy link
Member

Jand42 commented May 22, 2024

Last piece needed for working with Sitelets using module-based JS. For local debug mode, for readability and quick iteration, it would be best if one-file-per-class readable .js files are used. However, browsers can't handle npm package imports as is, because it's underdefined (the packages-lock.json file and the node_modules folder are not accessible through the localhost server).

We need to provide either an import map or an integration for a localhost prebundler like Vite.

Jand42 added a commit that referenced this issue Jun 6, 2024
* #1408 write re-exports for non-bundled sitelet mode

* testing with FSharp proj

* fixes

* small fix for root.js addresses
@Jand42
Copy link
Member Author

Jand42 commented Oct 3, 2024

Added a Vite helper in #1410

@Jand42
Copy link
Member Author

Jand42 commented Oct 3, 2024

A proposal:

In OFPC debug mode, WebSharper unpack would create a viteinfo.txt in the Scripts\WebSharper folder containing the full path of the project for identifying it.
Startup would look at launchSettings.json for a setting websharper:ScriptRedirectUrl. (which is the same as ScriptRedirectUrl inside the section websharper)
If found, http://localhost:X/Scripts/WebSharper/viteinfo.txt is checked, if replies and it's our current project, nothing is done.
Otherwise starting up npx vite --port X, preferably with a console window. But we should somehow get the output too, so if port is blocked by something else, we either raise an error or change websharper:ScriptRedirectUrl.
If there is no websharper:ScriptRedirectUrl value found, an random empty port is grabbed (from some range, not to collide with common ports, I'll research this a bit more how ANC does it for example), then this is persisted in launchSettings.json.

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

No branches or pull requests

1 participant