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

Remove parcel #993

Merged
merged 6 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ node_modules
.DS_Store
yarn-error.log
dist
.parcel-cache/
# testing
coverage
_site
Expand Down
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ node_modules/
.env.test.local
.env.production.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Stores VSCode versions used for testing VSCode extensions
.vscode-test
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"downloadSpecs": "node bin/downloadSpecs.js",
"preapi-docs": "yarn workspace @substrate/extension run compile",
"api-docs": "typedoc --entryPoints ./packages/connect/src/index.ts --entryPoints ./packages/connect-extension-protocol/src/index.ts",
"deep-clean": "yarn workspaces -s run deep-clean && rm -rf .parcel-cache && rm -rf node_modules",
"deep-clean": "yarn workspaces -s run deep-clean && rm -rf node_modules",
"clean": " yarn workspaces run clean",
"lint": "prettier --check . && yarn workspaces -s run lint",
"build": "yarn workspaces -s run build",
Expand Down Expand Up @@ -82,7 +82,6 @@
"jest-silent-reporter": "^0.5.0",
"jsdom": "^19.0.0",
"nodemon": "^2.0.15",
"parcel": "2.4.0",
"prettier": "^2.6.1",
"regenerator-runtime": "^0.13.7",
"rimraf": "^3.0.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/connect/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"jest.config*",
"tsconfig*",
"*node_modules*",
"../../node_modules*",
".parcel*"
"../../node_modules*"
],
"include": ["src/**/*", "src/**/*.json"],
"references": [{ "path": "../connect-extension-protocol" }]
Expand Down
1 change: 0 additions & 1 deletion projects/burnr/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.idea
.vscode
.cache/
.parcel-cache/
yarn-error.log*

# dependencies
Expand Down
1 change: 0 additions & 1 deletion projects/demo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

# dependencies
/node_modules
.parcel-cache/
# misc
.DS_Store
yarn-error.log*
Expand Down
1 change: 0 additions & 1 deletion projects/landing-page/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
.idea
.vscode
.cache/
.parcel-cache/
yarn-error.log*

# dependencies
Expand Down
3 changes: 0 additions & 3 deletions projects/landing-page/.parcelrc

This file was deleted.

9 changes: 6 additions & 3 deletions projects/landing-page/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"license": "GPL-3.0-only",
"scripts": {
"prebuild": "yarn clean",
"build": "parcel build ./src/index.html --public-url ./",
"build": "webpack",
"deep-clean": "yarn clean && rm -rf node_modules",
"clean": "rm -rf dist tsconfig.tsbuildinfo",
"dev": "tsc -b & parcel ./public/index.html",
"dev": "tsc -b & webpack serve --config webpack.config.js",
"test": "exit 0; #No tests",
"lint": "yarn eslint . --ext .js,.jsx,.ts,.tsx",
"predeploy": "yarn run build"
Expand All @@ -23,7 +23,10 @@
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.61",
"@material-ui/styles": "^4.11.4",
"copy-webpack-plugin": "^10.2.4",
"html-webpack-plugin": "^5.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"react-dom": "^17.0.2",
"webpack": "^5.72.0"
}
}
6 changes: 3 additions & 3 deletions projects/landing-page/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {
import MuiAlert, { AlertProps } from "@material-ui/lab/Alert"
import { CardNetwork, CardProject } from "./components/Cards"

import Burnr from "url:./assets/images/Burnr.png"
import Extension from "url:./assets/images/Extension.png"
import YourProject from "url:./assets/images/YourProject.png"
import Burnr from "./assets/images/Burnr.png"
import Extension from "./assets/images/Extension.png"
import YourProject from "./assets/images/YourProject.png"

const Alert = (props: AlertProps) => {
return <MuiAlert elevation={6} variant="filled" {...props} />
Expand Down
2 changes: 0 additions & 2 deletions projects/landing-page/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"module": "ES2015",
"target": "ES2015",
"types": [],
"esModuleInterop": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"jsx": "react"
Expand Down
78 changes: 78 additions & 0 deletions projects/landing-page/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* eslint-disable no-undef */
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be preferable to move common webpack configuration into a file in the root and then merge it with the specifics for each project instead of copy/pasting it around.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. This can be done in different PR though. The purpose of this pr is to remove parrcel, and not create common configs

Copy link
Contributor

Choose a reason for hiding this comment

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

ok 👍 but let's do this quickly after this merges

Copy link
Contributor

@tomaka tomaka Apr 22, 2022

Choose a reason for hiding this comment

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

to move common webpack configuration into a file in the root

But why?
There's nothing wrong with configuring multiple projects differently, and if projects can in theory have different configurations, then their configuration files should be separate.
It's not because files are similar that you should de-duplicate them. You should only de-duplicate them if it makes sense for the multiple different projects to always conform to the same configuration, which isn't the case.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is the case. The vast majority of the webpack configuration is identical across landing page, burnr and the demo. It's true that they can in theory be different but in practice they're not. It's not easy at the moment to see what's specific about the configuration for each project and if you make changes to the webpack configuration you have to remember to do it in all the places for them to stay consistent. The configuration for:

  • babel
  • css loading
  • HTML plugin
  • typsecript loading

is always going to be the same across these projects. If we change them we're going to want to change it everywhere. Having it one place makes that less laborious

Copy link
Contributor Author

@wirednkod wirednkod Apr 22, 2022

Choose a reason for hiding this comment

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

IMO webpack configurations should be dedicated per projects. Finding common parts of the existing configurations and making a common one, which then will be inherited to the rest ones, and then will add the extra configs - makes it more spaghetti than simple.

Common parts of webpack configs are very little and in some cases even these are different. A good example is the ts-loader where in demo we use it without extra options while in burnr we add options like transpileOnly and projectReferences. I would say that its better to narrow down the webpack confg per project and remove unnecessary parameters that probably exists due to copy/pasting and if there is some obvious added value then to create a common webpack file.

Copy link
Contributor

Choose a reason for hiding this comment

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

if you make changes to the webpack configuration you have to remember to do it in all the places for them to stay consistent.

If you merge all webpack configurations into one, then if you make changes to the webpack configuration you have to make sure that all projects still work.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not advocating merging it all into one .. just pulling the common boilerplate out

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added an issue

/* eslint-disable @typescript-eslint/no-var-requires */
const webpack = require("webpack")
const CopyPlugin = require("copy-webpack-plugin")
const HtmlWebpackPlugin = require("html-webpack-plugin")

module.exports = {
mode: "production",
entry: "./src/index.tsx",
devtool: "inline-source-map",
devServer: {
port: 1234,
open: true,
hot: true,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-react"],
},
},
},
{ test: /\.tsx?$/, loader: "ts-loader" },
{
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.png$/,
use: [
{
loader: "url-loader",
options: {
mimetype: "image/png",
},
},
],
},
],
},
resolve: {
alias: {
"react/jsx-runtime": require.resolve("react/jsx-runtime"),
},
extensions: ["*", ".js", ".jsx", ".ts", ".tsx"],
fallback: {
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
},
},
plugins: [
new CopyPlugin({
patterns: [{ from: "public/assets", to: "." }],
}),
new webpack.DefinePlugin({
process: {
env: {
WS_URL: JSON.stringify(undefined),
},
},
}),
new HtmlWebpackPlugin({
template: "./public/index.html",
}),
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
new webpack.HotModuleReplacementPlugin(),
],
optimization: {
minimize: true,
},
}
Loading