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

mini repl for svelte2tsx #744

Merged
merged 18 commits into from
Mar 10, 2021
Merged

mini repl for svelte2tsx #744

merged 18 commits into from
Mar 10, 2021

Conversation

pushkine
Copy link
Contributor

@pushkine pushkine commented Jan 7, 2021

Adds a svelte file under svelte2tsx/repl that automatically compiles its content to tsx on dev mode
Adds a debug package script, attaching a debugger to it will inspect the compiling process of the repl directly in the ts source

@pushkine pushkine marked this pull request as draft January 8, 2021 09:06
@pushkine pushkine marked this pull request as ready for review January 8, 2021 11:18
import fs from 'fs';
import path from 'path';

function repl() {
Copy link
Member

Choose a reason for hiding this comment

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

Not quite sure why we need this? Isn't all this handled without Rollup, just through sucrase?

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 part uses rollup watch, so just by having the dev script running in the background it automatically updates the repl results on save. i.e. Everything is instant, just hit ctrl+s on any change anywhere ( source or repl input ) and the results get live updates like an actual repl would

It is true that sucrase computes the same thing but you have to run it yourself and checking values in the debugger is a much slower process

Copy link
Contributor Author

@pushkine pushkine Jan 9, 2021

Choose a reason for hiding this comment

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

On a side note that part only outputs tsx right now, I imagine there are other outputs that could be interesting to print

"source-map": "^0.6.1",
"source-map-support": "^0.5.16",
"sucrase": "^3.17.0",
Copy link
Member

@dummdidumm dummdidumm Jan 9, 2021

Choose a reason for hiding this comment

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

Could we use ts-node instead? We already have that in this repo and it might serve the same use case and we avoid another dependency.

Copy link
Contributor Author

@pushkine pushkine Jan 9, 2021

Choose a reason for hiding this comment

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

I agree and I tried many things, but ts-node refuses to work due to a side issue in tsconfig
Sucrase just works, it's also much faster afaik

@dummdidumm
Copy link
Member

I got this running insive VS Code with this addition to launch.json:

{
            "type": "node",
            "request": "launch",
            "name": "Run REPL with debugger",
            "runtimeArgs": ["-r", "ts-node/register"],
            "args": ["${workspaceFolder}/packages/svelte2tsx/repl/debug.ts"],
            "env": {
                "TS_NODE_COMPILER_OPTIONS": "{\"esModuleInterop\":true, \"target\": \"es2018\"}",
                "TS_NODE_TRANSPILE_ONLY": "true"
            },
            "console": "integratedTerminal",
            "internalConsoleOptions": "neverOpen"
        },

Does this work for you, too? If so, I would propose ditching the debug script inside package.json and instead use that launch script.

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.

2 participants