Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Fix a couple of issues with the web build, caused by CLI changes #81

Conversation

AtkinsSJ
Copy link
Contributor

Avoid including PathCommandProvider and its dependencies in the web build, because they're useless there, and they try to include some binary files that make rollup upset.

Also redo the changes originally in #79 because we can read ctx.platform.name in most places, and that makes the check clearer.

This is only usable in a native terminal. Including it also makes rollup
upset about having to include a binary file from the node-pty library.

There is a small hack here: rollup will automatically include anything
that's imported, but splitting the imported path into two strings
concatenated is enough to fool it into ignoring the file.
`process` only exists when running in Node. Notably, `if (process)` is
still a ReferenceError, so the existing check in readline.js needs
modifying too. Unfortunately we don't have access to the platform name
there, so we just check if `process` exists.
@@ -83,10 +82,15 @@ export const launchPuterShell = async (ctx) => {
await sdkv2.setAPIOrigin(source_without_trailing_slash);
}

// PathCommandProvider is only compatible with node.js for now
// HACK: The import path is split to fool rollup into not including it.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The fact that this works is hilarious, and now I wonder if webpack or any of the other bundlers do actual AST parsing to handle this (or perhaps fail the same way).

Although, for the moment... 👍 this is a feature rather than a bug - thanks Rollup!

@KernelDeimos KernelDeimos merged commit 6ac511e into HeyPuter:trunk Apr 12, 2024
3 checks passed
@AtkinsSJ AtkinsSJ deleted the fix-browser-build-after-path-command-provider branch April 13, 2024 13:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants