Closed mlisook closed 6 years ago
The concept was that every JS file is placed inside the script
tags so that it can be imported via HTML Import, as the idea was to rely on those imports only. If there is however a need to structure those separately, you can however keep 2 TypeScript configuration files, the non-twc could be named tsconfig.json
and the twc one anything else, like tsconfig.twc.json
, so later you can pass it via the argument --project
(or -p
). The argument is exactly the same as with tsc
.
In my opinion (and I can always be wrong, so if I am please do share your thoughts) mixing HTML Imports and other packaging (be it ES Modules, Webpack, Require.js etc) is a bit non standard for Polymer projects thus default option should stay as it is. I could also change it so it keeps JS file + HTML file with script tag pointing to the JS one if that would help.
I have to agree with you on relying on HTML imports, though I have to admit I didn't use that philosophy in most of my projects - stuck in old thinking, no doubt.
The other use case, where I'm adding several new Polymer 2 pages to an existing typescript based website is neatly handled by the --project
option as you suggest.
So, really, there is no issue here, and I'm closing this. Thank you!
Glad to hear that :). New version of Polymer (V3) will rely on ES Modules instead of HTML Imports, and as soon as I get off the extra working hours (end of October) I am going to also implement that as a target. This should not change how twc looks itself, so hopefully any project started with twc for P2 will be able to migrate to P3 within a simple config change.
Since
twc
usestsconfig.json
, iftsconfig.json
includes files that are typescript, but not custom elements,twc
will still output html files with the transpiled js inside script tags. OTOH if non custom element ts is structured into its own folder(s), and a separate tsconfig pointing to those folders, there is now prescribed structure and the developer can't just fire off a nakedtsc
command to build or build + watch (or use the built in task in an editor such as vscode).In any case, I think
twc
should probably skip a ts file that does not include the@CustomElement
decorator.What is your recomendation for projects with both custom elements and non custom element ts?