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

Update to Parcel 2 #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update to Parcel 2 #18

wants to merge 1 commit into from

Conversation

szhu
Copy link

@szhu szhu commented Jan 5, 2022

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
$ uname
Darwin

$ sw_vers
ProductName:	macOS
ProductVersion:	12.1
BuildVersion:	21C52

$ node --version
v16.13.1

$ yarn --version
1.22.17

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.

"transform-react-jsx",
"transform-class-properties"
]
}
Copy link
Author

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:

https://stackoverflow.com/a/66856855/782045

@@ -7,6 +7,7 @@ dist/

# misc
.cache
.parcel-cache
Copy link
Author

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>
Copy link
Author

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 ./",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +6 to +8
"targets": {
"main": false
},
Copy link
Author

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.

parcel-bundler/parcel#3500 (comment)

"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",
Copy link
Author

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.

@szhu szhu marked this pull request as ready for review January 5, 2022 07:42
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

Successfully merging this pull request may close these issues.

None yet

1 participant