Skip to content

Commit 81e8102

Browse files
authored
Merge pull request #1 from ja2-stracciatella/agentic
Agentic
2 parents c0687de + 32c77ae commit 81e8102

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+13802
-12921
lines changed

.erb/configs/.eslintrc

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
*/
44

55
import webpack from 'webpack';
6-
import webpackPaths from './webpack.paths';
7-
import { dependencies as externals } from '../../release/app/package.json';
6+
import webpackPaths from './webpack.paths.mts';
7+
import packageJson from '../../release/app/package.json' with { type: 'json' };
8+
9+
const { dependencies: externals } = packageJson;
810

911
const configuration: webpack.Configuration = {
1012
externals: [...Object.keys(externals || {})],
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { fileURLToPath } from 'url';
2+
import { dirname, join } from 'path';
3+
4+
const __filename = fileURLToPath(import.meta.url);
5+
const __dirname = dirname(__filename);
6+
7+
// Calculate paths similar to webpack.paths.ts
8+
const rootPath = join(__dirname, '../..');
9+
const srcPath = join(rootPath, 'src');
10+
const appNodeModulesPath = join(rootPath, 'release/app/node_modules');
11+
12+
// Webpack configuration for ESLint import resolution
13+
const webpackConfig = {
14+
resolve: {
15+
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
16+
modules: [srcPath, 'node_modules', appNodeModulesPath],
17+
},
18+
mode: 'development',
19+
target: ['web', 'electron-renderer'],
20+
};
21+
22+
export default webpackConfig;

.erb/configs/webpack.config.eslint.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
* Webpack config for development electron main process
33
*/
44

5-
import path from 'path';
5+
import path from 'node:path';
66
import webpack from 'webpack';
77
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
88
import { merge } from 'webpack-merge';
9-
import checkNodeEnv from '../scripts/check-node-env';
10-
import baseConfig from './webpack.config.base';
11-
import webpackPaths from './webpack.paths';
9+
import checkNodeEnv from '../scripts/check-node-env.mts';
10+
import baseConfig from './webpack.config.base.mts';
11+
import webpackPaths from './webpack.paths.mts';
1212

1313
// When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's
1414
// at the dev webpack config is not accidentally run in a production environment
@@ -37,7 +37,6 @@ const configuration: webpack.Configuration = {
3737
},
3838

3939
plugins: [
40-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4140
// @ts-ignore
4241
new BundleAnalyzerPlugin({
4342
analyzerMode: process.env.ANALYZE === 'true' ? 'server' : 'disabled',
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
* Webpack config for production electron main process
33
*/
44

5-
import path from 'path';
5+
import path from 'node:path';
66
import webpack from 'webpack';
77
import { merge } from 'webpack-merge';
88
import TerserPlugin from 'terser-webpack-plugin';
99
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
10-
import baseConfig from './webpack.config.base';
11-
import webpackPaths from './webpack.paths';
12-
import checkNodeEnv from '../scripts/check-node-env';
13-
import deleteSourceMaps from '../scripts/delete-source-maps';
10+
import baseConfig from './webpack.config.base.mts';
11+
import webpackPaths from './webpack.paths.mts';
12+
import checkNodeEnv from '../scripts/check-node-env.mts';
13+
import deleteSourceMaps from '../scripts/delete-source-maps.mts';
1414

1515
checkNodeEnv('production');
1616
deleteSourceMaps();
@@ -69,7 +69,7 @@ const configuration: webpack.Configuration = {
6969

7070
new webpack.NormalModuleReplacementPlugin(
7171
/^stracciatella-toolset$/,
72-
'../../src-rust/target/stracciatella-toolset.node'
72+
'../../src-rust/target/stracciatella-toolset.node',
7373
),
7474
],
7575

.erb/configs/webpack.config.preload.dev.ts renamed to .erb/configs/webpack.config.preload.dev.mts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import path from 'path';
1+
import path from 'node:path';
22
import webpack from 'webpack';
33
import { merge } from 'webpack-merge';
44
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
5-
import baseConfig from './webpack.config.base';
6-
import webpackPaths from './webpack.paths';
7-
import checkNodeEnv from '../scripts/check-node-env';
5+
import baseConfig from './webpack.config.base.mts';
6+
import webpackPaths from './webpack.paths.mts';
7+
import checkNodeEnv from '../scripts/check-node-env.mts';
88

99
// When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's
1010
// at the dev webpack config is not accidentally run in a production environment

.erb/configs/webpack.config.renderer.dev.dll.ts renamed to .erb/configs/webpack.config.renderer.dev.dll.mts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
*/
44

55
import webpack from 'webpack';
6-
import path from 'path';
6+
import path from 'node:path';
77
import { merge } from 'webpack-merge';
8-
import baseConfig from './webpack.config.base';
9-
import webpackPaths from './webpack.paths';
10-
import { dependencies } from '../../package.json';
11-
import checkNodeEnv from '../scripts/check-node-env';
8+
import baseConfig from './webpack.config.base.mts';
9+
import webpackPaths from './webpack.paths.mts';
10+
import packageJson from '../../package.json' with { type: 'json' };
11+
import checkNodeEnv from '../scripts/check-node-env.mts';
12+
import rendererModuleConfig from './webpack.module.renderer.mts';
1213

1314
checkNodeEnv('development');
1415

16+
const { dependencies } = packageJson;
1517
const dist = webpackPaths.dllPath;
1618

1719
const configuration: webpack.Configuration = {
@@ -26,9 +28,9 @@ const configuration: webpack.Configuration = {
2628
externals: ['fsevents', 'crypto-browserify'],
2729

2830
/**
29-
* Use `module` from `webpack.config.renderer.dev.js`
31+
* Use shared module configuration for renderer
3032
*/
31-
module: require('./webpack.config.renderer.dev').default.module,
33+
module: rendererModuleConfig,
3234

3335
entry: {
3436
renderer: Object.keys(dependencies || {}),

.erb/configs/webpack.config.renderer.dev.ts renamed to .erb/configs/webpack.config.renderer.dev.mts

Lines changed: 17 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import 'webpack-dev-server';
2-
import path from 'path';
3-
import fs from 'fs';
2+
import path from 'node:path';
3+
import fs from 'node:fs';
44
import webpack from 'webpack';
55
import HtmlWebpackPlugin from 'html-webpack-plugin';
66
import chalk from 'chalk';
77
import { merge } from 'webpack-merge';
8-
import { execSync, spawn } from 'child_process';
8+
import { execSync, spawn } from 'node:child_process';
99
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
10-
import baseConfig from './webpack.config.base';
11-
import webpackPaths from './webpack.paths';
12-
import checkNodeEnv from '../scripts/check-node-env';
10+
import baseConfig from './webpack.config.base.mts';
11+
import webpackPaths from './webpack.paths.mts';
12+
import checkNodeEnv from '../scripts/check-node-env.mts';
13+
import rendererModuleConfig from './webpack.module.renderer.mts';
1314

1415
// When an ESLint server is running, we can't set the NODE_ENV so we'll check if it's
1516
// at the dev webpack config is not accidentally run in a production environment
@@ -19,21 +20,15 @@ if (process.env.NODE_ENV === 'production') {
1920

2021
const port = process.env.PORT || 1212;
2122
const manifest = path.resolve(webpackPaths.dllPath, 'renderer.json');
22-
const skipDLLs =
23-
module.parent?.filename.includes('webpack.config.renderer.dev.dll') ||
24-
module.parent?.filename.includes('webpack.config.eslint');
2523

2624
/**
2725
* Warn if the DLL is not built
2826
*/
29-
if (
30-
!skipDLLs &&
31-
!(fs.existsSync(webpackPaths.dllPath) && fs.existsSync(manifest))
32-
) {
27+
if (!(fs.existsSync(webpackPaths.dllPath) && fs.existsSync(manifest))) {
3328
console.log(
3429
chalk.black.bgYellow.bold(
35-
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"'
36-
)
30+
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"',
31+
),
3732
);
3833
execSync('npm run postinstall');
3934
}
@@ -60,87 +55,13 @@ const configuration: webpack.Configuration = {
6055
},
6156
},
6257

63-
module: {
64-
rules: [
65-
{
66-
test: /\.s?css$/,
67-
use: [
68-
'style-loader',
69-
{
70-
loader: 'css-loader',
71-
options: {
72-
modules: true,
73-
sourceMap: true,
74-
importLoaders: 1,
75-
},
76-
},
77-
'sass-loader',
78-
],
79-
include: /\.module\.s?(c|a)ss$/,
80-
},
81-
{
82-
test: /\.s?css$/,
83-
use: ['style-loader', 'css-loader', 'sass-loader'],
84-
exclude: /\.module\.s?(c|a)ss$/,
85-
},
86-
{
87-
test: /\.less$/i,
88-
use: [
89-
// compiles Less to CSS
90-
'style-loader',
91-
'css-loader',
92-
{
93-
loader: 'less-loader',
94-
options: {
95-
lessOptions: {
96-
modifyVars: { '@primary-color': '#9d1e1c' },
97-
javascriptEnabled: true,
98-
},
99-
},
100-
},
101-
],
102-
},
103-
// Fonts
104-
{
105-
test: /\.(woff|woff2|eot|ttf|otf)$/i,
106-
type: 'asset/resource',
107-
},
108-
// Images
109-
{
110-
test: /\.(png|jpg|jpeg|gif)$/i,
111-
type: 'asset/resource',
112-
},
113-
// SVG
114-
{
115-
test: /\.svg$/,
116-
use: [
117-
{
118-
loader: '@svgr/webpack',
119-
options: {
120-
prettier: false,
121-
svgo: false,
122-
svgoConfig: {
123-
plugins: [{ removeViewBox: false }],
124-
},
125-
titleProp: true,
126-
ref: true,
127-
},
128-
},
129-
'file-loader',
130-
],
131-
},
132-
],
133-
},
58+
module: rendererModuleConfig,
13459
plugins: [
135-
...(skipDLLs
136-
? []
137-
: [
138-
new webpack.DllReferencePlugin({
139-
context: webpackPaths.dllPath,
140-
manifest: require(manifest),
141-
sourceType: 'var',
142-
}),
143-
]),
60+
new webpack.DllReferencePlugin({
61+
context: webpackPaths.dllPath,
62+
manifest: JSON.parse(fs.readFileSync(manifest, 'utf8')),
63+
sourceType: 'var',
64+
}),
14465

14566
new webpack.NoEmitOnErrorsPlugin(),
14667

@@ -210,7 +131,7 @@ const configuration: webpack.Configuration = {
210131
let args = ['run', 'start:main'];
211132
if (process.env.MAIN_ARGS) {
212133
args = args.concat(
213-
['--', ...process.env.MAIN_ARGS.matchAll(/"[^"]+"|[^\s"]+/g)].flat()
134+
['--', ...process.env.MAIN_ARGS.matchAll(/"[^"]+"|[^\s"]+/g)].flat(),
214135
);
215136
}
216137
spawn('npm', args, {

.erb/configs/webpack.config.renderer.prod.ts renamed to .erb/configs/webpack.config.renderer.prod.mts

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
* Build config for electron renderer process
33
*/
44

5-
import path from 'path';
5+
import path from 'node:path';
66
import webpack from 'webpack';
77
import HtmlWebpackPlugin from 'html-webpack-plugin';
88
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
99
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
1010
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
1111
import { merge } from 'webpack-merge';
1212
import TerserPlugin from 'terser-webpack-plugin';
13-
import baseConfig from './webpack.config.base';
14-
import webpackPaths from './webpack.paths';
15-
import checkNodeEnv from '../scripts/check-node-env';
16-
import deleteSourceMaps from '../scripts/delete-source-maps';
13+
import baseConfig from './webpack.config.base.mts';
14+
import webpackPaths from './webpack.paths.mts';
15+
import checkNodeEnv from '../scripts/check-node-env.mts';
16+
import deleteSourceMaps from '../scripts/delete-source-maps.mts';
1717

1818
checkNodeEnv('production');
19-
deleteSourceMaps();
19+
await deleteSourceMaps();
2020

2121
const configuration: webpack.Configuration = {
2222
devtool: 'source-map',
@@ -59,23 +59,7 @@ const configuration: webpack.Configuration = {
5959
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
6060
exclude: /\.module\.s?(c|a)ss$/,
6161
},
62-
{
63-
test: /\.less$/i,
64-
use: [
65-
// compiles Less to CSS
66-
MiniCssExtractPlugin.loader,
67-
'css-loader',
68-
{
69-
loader: 'less-loader',
70-
options: {
71-
lessOptions: {
72-
modifyVars: { '@primary-color': '#9d1e1c' },
73-
javascriptEnabled: true,
74-
},
75-
},
76-
},
77-
],
78-
},
62+
7963
// Fonts
8064
{
8165
test: /\.(woff|woff2|eot|ttf|otf)$/i,
@@ -102,7 +86,6 @@ const configuration: webpack.Configuration = {
10286
ref: true,
10387
},
10488
},
105-
'file-loader',
10689
],
10790
},
10891
],

0 commit comments

Comments
 (0)