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

Option for default TypeScript source. #144

Closed
Rouche opened this issue Aug 10, 2018 · 3 comments
Closed

Option for default TypeScript source. #144

Rouche opened this issue Aug 10, 2018 · 3 comments

Comments

@Rouche
Copy link

Rouche commented Aug 10, 2018

Hello,

Using vue-cli 3, I want to add an option for the VueProgram.js that when it does not find <script> tag, try to get a default option object on the Plugin. Like:

{ 
  defaultScripts: {
    ts: 'ts'
  }
}

in VueProgram pass the file name to resolve.

var resolved = VueProgram.resolveScriptBlock(source.text, path.parse(filePath).name);

resolveScriptBlock could then run through keys, use it as "lang" parameter, and value, use it as extention to the same fileName as the MyFile.vue
No longer ignore invalid file

                // For now, ignore the error when the src file is not found
                // since it will produce incorrect code location.
                // It's not a large problem since it's handled on webpack side.

Continue with same process after this.

Pretty simple, a new option so no regressions and it would allow us remove the boiler plate <script> tag for every vue files.

I can try to PR if you want i already have the code.
But it seems i loose debugger with vue-cli 3. Also there is a clear console somewhere, so console log is not the best.
I need to find a way to access the Option inside VueProgram, thats the only thing left.

And then do the same thing for scss :)

@johnnyreilly
Copy link
Member

I don't really know Vue so excuse the dumb question: is this idiomatic Vue? Sounds slightly custom?

@Rouche
Copy link
Author

Rouche commented Aug 10, 2018

I dont know if its "idiomatic" for TypeScript + Vue
But i got here because of another "fixed" bug : #130
So people were separating files before.

With vue-cli 3, TypeScript is build-in. But vue-template-loader does not works.
In this case, the entry point (import) is the typescript file, not the template. Or else there is some very hard bug to understand of a circular JSON reference.

So now, to speparate .ts/.vue/.scss files, we need to put those empty <script> + <styles> tags, it works but boilerplate.

Maybe i didn't find the right option yet, i try to keep the config as minimal as possible so upgrading projects will be simple. (The purpose of the cli)

I almost done with VueProgram. Its not working without that <script> tag. Something depends on it somewhere!!

Ill definatelly search if i missed something somewhere.

@Rouche
Copy link
Author

Rouche commented Aug 11, 2018

OK i was definatelly searching at the wrong place.

ktsn/vue-template-loader#52

I would have liked a no config change and working but oh well, thanks.

@Rouche Rouche closed this as completed Aug 11, 2018
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

2 participants