Skip to content
Open
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
10 changes: 9 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"presets": ["@babel/preset-env"]
"presets": [
["@babel/preset-env",
{
"targets": {
"node": "22"
}
}
]
]
}
29 changes: 14 additions & 15 deletions eslint.config.mjs → eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* eslint-disable import/no-extraneous-dependencies */

import node from 'eslint-plugin-node';
import n from 'eslint-plugin-n';
import promise from 'eslint-plugin-promise';
import proposal from 'eslint-plugin-proposal';
import es from 'eslint-plugin-es';
import pluginESx from 'eslint-plugin-es-x';
import impprtRules from 'eslint-plugin-import';
import { fixupPluginRules } from '@eslint/compat';
import globals from 'globals';
import babelParser from '@babel/eslint-parser';
import path from 'node:path';
Expand Down Expand Up @@ -33,9 +31,9 @@ export default [
),
{
plugins: {
es: fixupPluginRules(es),
'es-x': pluginESx,
impprtRules,
node: fixupPluginRules(node),
n,
promise,
proposal
},
Expand All @@ -53,7 +51,7 @@ export default [
},

parser: babelParser,
ecmaVersion: 2020,
ecmaVersion: 2024,
sourceType: 'module',

parserOptions: {
Expand Down Expand Up @@ -265,13 +263,14 @@ export default [
}
],
yoda: ['error', 'never'],
'es/no-async-iteration': 'error',
'es/no-malformed-template-literals': 'error',
'es/no-regexp-lookbehind-assertions': 'error',
'es/no-regexp-named-capture-groups': 'error',
'es/no-regexp-s-flag': 'error',
'es/no-regexp-unicode-property-escapes': 'error',
'es-x/no-async-iteration': 'error',
'es-x/no-malformed-template-literals': 'error',
'es-x/no-regexp-lookbehind-assertions': 'error',
'es-x/no-regexp-named-capture-groups': 'error',
'es-x/no-regexp-s-flag': 'error',
'es-x/no-regexp-unicode-property-escapes': 'error',
'import/export': 'error',
'import/extensions': ['error', 'always'],
'import/first': 'error',
'import/no-absolute-path': [
'error',
Expand All @@ -284,8 +283,8 @@ export default [
'import/no-duplicates': 'error',
'import/no-named-default': 'error',
'import/no-webpack-loader-syntax': 'error',
'node/no-deprecated-api': 'error',
'node/process-exit-as-throw': 'error',
'n/no-deprecated-api': 'error',
'n/process-exit-as-throw': 'error',
'promise/param-names': 'error'
}
}
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import express from 'express';
import cookieParser from 'cookie-parser';
import morgan from 'morgan';
import apiRouter from './routes/api';
import api_headers from './lib/api_headers';
import api_errors from './lib/api_errors';
import logger from './lib/logger';
import apiRouter from './routes/api.js';
import api_headers from './lib/api_headers.js';
import api_errors from './lib/api_errors.js';
import logger from './lib/logger.js';

const app = express();

Expand Down
File renamed without changes.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"name": "express-docker-template",
"version": "2.3.0",
"private": true,
"type":"module",
"scripts": {
"dev": "npx eslint --fix .; npx webpack watch --mode development",
"build": "echo 'Building production pack'; npx eslint .; npx webpack --mode production",
"start": "node ./bin/server.js",
"start": "node ./bin/server.cjs",
"lint:fix": "npx eslint --fix ."
},
"dependencies": {
Expand All @@ -21,16 +22,15 @@
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.26.10",
"@babel/preset-env": "^7.26.0",
"@eslint/compat": "^1.2.7",
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.22.0",
"babel-loader": "^10.0.0",
"eslint": "^9.18.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^10.1.1",
"eslint-plugin-es": "^4.1.0",
"eslint-plugin-es-x": "^8.7.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-n": "^17.21.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^7.2.1",
"eslint-plugin-proposal": "^2.3.3",
Expand All @@ -41,7 +41,6 @@
"terser-webpack-plugin": "^5.3.10",
"webpack": "^5.90.1",
"webpack-cli": "^6.0.1",
"webpack-dev-server": "^5.0.1",
"webpack-node-externals": "^3.0.0"
}
}
37 changes: 13 additions & 24 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,21 @@
const path = require('path');
const ESLintLoader = require('eslint-webpack-plugin');
const NodemonPlugin = require('nodemon-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const NodeExternals = require('webpack-node-externals');
import path from 'node:path';
import ESLintLoader from 'eslint-webpack-plugin';
import NodemonPlugin from 'nodemon-webpack-plugin';
import TerserPlugin from 'terser-webpack-plugin';
import NodeExternals from 'webpack-node-externals';

const pure_funcs = [];

if (process.env.ENV === 'prod') {
pure_funcs.push('console.log');
}

module.exports = {
export default {
entry: ['./'],
target: 'node',
// to have webpack emit esm, need to change options at both top level of this config and config for NodeExternals
output: {
filename: 'server.js',
path: path.resolve(__dirname, 'bin'),
filename: 'server.cjs',
path: path.resolve(import.meta.dirname, 'bin'),
publicPath: '/bin/'
},
externalsPresets: { node: true },
externals: [NodeExternals()],
devtool: 'inline-source-map',
devServer: {
port: 3888, // default: 8080
open: true, // open page in browser
static: {
directory: path.join(__dirname, 'public')
}
},
module: {
rules: [
{
Expand All @@ -42,10 +31,10 @@ module.exports = {
new TerserPlugin({
test: /\.(m|c)?(js)$/,
extractComments: true,
parallel: true,
terserOptions: {
compress: {
pure_funcs
ecma: '2024',
drop_console: process.env.ENV === 'prod'
}
}
})
Expand All @@ -60,7 +49,7 @@ module.exports = {
new NodemonPlugin({
// If using more than one entry, you can specify
// which output file will be restarted.
script: './bin/server.js',
script: './bin/server.cjs',

// What to watch.
watch: path.resolve('./bin'),
Expand Down
Loading