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

Bump Webpack to v5 and node to 18 #343

Merged
merged 13 commits into from
Oct 24, 2023
Merged
26 changes: 13 additions & 13 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// .babelrc
{
"presets": [
["es2015", {"modules": false}],
"react"
],
"plugins": [
"transform-object-assign",
"transform-class-properties",
"react-hot-loader/babel"
],
"env": {
"test": {
"plugins": ["transform-es2015-modules-commonjs"]
}
}
"@babel/preset-react",
[
"@babel/preset-env",
{
"useBuiltIns": "entry",
"corejs": "3.19",
"targets": {
"chrome": 75,
"ios": 12
}
}
]
]
Comment on lines +4 to +16

Choose a reason for hiding this comment

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

Is this config change needed due to upgrading webpack?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some of the existing babel dependencies were incompatible - since I was moving from babel-core et al to @babel/core et all I needed to overhaul this file - mostly this is borrowed from Composer's .babelrc

}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12.13.1
18.18.2

Choose a reason for hiding this comment

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

Out of interest, why upgrade to Node 18 over 20? Was this because of issues with whatwg-fetch and url.parse()? In our case would this throw errors rather than just warnings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, have bumped up to 20 now! 18 was the first LTS version I started having problems with so I was focused on getting that running, it seems that 20 is working now too.
Pushed to the wrong branch (the follow-up: https://github.com/guardian/atom-workshop/pull/344/files)

73 changes: 0 additions & 73 deletions conf/webpack-devserver.conf.js

This file was deleted.

67 changes: 38 additions & 29 deletions conf/webpack.conf.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
/* global module:false, __dirname:false */

var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
devtool: 'cheap-module-source-map',
devtool: 'source-map',
entry: {
app: './public/js/app.js'
},
output: {
path: path.join(__dirname, '../public/build'),
filename: 'app.js'
},
module: {
loaders: [
rules: [
{
test: /\.js$/,
test: /\.m?js$/,
exclude: /node_modules/,
loaders: ['babel-loader']
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: ['@babel/plugin-transform-object-assign']
}
}
},
{
test: /\.js$/,
include: [path.resolve(__dirname, "../node_modules/panda-session")],
loaders: ['babel-loader']
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, "css-loader"],
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?sourceMap!sass-loader?sourceMap'
})
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader?sourceMap'
})
},
{
test: /\.woff(2)?(\?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?mimetype=application/font-woff&limit=10000"
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
},
"sass-loader"
]
},
{
test: /\.(ttf|eot|svg|gif|png)(\?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader?name=[name].[ext]"
test: /\.(ttf|eot|svg|gif|png|woff(2))(\?v=[0-9].[0-9].[0-9])?$/,
type: 'asset/resource'
}
]
},
Expand All @@ -48,10 +59,8 @@ module.exports = {
},

