Parcel 2: Typescript + Preact
See original GitHub issue🐛 bug report
Parcel remove unused Preact h
in typescript (works with js
):
Uncaught ReferenceError: h is not defined
💁 Possible Solution
looks like wrong jsxFactory
detection, even if I add tsconfig.json
with:
"compilerOptions": {
"jsx": "react",
"jsxFactory": "h"
},
I tried to investigate:
transformer-typescript-tsc
doesn’t run by default, right?- but
transformer-babel
has jsx pragma logic should this work with the Typescript?
💻 Code Sample
// unused `h`
import { h, render } from "preact";
const App = () => <div>Hello world!</div>;
// works if uncomment:
// console.log(h);
const node = document.getElementById("root");
render(<App />, node!, node!.lastChild as Element);
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 2.0.0-alpha.1.1 |
Node | v10.14.1 |
npm | 6.10.3 |
Operating System | macOS |
preact | 10.0.0-rc.1 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Simple setup using Parcel, Preact, and TypeScript - GitHub
Minimal template using Parcel, Preact, and TypeScript. This template provides the simplest possible set-up that combines Parcel, Preact, TypeScript, and Jest.
Read more >parcel-preact-typescript-boilerplate - npm
simple parcel2 preact typescript project without preact-compat. Latest version: 3.2.2, last published: a month ago.
Read more >Preact Project with TypeScript and Parcel | Denys Vuika's Blog
In this article, I am going to walk you through the process of configuring a new web application project that is powered by...
Read more >Recipes - Parcel
Preact. First we need to install the dependencies for Preact. npm install --save preact npm install --save-dev parcel-bundler.
Read more >Switching to Preact (from React)
There are two different approaches to switch from React to Preact: ... Aliasing via Webpack; Aliasing via Parcel; Aliasing via Browserify; Aliasing Manually ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@zackkrida I’m sorry, this is correct (babel’s typescript preset doesn’t react the tsconfig file):
@mischnic The recommended configuration above does not work. I made a minimal a repro as possible here: https://github.com/zackkrida/play/tree/parcel2/ts-preact-issue
I have both the specified .babelrc
and tsconfig.json
and still have the
ReferenceError: h is not defined
error. The “unused”, imported ‘h’ in myindex.tsx
file is still stripped out.