npm install -g parcel-bundler mkdir parceltest cd parceltest echo "<html><body><div id="root"></div><script src="./index.tsx"></script></body></html>" > index.html echo -e "import * as React from 'react'\nimport ReactDOM from 'react-dom'\nReactDOM.render(<h1>Hello world.</h1>,document.getElementById('root'))" > index.tsx parcel index.html => localhost:1234
And there you go, localhost:1234 works as intended;
Parcel figured out we needed React, ReactDOM, TypeScript, and JSX all by parsing the code and not a configuration file.
I've used JSX which either requires a
.tsx file extension or a TypeScript configuration which is counter to what we're trying to achieve here. You'll notice
import * as React from 'react' rather than the simpler
import React from 'react' and this is due to a somewhat counter intuitive default configuration by Parcel for TypeScript which I hope they change.