-
Notifications
You must be signed in to change notification settings - Fork 8
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
Update to Parcel 2 #18
base: master
Are you sure you want to change the base?
Conversation
"transform-react-jsx", | ||
"transform-class-properties" | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.babelrc
is not needed anymore.
I found out because it was causing an error, and I came across this advice that said to delete it:
@@ -7,6 +7,7 @@ dist/ | |||
|
|||
# misc | |||
.cache | |||
.parcel-cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parcel cache directory has changed from .cache
to .parcel-cache
.
https://parceljs.org/getting-started/migration/#cache-location
I've kept the old one around in yarn build-clean
and in .gitignore
so that users who have already cloned this repo won't run into issues.
@@ -13,6 +13,6 @@ | |||
</head> | |||
<body> | |||
<div id="root"></div> | |||
<script src="./src/index.js"></script> | |||
<script type="module" src="./src/index.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"react-start": "parcel -p 3000 index.html --out-dir build", | ||
"react-build": "parcel build index.html --out-dir build --public-url ./", | ||
"react-start": "parcel -p 3000 index.html --dist-dir build", | ||
"react-build": "parcel build index.html --dist-dir build --public-url ./", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"targets": { | ||
"main": false | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parcel 2 looks at package.json#main
(even though it's intended for Electron). Adding this tells Parcel to ignore it.
"electron-build": "electron-builder -mwl", | ||
"clean-build": "rm -rf build/ .cache dist/", | ||
"clean-build": "rm -rf build/ .cache .parcel-cache dist/", | ||
"build": "yarn clean-build && yarn react-build && yarn electron-build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted package-lock.json
and generated yarn.lock
since these scripts only work with Yarn anyway.
Note to other people coming across this issue: The repo seems to be not actively maintained, so I'm not sure if this PR will get merged soon. If you want to use Parcel 2 now, feel free to use my fork:
https://github.com/szhu/electron-react-parcel-boilerplate
This is a PR that upgrades Parcel from v1 to v2.
In this PR I've changed as little as possible. I think this is the bare minimum set of changes required to get Parcel 2 to work. I'll add inline comments to explain each change I've made. Note, this is Parcel's official migration guide: https://parceljs.org/getting-started/migration/
I tested all the yarn scripts on a Mac and they seem to be working as intended. (All the apps build successfully, but I only tested that the Mac app runs successfully.)
Here are my version numbers
Btw, thanks for making this repo! I'm just starting to learn Electron but I'm familiar with using Parcel and React, so this repo is incredibly helpful.