Polymer / pwa-starter-kit

Starter templates for building full-featured Progressive Web Apps from web components.
https://pwa-starter-kit.polymer-project.org
2.37k stars 431 forks source link

Typescript template: avoid overcrowding of files by placing Typescript sources in a different spot #247

Closed mercmobily closed 4 years ago

mercmobily commented 6 years ago

@keanulee Consider moving TS source to a ts_src/ directory or similar, with the idea that src/ still contains JS so that polymer serve/polymer build continues to work without further changes. At the moment, once generated, the directory looks like this (courtesy of @felipecesar42):

image

lit-html does this by having a tsconfig.json file that defines the output directory.

keanulee commented 6 years ago

We've partially addressed this by not outputting typings and sourcemaps anymore.

mercmobily commented 6 years ago

OK but... don't we need sourcemaps for debugging...?

On Thu, 25 Oct 2018 at 02:18, Keanu Lee notifications@github.com wrote:

We've partially addressed this by not outputting typings and sourcemaps anymore.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Polymer/pwa-starter-kit/issues/247#issuecomment-432771641, or mute the thread https://github.com/notifications/unsubscribe-auth/ACB7XgY1677Mb-ROZw8UP5iK6C0-u-1Dks5uoK7ngaJpZM4XWbyY .

--

keanulee commented 6 years ago

Without sourcemaps, you'll see the generated JavaScript in dev tools which should closely resemble TypeScript source anyways. TS sourcemaps are broken already because polymer serve makes transforms on JS files but not the corresponding sourcemaps. We could add sourcemap transformations to our tools, but that's not a priority. See https://github.com/Polymer/pwa-starter-kit/issues/250 for more info.

pinoyyid commented 5 years ago

My vote is to leave the directory structure as it is currently. The reason...

We are using PWA starter kit as the basis for a large project. The first thing we have done is restructure the directories to match our own app. So we have a directory for app concerns, a directory for user/onboarding, a directory for each view. We have actions, reducers in components together in the same directory for each view. This gives each developer a more modular view of his area of concern.

My point is that each app will have a directory structure that fits that app's needs. The current PWA SK approach makes it easy for us to tailor this. The more complex the initial structure, the more work we need to do to change it. The most important goal of a starter kit is that it should be easy to understand and easy to tailor. Hence my vote for the most simple initial directory structure possible.

felpsio commented 5 years ago

How I solved:

In tsconfig.json I put:

"outDir": "./src"
  },
  "include": [
    "ts/**/*.ts"
  ],

I copied the content from src folder to the folder ts and used find . -name "*.js" -type f -delete on folder src to delete the js files.

Now I work with the folder ts and have less visual pollution to worry about while programming

Arenari commented 5 years ago

If you are using visual studio code you can add to settings.json

"files.exclude": {
  "**/*.js": {"when": "$(basename).ts"}
},
stale[bot] commented 4 years ago

This project is no longer under development and will be transitioning to a read-only repo. Thank you for your contributions.