Skip to content

Commit

Permalink
Merge pull request #279 from django-stars/next-generation-upgrade
Browse files Browse the repository at this point in the history
upgrade packages/configs to the latest versions
  • Loading branch information
legendar authored Nov 21, 2024
2 parents 98529dc + 59e82c0 commit 054f0ba
Show file tree
Hide file tree
Showing 47 changed files with 5,500 additions and 3,545 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
docker:
# legacy node
- image: circleci/node:8.11.3
- image: cimg/node:18.18.0

working_directory: ~/frontend-skeleton

Expand Down Expand Up @@ -33,6 +33,6 @@ jobs:
name: Check Code Style
command: yarn lint

- run:
name: Run Tests
command: yarn test
#- run:
# name: Run Tests
# command: yarn test
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
init-env.mjs
12 changes: 8 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
"standard",
"plugin:react/recommended"
],
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"env": {
"browser": true,
"node": true,
"es6": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 2024,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"modules": true,
"globalReturn": true
"globalReturn": true,
"deprecatedImportAssert": true
},
"babelOptions": {
"presets": ["@babel/preset-react"]
}
},
"plugins": [
Expand Down Expand Up @@ -52,7 +56,7 @@
"react/display-name": ["off", { "ignoreTranspilerName": true }],
"jsx-quotes": ["error", "prefer-double"],
"padding-line-between-statements": [
"error",
"warn",
{ "blankLine": "always", "prev": "block", "next": "*" },
{ "blankLine": "always", "prev": "block-like", "next": "*" }
]
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18.18.0
33 changes: 17 additions & 16 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
module.exports = {
'compact': false,
'presets': [[
sourceType: 'module',
compact: false,
presets: [[
'@babel/preset-env',
{
'useBuiltIns': 'usage',
'corejs': {
'version': 3,
'proposals': true,
useBuiltIns: 'usage',
corejs: {
version: 3,
proposals: true,
},
},
]],
'plugins': [
plugins: [
// stage 2
['@babel/plugin-proposal-decorators', { 'legacy': true }],
'@babel/plugin-proposal-numeric-separator',
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-transform-numeric-separator',
'@babel/plugin-proposal-throw-expressions',
// stage 3
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
['@babel/plugin-proposal-class-properties', { 'loose': false }],
'@babel/plugin-proposal-json-strings',
'@babel/plugin-proposal-export-namespace-from',
['@babel/plugin-transform-class-properties', { loose: false }],
'@babel/plugin-transform-json-strings',
'@babel/plugin-transform-export-namespace-from',
],
'env': {
'test': {
'presets': ['@babel/preset-react', '@babel/preset-flow'],
'plugins': [
env: {
test: {
presets: ['@babel/preset-react', '@babel/preset-flow'],
plugins: [
'babel-plugin-react-require',
],
},
Expand Down
2 changes: 1 addition & 1 deletion init-env.js → init-env.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import dotenv from 'dotenv'
import packageConfig from './package.json'
import packageConfig from './package.json' assert { type: 'json' }
import dotenvExpand from 'dotenv-expand'

if(!Boolean(process.env.APP_NAME)) {
Expand Down
4 changes: 2 additions & 2 deletions linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const opts = {
version: pkg.version,
homepage: pkg.homepage,
bugs: pkg.bugs.url,
eslint: eslint,
eslint,
cmd: 'linter',
eslintConfig: {
configFile: path.join(__dirname, '.eslintrc.json'),
overrideConfigFile: path.join(__dirname, '.eslintrc.json'),
},
cwd: '',
}
Expand Down
90 changes: 48 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
"license": "MIT",
"repository": "github:django-stars/frontend-skeleton",
"scripts": {
"start": "NODE_ENV=development webpack-dev-server --progress --colors --mode development",
"start": "NODE_ENV=development webpack-dev-server --progress --mode development",
"build": "NODE_ENV=production webpack --mode production",
"lint": "yarn run eslint && yarn run stylelint",
"lint": "yarn run eslint",
"lint:fix": "yarn run eslint:fix && yarn run stylelint:fix",
"eslint": "node linter --verbose | snazzy",
"eslint:fix": "node linter --fix --verbose | snazzy",
"stylelint": "stylelint 'src/**/*.scss' --syntax scss",
"stylelint:fix": "stylelint 'src/**/*.scss' --syntax scss --fix",
"stylelint": "stylelint 'src/**/*.scss' scss",
"stylelint:fix": "stylelint 'src/**/*.scss' --fix",
"test": "jest --config jest.conf.json -u"
},
"dependencies": {
Expand All @@ -54,61 +54,67 @@
"whatwg-fetch": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.3.3",
"@babel/plugin-proposal-class-properties": "^7.3.4",
"@babel/plugin-proposal-decorators": "^7.3.0",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-proposal-function-sent": "^7.2.0",
"@babel/plugin-proposal-json-strings": "^7.2.0",
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
"@babel/plugin-proposal-throw-expressions": "^7.2.0",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-syntax-import-meta": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@babel/plugin-proposal-decorators": "^7.25.9",
"@babel/plugin-proposal-function-sent": "^7.25.9",
"@babel/plugin-proposal-throw-expressions": "^7.25.9",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/plugin-transform-export-namespace-from": "^7.25.9",
"@babel/plugin-transform-json-strings": "^7.25.9",
"@babel/plugin-transform-numeric-separator": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-flow": "^7.25.9",
"@babel/preset-react": "^7.25.9",
"@babel/register": "^7.25.9",
"@hot-loader/react-dom": "^16.11.0",
"@sentry/webpack-plugin": "^1.8.0",
"autoprefixer": "^9.4.9",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.5",
"babel-plugin-react-require": "^3.1.1",
"clean-webpack-plugin": "^3.0.0",
"babel-loader": "^9.2.1",
"babel-plugin-react-require": "^4.0.3",
"clean-webpack-plugin": "^4.0.0",
"core-js": "3",
"dotenv": "^6.0.0",
"dotenv-expand": "^5.1.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.10.0",
"enzyme-to-json": "^3.3.3",
"eslint": "^4.11.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^3.6.0",
"eslint-plugin-react": "^7.7.0",
"eslint-plugin-standard": "^4.0.0",
"html-webpack-plugin": "^3.2.0",
"eslint": "^8.57.1",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-n": "^17.13.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^7.1.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-standard": "^5.0.0",
"html-webpack-plugin": "^5.6.3",
"husky": "^3.0.9",
"identity-obj-proxy": "^3.0.0",
"jest": "^24.1.0",
"jest-cli": "^24.1.0",
"jest-enzyme": "^7.0.1",
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
"jest-enzyme": "^7.1.2",
"lint-staged": "^9.4.3",
"mini-css-extract-plugin": "^2.9.2",
"postcss-inline-svg": "^3.0.0",
"react-hot-loader": "^4.12.19",
"react-test-renderer": "^16.8.3",
"redux-mock-store": "^1.5.1",
"reload-html-webpack-plugin": "^0.1.2",
"sass": "^1.81.0",
"sass-loader": "^16.0.3",
"snazzy": "^8.0.0",
"standard-engine": "^10.0.0",
"stylelint": "^10.1.0",
"stylelint-config-standard": "^18.3.0",
"stylelint-scss": "^3.9.0",
"webpack": "^4.29.6",
"standard-engine": "^15.1.0",
"stylelint": "^16.10.0",
"stylelint-config-standard": "^36.0.1",
"stylelint-scss": "^6.10.0",
"webpack": "^5.96.1",
"webpack-blocks": "^2.1.0",
"webpack-cli": "^3.2.3",
"webpack-dev-server": "^3.2.1",
"write-file-webpack-plugin": "^4.5.0"
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0",
"write-file-webpack-plugin": "^4.5.1"
},
"resolutions": {
"node-sass": "npm:no-op@latest"
}
}
4 changes: 2 additions & 2 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var autoprefixer = require('autoprefixer')
var inlineSVG = require('postcss-inline-svg')
const autoprefixer = require('autoprefixer')
const inlineSVG = require('postcss-inline-svg')

module.exports = {
sourceMap: true,
Expand Down
3 changes: 2 additions & 1 deletion presets/assets.js → presets/assets.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { file, group, match } from 'webpack-blocks'
import webpackBlocks from 'webpack-blocks'
const { file, group, match } = webpackBlocks

export default function(config) {
return group([
Expand Down
4 changes: 2 additions & 2 deletions presets/babel.js → presets/babel.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { babel, match } from 'webpack-blocks'

import webpackBlocks from 'webpack-blocks'
const { babel, match } = webpackBlocks

export default function(config) {
return match([/\.(js|jsx)$/], { exclude: /node_modules\/(?!ds-)/ }, [
Expand Down
60 changes: 60 additions & 0 deletions presets/devServer.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Webpack dev-server block.
*
* @see https://github.com/andywer/webpack-blocks/blob/master/packages/dev-server/index.js
*/

/**
* @param {object} [options] See https://webpack.js.org/configuration/dev-server/
* @param {string|string[]} [entry]
* @return {Function}
*/
export default function devServer(options = {}, entry = []) {
if(options && (typeof options === 'string' || Array.isArray(options))) {
entry = options
options = {}
}

if(!Array.isArray(entry)) {
entry = entry ? [entry] : []
}

const setter = context => prevConfig => {
context.devServer = context.devServer || { entry: [], options: {} }
context.devServer.entry = context.devServer.entry.concat(entry)
context.devServer.options = Object.assign({}, context.devServer.options, options)

return prevConfig
}

return Object.assign(setter, { post: postConfig })
}

function postConfig(context, util) {
const entryPointsToAdd = context.devServer.entry

return prevConfig => {
return util.merge({
devServer: Object.assign(
{
hot: true,
historyApiFallback: true,
},
context.devServer.options,
),
entry: addDevEntryToAll(prevConfig.entry || {}, entryPointsToAdd),
})(prevConfig)
}
}

function addDevEntryToAll(presentEntryPoints, devServerEntry) {
const newEntryPoints = {}

Object.keys(presentEntryPoints).forEach(chunkName => {
// It's fine to just set the `devServerEntry`, instead of concat()-ing the present ones.
// Will be concat()-ed by webpack-merge (see `createConfig()`)
newEntryPoints[chunkName] = devServerEntry
})

return newEntryPoints
}
Loading

0 comments on commit 054f0ba

Please sign in to comment.