Closed stramel closed 4 years ago
This looks good, but I must confess I have not looked fully into how snowpack deals with TS. No actual TypeScript dependency, just type stripping with Babel or similar? Maybe the production version should go through the actual compiler?
FYI The creators are finalizing the new official tsconfig
template and discussing what to put in it https://github.com/tsconfig/bases/pull/15
I have not looked fully into how snowpack deals with TS. No actual TypeScript dependency, just type stripping with Babel or similar? Maybe the production version should go through the actual compiler?
Snowpack doesn’t really need to run the compiler because when it searches your code for imports & exports, that’s literally all it cares about. For that, we run es-module-lexer which is a tiny, WASM-powered lexer that lets us grab all that quickly and cheaply, and it works for TS.
If we included the TS compiler (which is heavy & slow), we’d slow down npx snowpack
as well as the web module install in general for no big gains (since Snowpack isn’t concerned with typechecking, etc.). Not saying that Snowpack is 100% perfectly optimized for speed in both of those areas, but not depending on TS directly helps a lot for install speed.
@drwpow Hmmm, looking at the react-typescript and litelement-typescript templates both utilize tsc
as a script. I should probably add that?
We do use esbuild
(https://github.com/evanw/esbuild) by default to handle javascript/typescript building.
@drwpow Hmmm, looking at the react-typescript and litelement-typescript templates both utilize tsc as a script. I should probably add that?
Oh good catch. I hadn’t noticed for both that was in the snowpack.config.json
.
We do use
esbuild
(https://github.com/evanw/esbuild) by default to handle javascript/typescript building.
Yup! That too. Forgot we use that for building 😅
@stramel esbuild looks very cool. How do I turn on the minifier feature in Snowpack? I searched the docs and found:
Legacy browser support, code minification, code-splitting, tree-shaking, dead code elimination, and other performance optimizations are all handled in Snowpack via bundling.
but that was the final mention of minification? Seems like with esbuild it is dependency free and built in out of the box?
There's a reasonable argument for moving the majority of that tsconfig into https://github.com/tsconfig/bases too as it's mostly framework-y level stuff 👍
( though I'm not sure how much this template relies on npm )
I can't use it yet as it is not published, but it shows on https://github.com/pikapkg/create-snowpack-app as available:
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@snowpack%2fapp-template-blank-typescript - Not found
npm ERR! 404
npm ERR! 404 '@snowpack/app-template-blank-typescript@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
@david-else it hasn't been published to npm yet.
Resolves #157
Summary:
Adds a blank typescript template for snowpack. I also sync'd the types across all 3 typescript templates.