pawelgabryelewicz / babel-preset-typescript-vue

TypeScript preset for Babel 7.x supporting Vue.js components written in TS
MIT License
22 stars 4 forks source link

Default to javascript when no lang attribute is found #1

Closed whiskyjs closed 4 years ago

whiskyjs commented 4 years ago

First of all, thanks for the preset. Without it I'd probably stopped here and passed on making class-based components and Typescript work together.

It seems, however, it does not handle well cases when there are no attributes present on script tag in .vue file, in which fast-xml-parser returns the inner text of the node as string instead of the object.

On quick glance I haven't found the option to force it to always return object, so adding extra typechecks is probably the simplest way.

pawelgabryelewicz commented 4 years ago

That is correct! Also there was a bug in the typeof check. Thank you for your contribution!

bbugh commented 4 years ago

@pawelgabryelewicz it looks like the 1.0.3 package in npm does not have this update, though the Github release Changelog says that it does. When I download and install the latest version (1.0.3), this patch is not included. In both index.js and index.es.js, it still shows:

if (typeof json.script !== "undefined" && typeof json.script["@_lang"] && json.script["@_lang"].toLowerCase() === "ts") {

I confirmed that the package.json includes "version": "1.0.3",.

Reproduction:

> npm pack babel-preset-typescript-vue@1.0.3
> tar -xvf babel-preset-typescript-vue-1.0.3.tgz

Then look at index.js and see that this code has not been changed.

bbugh commented 4 years ago

@pawelgabryelewicz it looks like someone else reported this issue a few months ago. Is there anything we can do to help get this new version launched? We're blocked from upgrading to babel just by this one line check!

pawelgabryelewicz commented 4 years ago

Hi guys. First of all I am terribly sorry for no reply - I have changed my job and recently had no time for other activities. It seems that older build was published to npm with 1.0.3 (there is no npm prepare script so most likely I haven't built it before publishing...). It's a very side project (I am more into React these days) so it doesn't have proper attention and love.

Anyways I have just published version 1.0.4 that should contain an up-to-date build. This is a temporary solution, I guess vue will eventually support it properly. Thanks and again sorry.

bbugh commented 4 years ago

Thank you for all of your work on this @pawelgabryelewicz. I know how these side projects can sometimes run away with our time. Best of luck in your new job!