Closed marcusball closed 6 years ago
This is strange, babel transformations occur before minification, there shouldn't be any code removal before that step.
Could you provide a minimal repo for reproduction?
I would say babel transforms are not being applied but than you wouldn't get h is not defined
in the browser so it's probably not that
All of the code snippets above are enough to reproduce the issue; I've attached an archive of them, let me know if an actual git repo would be preferrable.
You should be able to just npm install
/yarn install
to set up the repo.
When you run Parcel the issue should be present; if you uncomment line 3 of src/index.tsx
the code should run correctly.
I took a bunch of time today to dig through the code and eventually found that it was the Typescript compiler that was stripping the import line (https://github.com/Microsoft/TypeScript/issues/24731).
🐛 bug report
I am trying to use Hyperapp with JSX. I followed this guide for most of my set up. I'm not experienced with the JS so I'm sorry if I misdiagnosed this as a Parcel issue if it's actually a bug in a dependency or me misconfiguring something.
Basically, hyperapp uses the
h
function for virtual-DOM creation, and I have configured babel to use that when transforming JSX.index.tsx:
The problem is that when I run this in my browser, I will receive a
ReferenceError: h is not defined
error and nothing will render.However, the code will run properly if I have explicitly used the
h
function anywhere in code. This example will run fine:🎛 Configuration (.babelrc, package.json, cli command)
.babelrc
:package.json
:tsconfig.json
:Commands
yarn start
andyarn build
which alias to:parcel src/index.html
andparcel build src/index.html
.🤔 Expected Behavior
The
h
function import should be included in the bundled code.😯 Current Behavior
The
h
function is not included. My assumption is that because theh
import is not explicity used, it it being stripped as an unused import, even though it'll be used once the babel transform is complete.🔦 Context
This is mostly just annoying, but isn't a huge problem. Adding a dummy use of the function is hacky, but doesn't prevent me from getting work done.
💻 Code Sample
See above, let me know if I left out any necessary files.
src/index.html
:🌍 Your Environment