Browse Source

chore: adds CommonJS support

e22m4u 1 year ago
parent
commit
297f901136
4 changed files with 13729 additions and 6 deletions
  1. 1 0
      .husky/pre-commit
  2. 10 0
      build-cjs.js
  3. 13705 0
      dist/cjs/index.cjs
  4. 13 6
      package.json

+ 1 - 0
.husky/pre-commit

@@ -1,5 +1,6 @@
 npm run lint:fix
 npm run lint:fix
 npm run format
 npm run format
 npm run test
 npm run test
+npm run build:cjs
 
 
 git add -A
 git add -A

+ 10 - 0
build-cjs.js

@@ -0,0 +1,10 @@
+import * as esbuild from 'esbuild';
+
+await esbuild.build({
+  entryPoints: ['src/index.js'],
+  outfile: 'dist/cjs/index.cjs',
+  format: 'cjs',
+  platform: 'node',
+  target: ['node14'],
+  bundle: true,
+});

File diff suppressed because it is too large
+ 13705 - 0
dist/cjs/index.cjs


+ 13 - 6
package.json

@@ -3,16 +3,22 @@
   "version": "0.1.5",
   "version": "0.1.5",
   "description": "MongoDB адаптер для @e22m4u/js-repository",
   "description": "MongoDB адаптер для @e22m4u/js-repository",
   "type": "module",
   "type": "module",
-  "main": "src/index.js",
+  "module": "./src/index.js",
+  "main": "./dist/cjs/index.cjs",
+  "exports": {
+    "import": "./src/index.js",
+    "require": "./dist/cjs/index.cjs"
+  },
   "engines": {
   "engines": {
-    "node": ">=14"
+    "node": ">=14.20.1"
   },
   },
   "scripts": {
   "scripts": {
-    "lint": "eslint .",
-    "lint:fix": "eslint . --fix",
+    "lint": "eslint ./src",
+    "lint:fix": "eslint ./src --fix",
     "format": "prettier --write \"./src/**/*.js\"",
     "format": "prettier --write \"./src/**/*.js\"",
-    "test": "eslint . && c8 --reporter=text-summary mocha",
-    "test:coverage": "eslint . && c8 --reporter=text mocha",
+    "test": "eslint ./src && c8 --reporter=text-summary mocha",
+    "test:coverage": "eslint ./src && c8 --reporter=text mocha",
+    "build:cjs": "node build-cjs.js",
     "prepare": "husky"
     "prepare": "husky"
   },
   },
   "repository": {
   "repository": {
@@ -47,6 +53,7 @@
     "chai": "~5.1.1",
     "chai": "~5.1.1",
     "chai-as-promised": "~8.0.0",
     "chai-as-promised": "~8.0.0",
     "dotenv": "~16.4.5",
     "dotenv": "~16.4.5",
+    "esbuild": "~0.24.0",
     "eslint": "~9.12.0",
     "eslint": "~9.12.0",
     "eslint-config-prettier": "~9.1.0",
     "eslint-config-prettier": "~9.1.0",
     "eslint-plugin-chai-expect": "~3.1.0",
     "eslint-plugin-chai-expect": "~3.1.0",

Some files were not shown because too many files changed in this diff