Skip to content

Commit

Permalink
Merge pull request #2772 from input-output-hk/chore/ddw-596-webpack-5…
Browse files Browse the repository at this point in the history
…-upgrade

[DDW-596] webpack 5 upgrade
  • Loading branch information
danielmain authored Jun 21, 2022
2 parents 18c3f64 + 38e13cc commit 35f93ba
Show file tree
Hide file tree
Showing 269 changed files with 23,568 additions and 27,413 deletions.
30 changes: 0 additions & 30 deletions .babelrc

This file was deleted.

8 changes: 4 additions & 4 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ env:
ARTIFACT_BUCKET: s3://ci-output-sink
steps:
- label: 'daedalus-x86_64-darwin'
command: 'scripts/build-installer-unix.sh--nix-2.5 --build-id $BUILDKITE_BUILD_NUMBER'
command: 'scripts/with-nix-2.5.sh scripts/build-installer-unix.sh --build-id $BUILDKITE_BUILD_NUMBER'
env:
NIX_SSL_CERT_FILE: /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
agents:
queue: daedalus
system: x86_64-darwin
- label: 'daedalus-aarch64-darwin'
command: 'scripts/build-installer-unix.sh--nix-2.5 --build-id $BUILDKITE_BUILD_NUMBER'
command: 'scripts/with-nix-2.5.sh scripts/build-installer-unix.sh --build-id $BUILDKITE_BUILD_NUMBER'
env:
NIX_SSL_CERT_FILE: /nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
UPLOAD_DIR_OVERRIDE: UNSAFE-internal-build
agents:
queue: daedalus
system: aarch64-darwin
- label: 'daedalus-x86_64-linux-nix'
command: 'scripts/build-installer-nix.sh $BUILDKITE_BUILD_NUMBER'
command: 'scripts/with-nix-2.5.sh scripts/build-installer-nix.sh $BUILDKITE_BUILD_NUMBER'
agents:
system: x86_64-linux
- label: 'daedalus-x86_64-windows-nix'
command: 'scripts/build-cross-windows.sh $BUILDKITE_BUILD_NUMBER'
command: 'scripts/with-nix-2.5.sh scripts/build-cross-windows.sh $BUILDKITE_BUILD_NUMBER'
agents:
system: x86_64-linux

Expand Down
18 changes: 12 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"prettier",
"prettier/babel",
"prettier/@typescript-eslint",
"prettier/react",
"plugin:jest/recommended"
],
"env": {
Expand All @@ -22,9 +19,11 @@
"jest": true
},
"rules": {
"arrow-body-style": 0,
"class-methods-use-this": 0,
"consistent-return": "warn",
"@typescript-eslint/generic-spacing": 0,
"@typescript-eslint/space-after-type-colon": 0,
"jsx-a11y/alt-text": 0,
"lines-between-class-members": 0,
"global-require": 0,
Expand Down Expand Up @@ -60,6 +59,7 @@
"react/destructuring-assignment": 0,
"react/display-name": 0,
"react/jsx-curly-brace-presence": 0,
"react/jsx-curly-newline": 0,
"react/jsx-filename-extension": 0,
"react/jsx-fragments": 0,
"react/jsx-no-bind": "warn",
Expand All @@ -76,22 +76,28 @@
"@typescript-eslint/no-empty-function": 1,
"@typescript-eslint/ban-types": 1,
"import/no-unresolved": 1,
"@typescript-eslint/no-var-requires": 1,
"@typescript-eslint/no-var-requires": 0,
"camelcase": 1,
"no-empty": 1,
"@typescript-eslint/no-explicit-any": 1,
"no-shadow": 1,
"react/no-did-update-set-state": 1,
"react/sort-comp": 0,
"react/state-in-constructor": 0,
"react/static-property-placement": 0
"react/static-property-placement": 0,
"react/jsx-no-useless-fragment": 0,
"prefer-regex-literals": 0,
"no-unused-vars": "warn",
"react/no-unused-class-component-methods": "warn",
"react/no-unstable-nested-components": "warn",
"no-promise-executor-return": "warn",
"default-param-last": "warn"
},
"plugins": ["@typescript-eslint", "import", "promise", "react", "jest"],
"globals": {
"API": true,
"API_VERSION": true,
"NETWORK": true,
"MOBX_DEV_TOOLS": true,
"BUILD_NUMBER": true,
"Process": true // TODO: remove after fix
},
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/chromatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "14"
node-version: "16"
- name: Install dependencies
run: yarn
- name: Publish to Chromatic
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ build/Release
# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
/node_modules.*

