Skip to content

Commit

Permalink
Fix JS module build scripts to know about all env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjozork committed Aug 5, 2023
1 parent 0cd7536 commit bdc53dd
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 166 deletions.
5 changes: 3 additions & 2 deletions fbw-a32nx/src/systems/atsu/common/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

const esbuild = require('esbuild');
const path = require('path');
const { esbuildModuleBuild, defineEnvVars } = require('#build-utils');

const rootDir = path.join(__dirname, '..', '..', '..', '..');
const outFile = 'out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/atsu/common.js';
const outFile = 'fbw-a32nx/out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/atsu/common.js';

const isProductionBuild = process.env.A32NX_PRODUCTION_BUILD === '1';

esbuild.build({
absWorkingDir: __dirname,

define: { DEBUG: 'false' },
define: { DEBUG: 'false', ...defineEnvVars() },

entryPoints: [path.join(rootDir, '../fbw-common/src/systems/datalink/common/src/index.ts')],
bundle: true,
Expand Down
27 changes: 3 additions & 24 deletions fbw-a32nx/src/systems/atsu/fmsclient/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,8 @@

const esbuild = require('esbuild');
const path = require('path');
const { esbuildModuleBuild } = require('#build-utils');

const rootDir = path.join(__dirname, '..', '..', '..');
const outFile = '../out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/atsu/fmsclient.js';
const outFile = 'fbw-a32nx/out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/atsu/fmsclient.js';

const isProductionBuild = process.env.A32NX_PRODUCTION_BUILD === '1';

esbuild.build({
absWorkingDir: __dirname,

define: { DEBUG: 'false' },

entryPoints: ['src/index.ts'],
bundle: true,
treeShaking: false,
minify: isProductionBuild,

outfile: path.join(rootDir, outFile),

format: 'iife',
globalName: 'AtsuFmsClient',

sourcemap: isProductionBuild ? 'linked' : undefined,

// Target approximate CoherentGT WebKit version
target: 'safari11',
});
esbuild.build(esbuildModuleBuild('AtsuFmsClient', path.join(__dirname, 'src/index.ts'), outFile));
26 changes: 3 additions & 23 deletions fbw-a32nx/src/systems/extras-host/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,8 @@

const esbuild = require('esbuild');
const path = require('path');
const { esbuildModuleBuild } = require('#build-utils');

const rootDir = path.join(__dirname, '..', '..', '..');
const outFile = 'out/flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX/ExtrasHost';
const outFile = 'fbw-a32nx/out/flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX/ExtrasHost/index.js';

const isProductionBuild = process.env.A32NX_PRODUCTION_BUILD === '1';

esbuild.build({
absWorkingDir: __dirname,

define: { 'DEBUG': 'false', 'process.env.CLIENT_ID': `'${process.env.CLIENT_ID}'`, 'process.env.CLIENT_SECRET': `'${process.env.CLIENT_SECRET}'` },

entryPoints: ['./index.ts'],
bundle: true,
treeShaking: false,
minify: isProductionBuild,

outdir: path.join(rootDir, outFile),

format: 'iife',

sourcemap: isProductionBuild ? 'linked' : undefined,

// Target approximate CoherentGT WebKit version
target: 'safari11',
});
esbuild.build(esbuildModuleBuild(undefined, path.join(__dirname, './index.ts'), outFile));
27 changes: 3 additions & 24 deletions fbw-a32nx/src/systems/fmgc/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,8 @@

const esbuild = require('esbuild');
const path = require('path');
const { esbuildModuleBuild } = require('#build-utils');

const rootDir = path.join(__dirname, '..', '..', '..');
const outFile = 'out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/fmgc/fmgc.js';
const outFile = 'fbw-a32nx/out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/fmgc/fmgc.js';

const isProductionBuild = process.env.A32NX_PRODUCTION_BUILD === '1';

esbuild.build({
absWorkingDir: __dirname,

define: { DEBUG: 'false' },

entryPoints: ['src/index.ts'],
bundle: true,
treeShaking: false,
minify: isProductionBuild,

outfile: path.join(rootDir, outFile),

format: 'iife',
globalName: 'Fmgc',

sourcemap: isProductionBuild ? 'linked' : undefined,

// Target approximate CoherentGT WebKit version
target: 'safari11',
});
esbuild.build(esbuildModuleBuild('Fmgc', path.join(__dirname, 'src/index.ts'), outFile));
26 changes: 3 additions & 23 deletions fbw-a32nx/src/systems/sentry-client/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,10 @@

const esbuild = require('esbuild');
const path = require('path');
const { esbuildModuleBuild } = require('#build-utils');

require('dotenv').config();

const rootDir = path.join(__dirname, '..', '..', '..');
const outFile = 'out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/sentry-client/sentry-client.js';
const outFile = 'fbw-a32nx/out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/sentry-client/sentry-client.js';

const isProductionBuild = process.env.A32NX_PRODUCTION_BUILD === '1';

esbuild.build({
absWorkingDir: __dirname,

define: { 'DEBUG': 'false', 'process.env.SENTRY_DSN': `'${process.env.SENTRY_DSN}'` },

entryPoints: ['src/index.ts'],
bundle: true,
treeShaking: false,
minify: isProductionBuild,

outfile: path.join(rootDir, outFile),

format: 'iife',

sourcemap: isProductionBuild ? 'linked' : undefined,

// Target approximate CoherentGT WebKit version
target: 'safari11',
});
esbuild.build(esbuildModuleBuild(undefined, path.join(__dirname, 'src/index.ts'), outFile));
27 changes: 3 additions & 24 deletions fbw-a32nx/src/systems/simbridge-client/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,8 @@

const esbuild = require('esbuild');
const path = require('path');
const { esbuildModuleBuild } = require('#build-utils');

const rootDir = path.join(__dirname, '..', '..', '..');
const outFile = 'out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/simbridge-client/simbridge-client.js';
const outFile = 'fbw-a32nx/out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/simbridge-client/simbridge-client.js';

const isProductionBuild = process.env.A32NX_PRODUCTION_BUILD === '1';

esbuild.build({
absWorkingDir: __dirname,

define: { DEBUG: 'false' },

entryPoints: ['src/index.ts'],
bundle: true,
treeShaking: false,
minify: isProductionBuild,

outfile: path.join(rootDir, outFile),

format: 'iife',
globalName: 'SimBridgeClient',

sourcemap: isProductionBuild ? 'linked' : undefined,

// Target approximate CoherentGT WebKit version
target: 'safari11',
});
esbuild.build(esbuildModuleBuild('SimBridgeClient', path.join(__dirname, 'src/index.ts'), outFile));
26 changes: 3 additions & 23 deletions fbw-a32nx/src/systems/systems-host/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,8 @@

const esbuild = require('esbuild');
const path = require('path');
const { esbuildModuleBuild } = require('#build-utils');

const rootDir = path.join(__dirname, '..', '..', '..');
const outFile = 'out/flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX/SystemsHost';
const outFile = 'fbw-a32nx/out/flybywire-aircraft-a320-neo/html_ui/Pages/VCockpit/Instruments/A32NX/SystemsHost/index.js';

const isProductionBuild = process.env.A32NX_PRODUCTION_BUILD === '1';

esbuild.build({
absWorkingDir: __dirname,

define: { 'DEBUG': 'false', 'process.env.CLIENT_ID': `'${process.env.CLIENT_ID}'`, 'process.env.CLIENT_SECRET': `'${process.env.CLIENT_SECRET}'` },

entryPoints: ['./index.ts'],
bundle: true,
treeShaking: false,
minify: isProductionBuild,

outdir: path.join(rootDir, outFile),

format: 'iife',

sourcemap: isProductionBuild ? 'linked' : undefined,

// Target approximate CoherentGT WebKit version
target: 'safari11',
});
esbuild.build(esbuildModuleBuild(undefined, path.join(__dirname, './index.ts'), outFile));
26 changes: 3 additions & 23 deletions fbw-a32nx/src/systems/tcas/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,8 @@

const esbuild = require('esbuild');
const path = require('path');
const { esbuildModuleBuild } = require('#build-utils');

const rootDir = path.join(__dirname, '..', '..', '..');
const outFile = 'out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/tcas/tcas.js';
const outFile = 'fbw-a32nx/out/flybywire-aircraft-a320-neo/html_ui/JS/fbw-a32nx/tcas/tcas.js';

const isProductionBuild = process.env.A32NX_PRODUCTION_BUILD === '1';

esbuild.build({
absWorkingDir: __dirname,

define: { DEBUG: 'false' },

entryPoints: ['src/index.ts'],
bundle: true,
treeShaking: false,
minify: isProductionBuild,

outfile: path.join(rootDir, outFile),

format: 'iife',

sourcemap: isProductionBuild ? 'linked' : undefined,

// Target approximate CoherentGT WebKit version
target: 'safari11',
});
esbuild.build(esbuildModuleBuild(undefined, path.join(__dirname, 'src/index.ts'), outFile));
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"name": "a32nx",
"version": "0.11.0",
"edition": "development",
"imports": {
"#build-utils": "./build-utils.js"
},
"scripts": {
"====== A320 =================": "==========================================",

Expand Down

0 comments on commit bdc53dd

Please sign in to comment.