Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"multiple files" in chapter 07, "dynamic", not working with parcel 1 but does work with parcel 2 #225

Open
NickleDave opened this issue Aug 19, 2022 · 0 comments

Comments

@NickleDave
Copy link

Hi, thanks again for this book and sorry for adding noise to your GitHub notifications

I had trouble getting the examples in Chapter 07 to work, starting from "Multiple files"

\section{Multiple Files}\label{s:dynamic-multiple}

For some reason, the JSX would not render--there was just nothing on the page--when I removed the <script> elements that import dependencies from the web. I had the same issue with / without "require" statements and regardless of where I put the <script> element containing "app.js". I even tried installing babel and configuring parcel to use it, etc. even though I think the whole point of using parcel was to avoid that.

So it's not at all clear to me why things don't work as written in the chapter using parcel version 1, but for whatever reason I did get things to work eventually by just using parcel 2.

I needed to make two changes for this to work.

  1. parcel version 2 is now just installed with parcel, not parcel-bundler
    as described here: https://parceljs.org/getting-started/migration/#package-name

so this line in dynamic.tex:

$ npm install parcel-bundler

would be

\begin{minted}{shell}
$ npm install parcel
\end{minted}
  1. and, when building with a separate app.js script and local installs of React et al., I needed to set the "type" tag in the script element to type="module" instead of `type="text/babel"
    as shown here: https://parceljs.org/getting-started/migration/#%3Cscript-type%3D%22module%22%3E

so this line

<script src="./app.js" type="text/babel"></script>

would be

        <script src="./app.js" type="module" async></script>

Not sure if this is useful for you all but I think the intent was to make these examples require minimal config, so passing this along in case it helps achieve that goal

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

No branches or pull requests

1 participant