# OSX
.DS_Store
Expand All @@ -46,6 +47,9 @@ installers/config.yaml
installers/icons/electron.icns
installers/installer-config.json
installers/topology.yaml
installers/csl-daedalus/
installers/delegation.cert
installers/signing.key

# temporary certs for daedalus dev
tls/client
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
!features/
!storybook/
!hardware-wallet-tests/
!tests/

# Now we ignore all files
*.*
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

### Chores

- Upgraded webpack to version 5 ([PR 2772](https://github.com/input-output-hk/daedalus/pull/2772))
- Bumped vulnerable dependencies versions ([PR 2943](https://github.com/input-output-hk/daedalus/pull/2943))
- Added support for Trezor firmware 2.5.1 ([PR 2991](https://github.com/input-output-hk/daedalus/pull/2991))
- Added steps on how to link with `react-polymorph` and other external UI libraries ([PR 2948](https://github.com/input-output-hk/daedalus/pull/2948))
- Published selfnode installers for all 3 platforms ([PR 2971](https://github.com/input-output-hk/daedalus/pull/2971))
Expand Down
25 changes: 25 additions & 0 deletions declaration.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import { IpcRenderer } from 'electron';
import type { request as httpRequest } from 'http';
import type { request as httpsRequest, globalAgent } from 'https';
import { Environment } from './source/common/types/environment.types';

declare module '*.svg' {
const content: any;
export default content;
Expand All @@ -22,6 +27,15 @@ type Daedalus = {
};
};

interface Http {
request: httpRequest;
}

interface Https {
request: httpsRequest;
Agent: globalAgent;
}

export type $ElementType<
T extends { [P in K & any]: any },
K extends keyof T | number
Expand All @@ -39,7 +53,18 @@ declare global {
WALLET_COUNT: number;
}
}
/* eslint-disable no-var, vars-on-top */
var daedalus: Daedalus;
var environment: Environment;
var http: Http;
var https: Https;
var legacyStateDir: string;
var isFlight: boolean;
var ipcRenderer: Pick<
IpcRenderer,
'on' | 'once' | 'send' | 'removeListener' | 'removeAllListeners'
>;
/* eslint-enable no-var, vars-on-top */
}

export {};
164 changes: 3 additions & 161 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,123 +1,5 @@
const gulp = require('gulp');
const webpack = require('webpack');
const webpackStream = require('webpack-stream');
const shell = require('gulp-shell');
const electronConnect = require('electron-connect');
const mainWebpackConfig = require('./source/main/webpack.config');
const rendererWebpackConfig = require('./source/renderer/webpack.config');

// Setup electron-connect server to start the app in development mode
let electronServer;
const electronServerAgs = ['--inspect=9229'];
// Gulp input sources for main and renderer compilation
const mainInputSource = () => gulp.src('source/main/index.ts');
const rendererInputSource = () => gulp.src('source/renderer/index.ts');
// Webpack watch configs
const mainWebpackWatchConfig = Object.assign({}, mainWebpackConfig, {
watch: true,
});
const rendererWebpackWatchConfig = Object.assign({}, rendererWebpackConfig, {
watch: true,
});
// Gulp output destinations for main and renderer compilation
const mainOutputDestination = () => gulp.dest('dist/main');
const rendererOutputDestination = () => gulp.dest('dist/renderer');

/**
* Creates an electron-connect server instance that enables
* us to control our app (restarting / reloading)
* @param env - electron app environment
* @param args - additional spawn options
*/
const createElectronServer = (env, args = []) => {
electronServer = electronConnect.server.create({
spawnOpt: {
env: Object.assign({}, process.env, env),
args,
},
});
};

const buildMain = () => () =>
mainInputSource()
.pipe(webpackStream(mainWebpackConfig, webpack))
.pipe(mainOutputDestination());

const buildMainWatch = () => (done) =>
mainInputSource()
.pipe(
webpackStream(mainWebpackWatchConfig, webpack, () => {
// Restart app every time after main script has been re-compiled
electronServer.restart(electronServerAgs);
done();
})
)
.pipe(mainOutputDestination());

const buildRenderer = () => () =>
rendererInputSource()
.pipe(webpackStream(rendererWebpackConfig, webpack))
.pipe(rendererOutputDestination());

const buildRendererWatch = () => (done) =>
rendererInputSource()
.pipe(
webpackStream(rendererWebpackWatchConfig, webpack, () => {
if (electronServer) {
// Reload app every time after renderer script has been re-compiled
electronServer.reload();
}
done();
})
)
.pipe(rendererOutputDestination());

gulp.task(
'clear:cache',
shell.task('rimraf ./node_modules/.cache && rimraf .cache-loader')
);

gulp.task('clean:dist', shell.task('rimraf ./dist'));

gulp.task('server:start', (done) => {
electronServer.start(electronServerAgs);
done();
});

gulp.task('server:create:dev', (done) => {
createElectronServer({
NODE_ENV: process.env.NODE_ENV,
XCURSOR_PATH: '/usr/share/icons' || 'development',
});
done();
});

gulp.task('server:create:debug', (done) => {
createElectronServer({
NODE_ENV: process.env.NODE_ENV,
XCURSOR_PATH: '/usr/share/icons' || 'development',
});
done();
});

gulp.task('build:main', buildMain());

gulp.task('build:main:watch', buildMainWatch());

gulp.task('build:renderer:html', () =>
gulp.src('source/renderer/index.html').pipe(gulp.dest('dist/renderer/'))
);

gulp.task('build:renderer:assets', buildRenderer());

gulp.task(
'build:renderer',
gulp.series('build:renderer:html', 'build:renderer:assets')
);

gulp.task('build:renderer:watch', buildRendererWatch());

gulp.task('build', gulp.series('clean:dist', 'build:main', 'build:renderer'));

gulp.task('prepare:themes:utils', () =>
gulp
Expand Down Expand Up @@ -169,20 +51,7 @@ gulp.task(
)
);

gulp.task('typedef:sass', shell.task('yarn typedef:sass --watch'));

gulp.task(
'build:watch',
gulp.series(
'clean:dist',
'server:create:dev',
'build:renderer:html',
process.argv.includes('--disable-electron-reload')
? 'build:main'
: 'build:main:watch',
'build:renderer:watch'
)
);
gulp.task('clean:dist', shell.task('rimraf ./dist'));

gulp.task('build:themes', gulp.series('clean:dist', 'prepare:themes'));

Expand All @@ -193,33 +62,6 @@ gulp.task(
)
);

gulp.task('test:e2e:watch', gulp.series('build:watch', 'test:e2e:nodemon'));

gulp.task('purge:translations', shell.task('rimraf ./translations/messages'));

gulp.task('electron:inspector', shell.task('yarn electron:inspector'));

gulp.task(
'start',
shell.task(
`cross-env NODE_ENV=${process.env.NODE_ENV || 'production'} electron ./`
)
);

gulp.task(
'dev',
gulp.parallel(
gulp.series('server:create:dev', 'build:watch', 'server:start'),
gulp.series('typedef:sass')
)
);
gulp.task('e2e:watch', gulp.series('clean:dist', shell.task('yarn dev')));

gulp.task(
'debug',
gulp.series(
'server:create:debug',
'build:watch',
'server:start',
'electron:inspector'
)
);
gulp.task('test:e2e:watch', gulp.series('e2e:watch', 'test:e2e:nodemon'));
Loading

0 comments on commit 35f93ba

Please sign in to comment.