-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
Conversation
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
function repl() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
packages/svelte2tsx/package.json
Outdated
"source-map": "^0.6.1", | ||
"source-map-support": "^0.5.16", | ||
"sucrase": "^3.17.0", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
I got this running insive VS Code with this addition to {
"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. |
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