Skip to content

Add filename option in REPL config - #2019

Closed
hackape wants to merge 2 commits into
babel:masterfrom
hackape:master
Closed

hackape wants to merge 2 commits into
babel:masterfrom
hackape:master

Conversation

@hackape

@hackape hackape commented May 6, 2019 •

Copy link
Copy Markdown

fix #1666, fix babel/babel#8117
the long pending issue that breaks typescript compilation

@netlify

netlify Bot commented May 6, 2019

Copy link
Copy Markdown

@hackape

hackape commented May 6, 2019

Copy link
Copy Markdown
Author

@loganfsmyth can you help review this PR?

@nicolo-ribaudo nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@danez

danez commented May 8, 2019

Copy link
Copy Markdown
Member

besides the extension I guess there is not much use for the filename, right?

Why don't we just change the filename internally when the typescript preset is on?

@hackape

hackape commented May 8, 2019

Copy link
Copy Markdown
Author

@danez According to @nicolo-ribaudo changing the filename is the preferred solution, though I cannot tell the what's the preferred way to change it. My thought is the filename might play a role in scenarios other than typescript, maybe in the future. So an option to allow user to manually change filename might be better than hard-coded to fit typescript in a sense it's future proof.

@hackape

hackape commented May 8, 2019

Copy link
Copy Markdown
Author

With all due respect, this issue has been bikeshedded for a whole year. People just want typescript compilation to work in repl, that's all. Whatever conclusion you guys come to, I'll respect that and change my implementation accordingly. But please, don't leave this pending like before.

@existentialism

Copy link
Copy Markdown
Member

It depends how much we want the REPL to illustrate/educate the differences between the functionality of presets and .js vs .ts vs. .tsx.

If we want TS to just work, then my initial reaction is to just change the filename internally.

(FWIW, just because it's been an open issue hardly means it's been bikeshedded, and as far as I know we actually haven't discussed this much.)

@hackape

hackape commented May 9, 2019

Copy link
Copy Markdown
Author

const babelConfig = {
babelrc: false,
filename: "repl",
sourceMap: config.sourceMap,

If I understand it right, for the current state of repl, changing ln:92 to filename: "repl.tsx" suffices to make everything work. Is that acceptable?

@nicolo-ribaudo

Copy link
Copy Markdown
Member

No, that would prevent <Type> foo type cast from working.
The extension (at least) needs to be configurable; but I don't see anything bad in allowing configuring the whole filename.

@hzoo

hzoo commented May 20, 2019

Copy link
Copy Markdown
Member

This is cool, but my hesitation is that it is extremely unlikely a user is going to know to change the filename (especially if we don't have an error message for it).

Screen Shot 2019-05-20 at 10 53 09 AM

It just looks like it doesn't work. So I would suggest the "Why don't we just change the filename internally when the typescript preset is on?" suggestion (exposing the filename is fine but seems unnecessary in a repl, especially if it doesn't do anything else). There's limited space for options and it's just for testing, in this environment/scenario everything should probably just work with the least changing/config possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typescript preset does nothing in current REPL beta Include file extension in REPL config options

5 participants