Skip to content

Commit

Permalink
DEP Upgrade build stack (#123)
Browse files Browse the repository at this point in the history
* DEP Upgrade webpack and deps

* DEP Upgrade code to work with upgraded dependencies

* MNT Run yarn build
  • Loading branch information
GuySartorelli authored Dec 18, 2022
1 parent fa4cdaa commit 4043291
Show file tree
Hide file tree
Showing 7 changed files with 5,416 additions and 9,201 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10
18
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/dist/styles/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions client/src/legacy/SessionManagerFieldEntwine.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Manages rendering SessionManagerFields in lieu of React support in ModelAdmin
import React from 'react';
import ReactDOM from 'react-dom';
import { createRoot } from 'react-dom/client';
import { loadComponent } from 'lib/Injector';
import $ from 'jquery';

Expand All @@ -14,7 +14,8 @@ function injectReactSessionManagerField(field) {
}
} = field.data('schema');

ReactDOM.render(<SessionManagerField loginSessions={loginSessions} />, field[0]);
const root = createRoot(field[0]);
root.render(<SessionManagerField loginSessions={loginSessions} />);
}

$.entwine('ss', jQuery => {
Expand Down
58 changes: 30 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"main": "./client/src/boot/index.js",
"author": "SilverStripe Ltd",
"engines": {
"node": ">=10.x"
"node": ">=18.x"
},
"scripts": {
"build": "yarn && yarn lint && NODE_ENV=production webpack -p --bail --progress",
"build": "yarn && rm -rf client/dist/* && NODE_ENV=production webpack --mode production --bail --progress",
"dev": "NODE_ENV=development webpack --progress",
"watch": "NODE_ENV=development webpack --watch --progress",
"css": "WEBPACK_CHILD=css npm run build",
Expand All @@ -19,47 +19,49 @@
"lint-sass": "sass-lint client/src"
},
"dependencies": {
"@silverstripe/reactstrap-confirm": "^0.0.4",
"babel-polyfill": "6.7.4",
"babel-polyfill": "^6.26.0",
"core-js": "^3.26.0",
"moment": "^2.29.4",
"prop-types": "^15.7.2",
"react": "^16.8.3",
"react-dom": "16.8.3",
"react-redux": "^5.0.7",
"reactstrap": "^8.5.1",
"redux": "^4.0.0"
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"reactstrap": "^8.9.0",
"reactstrap-confirm": "^1.3.2",
"redux": "^4.2.0"
},
"devDependencies": {
"@silverstripe/eslint-config": "^0.1.0",
"@silverstripe/webpack-config": "^1.7.0",
"@storybook/addon-knobs": "^3.4.10",
"babel-jest": "^23.6.0",
"@babel/runtime": "^7.20.1",
"@silverstripe/eslint-config": "^1.0.0-alpha1",
"@silverstripe/webpack-config": "^2.0.0-alpha1",
"@storybook/addon-knobs": "^6.4.0",
"babel-jest": "^29.3.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-runtime": "^6.26.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.10.0",
"jest-cli": "^23.6.0",
"mockdate": "^3.0.3",
"react-test-renderer": "16.8.3"
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.7",
"jest-cli": "^29.3.0",
"mockdate": "^3.0.5",
"react-test-renderer": "^18.2.0",
"webpack": "^5.74.0",
"webpack-cli": "^5.0.0"
},
"resolutions": {
"colors": "1.1.2"
"colors": "1.4.0"
},
"browserslist": [
"defaults"
],
"babel": {
"presets": [
"env",
"react"
],
"plugins": [
"transform-object-rest-spread",
"transform-runtime"
"@babel/preset-env",
"@babel/preset-react"
]
},
"jest": {
"roots": [
"client/src"
],
"modulePaths": [
"moduleDirectories": [
"client/src",
"../admin/client/src",
"../admin/node_modules",
Expand Down
55 changes: 12 additions & 43 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,27 @@
const Path = require('path');
const webpackConfig = require('@silverstripe/webpack-config');
const {
resolveJS,
externalJS,
moduleJS,
pluginJS,
moduleCSS,
pluginCSS,
} = webpackConfig;
const { JavascriptWebpackConfig, CssWebpackConfig } = require('@silverstripe/webpack-config');

const ENV = process.env.NODE_ENV;
const PATHS = {
MODULES: 'node_modules',
FILES_PATH: '../',
ROOT: Path.resolve(),
SRC: Path.resolve('client/src'),
DIST: Path.resolve('client/dist'),
};

const externals = externalJS(ENV, PATHS);
delete externals.reactstrap;

const config = [
{
name: 'js',
entry: {
// Main JS bundle
new JavascriptWebpackConfig('js', PATHS, 'silverstripe/session-manager')
.setEntry({
bundle: `${PATHS.SRC}/bundles/bundle.js`,
},
output: {
path: PATHS.DIST,
filename: 'js/[name].js',
},
devtool: (ENV !== 'production') ? 'source-map' : '',
resolve: resolveJS(ENV, PATHS),
externals,
module: moduleJS(ENV, PATHS),
plugins: pluginJS(ENV, PATHS),
},
{
name: 'css',
entry: {
})
.getConfig(),
// sass to css
new CssWebpackConfig('css', PATHS)
.setEntry({
bundle: `${PATHS.SRC}/bundles/bundle.scss`,
},
output: {
path: PATHS.DIST,
filename: 'styles/[name].css',
},
devtool: (ENV !== 'production') ? 'source-map' : '',
module: moduleCSS(ENV, PATHS),
plugins: pluginCSS(ENV, PATHS),
},
})
.getConfig(),
];

// Use WEBPACK_CHILD=js or WEBPACK_CHILD=css env var to run a single config
module.exports = (process.env.WEBPACK_CHILD)
? config.find((entry) => entry.name === process.env.WEBPACK_CHILD)
: module.exports = config;
: config;
Loading

0 comments on commit 4043291

Please sign in to comment.