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

Bundle code in main/ #700

Merged
merged 10 commits into from
Sep 7, 2022
10 changes: 5 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
npm config set //npm.nordicsemi.no/:_authToken $(WAYLAND_NPM_TOKEN_INTERNAL)
npm ci
npm run check
npm run build
npm run build:prod
npm test
condition: and(eq(variables['INTERNAL'], 'true'), contains(variables['IMAGE_NAME'], 'ubuntu'))
displayName: 'Build with internal release [Linux]'
Expand All @@ -85,7 +85,7 @@ jobs:
npm config set //npm.nordicsemi.no/:_authToken $(WAYLAND_NPM_TOKEN_INTERNAL)
npm ci
npm run check
npm run build
npm run build:prod
npm test
condition: and(eq(variables['INTERNAL'], 'true'), contains(variables['IMAGE_NAME'], 'mac'))
displayName: 'Build with internal release [macOS]'
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
- script: |
npm ci
npm run check
npm run build
npm run build:prod
npm test
env: {
ENABLE_DRAFT_TEST: true,
Expand All @@ -131,7 +131,7 @@ jobs:
set -o errexit -o pipefail
npm ci
npm run check
npm run build
npm run build:prod
npm test
condition: and(ne(variables['INTERNAL'], 'true'), not(contains(variables['IMAGE_NAME'], 'win')))
displayName: 'Build on not windows'
Expand All @@ -142,7 +142,7 @@ jobs:
npm config set node_gyp "C:\npm\prefix\node_modules\node-gyp\bin\node-gyp.js"
npm ci
npm run check
npm run build
npm run build:prod
npm test
condition: and(ne(variables['INTERNAL'], 'true'), contains(variables['IMAGE_NAME'], 'win'))
displayName: 'Build on windows'
Expand Down
20 changes: 20 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
*/

require('esbuild')
.build({
bundle: true,
color: true,
entryPoints: ['src/main/index.js'],
external: ['electron', './node_modules/*'],
jonasem marked this conversation as resolved.
Show resolved Hide resolved
logLevel: 'info',
outfile: 'dist/main.js',
platform: 'node',
sourcemap: true,
watch: process.argv.includes('--watch'),
minify: process.argv.includes('--prod'),
})
.catch(() => process.exit(1));
168 changes: 168 additions & 0 deletions package-lock.json

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

22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@
"type": "git",
"url": "https://github.com/NordicSemiconductor/pc-nrfconnect-launcher.git"
},
"main": "src/main",
"main": "dist/main.js",
"scripts": {
"postinstall": "node getJlink.js",
"app": "electron .",
"dev": "webpack watch --mode development",
"webpack": "webpack build --mode development",
"build": "webpack build",
"test": "jest src/",
"app": "NODE_OPTIONS=--enable-source-maps electron .",
jonasem marked this conversation as resolved.
Show resolved Hide resolved
"watch": "run-p --silent --continue-on-error --print-label watch:*",
"watch:main": "node esbuild.js --watch",
"watch:renderer": "webpack watch --mode development --color",
"build:dev": "run-p --silent --continue-on-error --print-label build:dev:*",
"build:dev:renderer": "webpack build --mode development --color",
"build:dev:main": "node esbuild.js",
"build:prod": "run-p --silent --continue-on-error --print-label build:prod:*",
"build:prod:renderer": "webpack build --color",
"build:prod:main": "node esbuild.js --prod",
"check": "run-p --silent --continue-on-error --print-label check:*",
"check:lint": "eslint --color .",
"check:types": "check-for-typescript tsc --noEmit --pretty",
"check:license": "nrfconnect-license check",
"test": "jest src/",
"test-e2e": "xvfb-maybe npx playwright test test-e2e/",
"pack": "npm run build && electron-builder -p never",
"pack": "npm run build:prod && electron-builder -p never",
"release": "electron-builder -p always",
"install-devtools": "electron . --install-devtools",
"remove-devtools": "electron . --remove-devtools"
Expand All @@ -35,7 +41,6 @@
],
"files": [
"dist/",
"src/main/",
"node_modules/",
"resources/*.html",
"resources/*.png",
Expand Down Expand Up @@ -88,6 +93,7 @@
"electron-builder": "^22.14.13",
"electron-devtools-installer": "3.2.0",
"electron-notarize": "0.3.0",
"esbuild": "0.14.49",
"mini-css-extract-plugin": "0.9.0",
"pc-nrfconnect-shared": "git+https://github.com/NordicSemiconductor/pc-nrfconnect-shared.git#v6.5.5",
"playwright": "^1.16.3",
Expand Down
11 changes: 3 additions & 8 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@
// eslint-disable-next-line strict,lines-around-directive -- because we are not inside a module, using strict is helpful here
'use strict';

// Run this as soon as possible, so that the user data folder is not already initialised by Electron
require('./setUserDataDir');
// Run this as soon as possible, so it is set up for the other modules to be loaded afterwards
require('./init');

require('@electron/remote/main').initialize();

const { argv } = require('yargs');
// eslint-disable-next-line import/order -- The config needs to be loaded and initialised early, because it is used in other modules, sometimes while loading them
const config = require('./config');

config.init(argv);

const {
Menu,
ipcMain,
Expand All @@ -27,6 +21,7 @@ const {
} = require('electron');
const { join } = require('path');

const config = require('./config');
const windows = require('./windows');
const apps = require('./apps');
const { createMenu } = require('./menu');
Expand Down
12 changes: 12 additions & 0 deletions src/main/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
*/

require('./setUserDataDir');

const { argv } = require('yargs');
const config = require('./config');

config.init(argv);