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

build: migrate to esm #786

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions client/config/paths.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const path = require('node:path');
const fs = require('node:fs');

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
const appDirectory = path.resolve(path.join(__dirname, '../..'));
const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath);

const Paths = {
appBuild: resolveApp('dist/assets'),
appPublic: resolveApp('client/src/public/'),
appHtml: resolveApp('client/src/index.html'),
appIndex: resolveApp('client/src/javascript/app.tsx'),
appSrc: resolveApp('./'),
};

module.exports = Paths;
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const path = require('node:path');

const ESLintPlugin = require('eslint-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const WebpackBar = require('webpackbar');
const paths = require('../../shared/config/paths');

const paths = require('./paths.cjs');

module.exports = {
mode: 'development',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
const autoprefixer = require('autoprefixer');
const path = require('node:path');

const autoprefixer = require('autoprefixer');
const webpack = require('webpack');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const WebpackBar = require('webpackbar');
const paths = require('../../shared/config/paths');

// Assert this just to be safe.
// Development builds of React are slow and not intended for production.
if (process.env.NODE_ENV !== 'production') {
throw new Error('Production builds must have NODE_ENV=production.');
}
const paths = require('./paths.cjs');

module.exports = {
mode: 'production',
Expand Down
2 changes: 1 addition & 1 deletion client/scripts/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
const {choosePort, prepareUrls} = require('react-dev-utils/WebpackDevServerUtils');
const path = require('node:path');
const paths = require('../../shared/config/paths');
const config = require('../config/webpack.config.dev');
const config = require('../config/webpack.config.dev.cjs');

const {proxy: floodServerProxy} = require('yargs').env('FLOOD_OPTION_').option('proxy', {
default: 'http://127.0.0.1:3000',
Expand Down
2 changes: 1 addition & 1 deletion client/src/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"settings": {
"import/resolver": {
"webpack": {
"config": "client/config/webpack.config.dev.js"
"config": "client/config/webpack.config.dev.cjs"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import path from 'node:path';
import type {ClientConnectionSettings} from '@shared/schema/ClientConnectionSettings';
import type {Config} from '@shared/schema/Config';
import {configSchema} from '@shared/schema/Config';
import yargs from 'yargs/yargs';
import yargs from 'yargs';

import {version} from './package.json';

Expand Down
4 changes: 2 additions & 2 deletions distribution/debian/flood-bin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ VERSION = "4.8.2-0"
genrule(
name = "flood-pkg-arm64",
srcs = [
"dist/index.js",
"dist/index.mjs",
"package.json",
] + glob(["node_modules/**/*"]),
outs = ["arm64/flood"],
Expand All @@ -26,7 +26,7 @@ genrule(
genrule(
name = "flood-pkg-x64",
srcs = [
"dist/index.js",
"dist/index.mjs",
"package.json",
] + glob(["node_modules/**/*"]),
outs = ["x64/flood"],
Expand Down
2 changes: 1 addition & 1 deletion distribution/debian/flood/nodejs/links
Original file line number Diff line number Diff line change
@@ -1 +1 @@
flood/dist/index.js /usr/bin/flood
flood/dist/index.mjs /usr/bin/flood
2 changes: 1 addition & 1 deletion distribution/debian/flood/tests/pkg-js/test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
if [ -d dist ]; then
./dist/index.js --version
./dist/index.mjs --version
else
flood --version
fi
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "flood",
"version": "4.8.4",
"description": "A modern Web UI for various torrent clients with multi-user and multi-client support",
"type": "module",
"keywords": [
"typescript",
"react",
Expand Down Expand Up @@ -30,7 +31,7 @@
"SECURITY.md"
],
"bin": {
"flood": "dist/index.js"
"flood": "dist/index.mjs"
},
"pkg": {
"assets": [
Expand All @@ -47,15 +48,15 @@
]
},
"scripts": {
"build": "node scripts/build.js",
"build": "cross-env BABEL_ENV=production NODE_ENV=production node scripts/build.mjs",
"build-pkg": "rm -rf dist && npm run build && npm run pkg",
"pkg": "pkg . --out-path dist-pkg --no-bytecode --public --options=enable-source-maps",
"format-source": "prettier -w .",
"check-source-formatting": "prettier -c .",
"check-types": "tsc",
"lint": "NODE_ENV=development eslint --max-warnings 0 . --ext .js --ext .jsx --ext .ts --ext .tsx",
"prepack": "rm -rf dist && npm run build",
"start": "node --enable-source-maps --use_strict dist/index.js",
"start": "node --enable-source-maps --use_strict dist/index.mjs",
"start:development:client": "node client/scripts/development.js",
"start:development:server": "NODE_ENV=development tsx watch server/bin/start.ts",
"start:test:rtorrent": "node scripts/testsetup.js",
Expand Down Expand Up @@ -88,7 +89,7 @@
"@lingui/react": "^4.11.3",
"@maxmind/geoip2-node": "^5.0.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
"@seald-io/nedb": "^3.1.0",
"@seald-io/nedb": "^4.0.4",
"@types/bencode": "^2.0.1",
"@types/body-parser": "^1.19.2",
"@types/content-disposition": "^0.5.5",
Expand All @@ -105,7 +106,7 @@
"@types/jsonwebtoken": "^9.0.2",
"@types/lodash": "^4.14.195",
"@types/morgan": "^1.9.4",
"@types/node": "^16.18.105",
"@types/node": "^20.11.25",
"@types/parse-torrent": "^5.8.4",
"@types/passport": "^1.0.12",
"@types/passport-jwt": "^3.0.9",
Expand All @@ -126,11 +127,12 @@
"bencode": "^2.0.3",
"body-parser": "^1.20.2",
"case-sensitive-paths-webpack-plugin": "2.4.0",
"chalk": "^4.1.2",
"chalk": "^5.3.0",
"classnames": "^2.3.2",
"content-disposition": "^0.5.4",
"cookie-parser": "^1.4.6",
"create-torrent": "^5.0.9",
"cross-env": "^7.0.3",
"css-loader": "^6.8.1",
"css-minimizer-webpack-plugin": "^4.2.2",
"d3-array": "^3.2.4",
Expand Down Expand Up @@ -183,6 +185,7 @@
"postcss": "^8.4.24",
"postcss-loader": "^7.3.3",
"prettier": "^2.8.8",
"punycode": "^2.3.1",
"react": "^18.2.0",
"react-dev-utils": "^12.0.1",
"react-dom": "^18.2.0",
Expand Down Expand Up @@ -219,7 +222,7 @@
"zod": "^3.21.4"
},
"engines": {
"node": ">=16.0.0"
"node": ">=22.11.0"
},
"browserslist": [
"> 2%",
Expand Down
Loading
Loading