plugins: [
new ExtractTextPlugin('main.css'),
new webpack.ProvidePlugin({
'Promise': 'es6-promise',
'fetch': 'imports-loader?this=>global!exports-loader?global.fetch!whatwg-fetch'
new MiniCssExtractPlugin({
filename: 'main.css',
})
]
};
52 changes: 25 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"description": "A tool for creating multiple atom types.",
"main": "public/index.html",
"scripts": {
"start": "webpack ./public/js/app.js ./public/build/app.js --config ./conf/webpack.conf.js --watch",
"build": "webpack -p ./public/js/app.js ./public/build/app.js --config ./conf/webpack.conf.js",
"test": "jest",
"lint": "eslint public/**"
"start": "webpack --mode development --config ./conf/webpack.conf.js --watch",
"build": "webpack --mode production --config ./conf/webpack.conf.js",
"test": "jest ./public/js",
"lint": "eslint public/js/** --ext .js"
},
"repository": {
"type": "git",
Expand All @@ -20,48 +20,46 @@
"jest": {
"testPathDirs": [
"<rootDir>/public/js"
]
],
"testEnvironment": "jsdom"
},
"homepage": "https://github.com/guardian/atom-workshop",
"devDependencies": {
"babel-core": "^6.21.0",
"babel-eslint": "6",
"babel-jest": "^18.0.0",
"babel-loader": "^6.2.10",
"babel-plugin-transform-es2015-modules-commonjs": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.8.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"css-loader": "^0.26.1",
"@babel/core": "^7.23.2",
"@babel/plugin-transform-object-assign": "^7.22.5",
"@babel/preset-env": "^7.23.2",
"@babel/preset-react": "^7.22.15",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.3",
"css-loader": "^6.8.1",
"enzyme": "^3.10.0",
"eslint": "^3.15.0",
"eslint": "^4.12.1",
"eslint-plugin-react": "^6.9.0",
"extract-text-webpack-plugin": "^2.1.2",
"file-loader": "^0.9.0",
"jest": "^18.1.0",
"node-sass": "4.13.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^22.1.0",
"mini-css-extract-plugin": "^2.7.6",
"react-addons-test-utils": "^15.4.2",
"react-hot-loader": "^3.1.1",
"react-test-renderer": "^15.4.2",
"sass-loader": "^4.1.1",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^2.6.1"
"sass": "^1.69.4",
"sass-loader": "^13.3.2",
"style-loader": "3.3.3",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"babel-plugin-transform-class-properties": "^6.22.0",
"babel-eslint": "^10.1.0",
"copy-to-clipboard": "^3.0.5",
"date-fns": "^1.28.0",
"enzyme-adapter-react-15": "^1.4.1",
"es6-promise": "^4.0.5",
"exports-loader": "^0.6.3",
"filesize": "^3.5.4",
"history": "^4.5.1",
"imports-loader": "^0.7.0",
"lodash": "^4.17.21",
"moment": "^2.18.0",
"panda-session": "^0.1.6",
"react": "^15.4.2",
"react": "15.7.0",
"react-addons-shallow-compare": "^15.4.2",
"react-dates": "^8.2.1",
"react-dom": "^15.4.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
exports[`test Should render 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Should render 1`] = `
<div
className="form__ group form__group--checkbox--test">
className="form__ group form__group--checkbox--test"
>
<label
className="form__label"
htmlFor="test">
htmlFor="test"
>
test
</label>
<input
Expand All @@ -12,6 +16,7 @@ exports[`test Should render 1`] = `
name="test"
onChange={[Function]}
type="checkbox"
value={true} />
value={true}
/>
</div>
`;
Original file line number Diff line number Diff line change
@@ -1,50 +1,63 @@
exports[`test Should render 1`] = `
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Should render 1`] = `
<div
className="form__row">
className="form__row"
>
<label
className="form__label"
htmlFor="test">
htmlFor="test"
>
test
</label>
<div
className="form__ group form__group--checkbox--one">
className="form__ group form__group--checkbox--one"
>
<input
checked={true}
className="form__checkbox"
name="one"
onChange={[Function]}
type="checkbox"
value={true} />
value={true}
/>
<span
className="form__label form__label--checkbox">
className="form__label form__label--checkbox"
>
one
</span>
</div>
<div
className="form__ group form__group--checkbox--two">
className="form__ group form__group--checkbox--two"
>
<input
checked={true}
className="form__checkbox"
name="two"
onChange={[Function]}
type="checkbox"
value={true} />
value={true}
/>
<span
className="form__label form__label--checkbox">
className="form__label form__label--checkbox"
>
two
</span>
</div>
<div
className="form__ group form__group--checkbox--three">
className="form__ group form__group--checkbox--three"
>
<input
checked={false}
className="form__checkbox"
name="three"
onChange={[Function]}
type="checkbox"
value={false} />
value={false}
/>
<span
className="form__label form__label--checkbox">
className="form__label form__label--checkbox"
>
three
</span>
</div>
Expand Down