Skip to content
This repository has been archived by the owner on Dec 30, 2021. It is now read-only.

New: Blank Typescript template #165

Merged

Conversation

stramel
Copy link
Contributor

@stramel stramel commented Jul 3, 2020

Resolves #157

Summary:

Adds a blank typescript template for snowpack. I also sync'd the types across all 3 typescript templates.

@stramel stramel requested a review from a team July 3, 2020 18:45
@stramel stramel self-assigned this Jul 3, 2020
@stramel stramel force-pushed the ms/add-blank-typescript-template branch from 617beea to 7414ebd Compare July 3, 2020 18:50
@David-Else
Copy link
Contributor

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 tsconfig/bases#15

declare module '*.webp' {
const ref: string;
export default ref;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Good additions

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! This is awesome.

@drwpow
Copy link
Contributor

drwpow commented Jul 4, 2020

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.

@stramel
Copy link
Contributor Author

stramel commented Jul 4, 2020

@drwpow Hmmm, looking at the react-typescript and litelement-typescript templates both utilize tsc as a script. I should probably add that?

@stramel
Copy link
Contributor Author

stramel commented Jul 5, 2020

We do use esbuild (https://github.com/evanw/esbuild) by default to handle javascript/typescript building.

@drwpow
Copy link
Contributor

drwpow commented Jul 5, 2020

@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 😅

Copy link
Contributor

@drwpow drwpow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally and works well for me! Ready to merge it whenever (I don’t remember if you can merge on this repo or not)

@stramel stramel merged commit 6332e53 into FredKSchott:master Jul 5, 2020
@David-Else
Copy link
Contributor

David-Else commented Jul 5, 2020

@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?

@orta
Copy link
Contributor

orta commented Jul 5, 2020

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 )

@stramel stramel deleted the ms/add-blank-typescript-template branch July 5, 2020 17:37
@David-Else
Copy link
Contributor

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.

@stramel
Copy link
Contributor Author

stramel commented Jul 6, 2020

@David-Else it hasn't been published to npm yet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a blank template for Typescript
4 participants