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

Use esbuild instead of webpack #38

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 0 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"presets": ["@babel/preset-env"],
"plugins": ["add-module-exports"]
}
2 changes: 0 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"extends": "airbnb-base",
"parser": "babel-eslint",
"plugins": [
"babel",
"jest"
],
"env": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x, 21.x, 22.x]
node-version: [18.x, 20.x, 21.x, 22.x]

steps:
- uses: actions/checkout@v4
Expand Down
33 changes: 33 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const esbuild = require('esbuild');
const path = require('path');

// Common configuration
const commonConfig = {
entryPoints: [path.join(__dirname, '/src/jdate.js')],
bundle: true,
sourcemap: 'inline',
outfile: path.join(__dirname, '/lib/jdate.js'),
target: ['es2015'],
format: 'esm',
globalName: 'JDate'
};

// Development configuration
const devConfig = {
...commonConfig,
minify: false
};

// Production configuration
const prodConfig = {
...commonConfig,
minify: true,
outfile: path.join(__dirname, '/lib/jdate.min.js')
};

// Determine the mode
const mode = process.env.NODE_ENV || 'development';
const config = mode === 'development' ? devConfig : prodConfig;

// Build
esbuild.build(config).catch(() => process.exit(1));
34 changes: 14 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"version": "1.1.5",
"description": "A Jalali to Gregorian converter with support of formatting output",
"scripts": {
"start": "webpack --progress --colors --watch --env dev",
"lint": "eslint ./src --ext .js --cache",
"test": "jest",
"watch": "webpack --watch --config webpack.dev.js",
"build": "webpack --config webpack.pro.js && webpack --config webpack.dev.js"
"test": "yarn node --experimental-vm-modules $(yarn bin jest)",
"start": "webpack --progress --colors --watch --env dev",
"watch": "node esbuild.dev.js",
"build": "NODE_ENV=production node esbuild.js && NODE_ENV=development node esbuild.js"
},
"repository": {
"type": "git",
Expand All @@ -29,23 +29,17 @@
},
"homepage": "https://github.com/arashm/JDate",
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/preset-env": "^7.5.5",
"babel-eslint": "^10.0.2",
"babel-jest": "^27.2.0",
"babel-loader": "^8.0.6",
"babel-plugin-add-module-exports": "^1.0.2",
"eslint": "^7.5.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-babel": "^5.3.0",
"@babel/core": "^7.24.6",
"@babel/preset-env": "^7.24.6",
"babel-jest": "^29.7.0",
"esbuild": "^0.21.4",
"eslint": "^8.57.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-jest": "^24.0",
"jest": "^27.2.0",
"jest-cli": "^27.2.0",
"jest-date-mock": "^1.0.7",
"webpack": "^5.53.0",
"webpack-cli": "^4.8.0",
"webpack-merge": "^5.0.0"
"eslint-plugin-jest": "^28.5.0",
"jest": "^29.7.0",
"jest-cli": "^29.7.0",
"jest-date-mock": "^1.0.7"
},
"jest": {
"setupFiles": [
Expand Down
8 changes: 2 additions & 6 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export function replaceYear(str, date) {
return value;
}
case 'YY': {
const value = replaceYear(
str.replace(match, String(date.getFullYear()).slice(2)), date
);
const value = replaceYear(str.replace(match, String(date.getFullYear()).slice(2)), date);
return value;
}
default: {
Expand All @@ -67,9 +65,7 @@ export function replaceMonth(str, date) {
}
case 'MMM':
case 'MMMM': {
const value = replaceMonth(
str.replace(match, MONTH_NAMES[date.getMonth() - 1]), date
);
const value = replaceMonth(str.replace(match, MONTH_NAMES[date.getMonth() - 1]), date);
return value;
}
default: {
Expand Down
31 changes: 0 additions & 31 deletions webpack.common.js

This file was deleted.

7 changes: 0 additions & 7 deletions webpack.dev.js

This file was deleted.

9 changes: 0 additions & 9 deletions webpack.pro.js

This file was deleted.

Loading