Skip to content

Commit

Permalink
fix: fix cjs requires + use cjs for commonjs files
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Oct 3, 2023
1 parent db12257 commit a3a3af8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lib/modules/example.mjs
test.mjs
**/*.cjs
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ node_modules
yarn.lock

# Custom
/lib/*.js
/lib/modules/*.js
/lib/presets/*.js
/lib/*.cjs
/lib/modules/*.cjs
/lib/presets/*.cjs
/test.cjs
/test.js
/index.js
/index.cjs

# Docs
/docs/build/
Expand Down
19 changes: 15 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"name": "htmlnano",
"version": "2.0.4",
"description": "Modular HTML minifier, built on top of the PostHTML",
"main": "index.js",
"main": "index.cjs",
"module": "index.mjs",
"source": "index.mjs",
"exports": {
".": {
"require": "./index.js",
"require": "./index.cjs",
"import": "./index.mjs"
}
},
"types": "index.d.ts",
"author": "Kirill Maltsev <maltsevkirill@gmail.com>",
"license": "MIT",
"scripts": {
"clean": "rimraf lib/*.js lib/**/*.js",
"compile": "npm run clean && babel -d lib/ lib/ && babel -d ./ ./*.mjs",
"clean": "rimraf lib/*.cjs lib/**/*.cjs",
"compile": "npm run clean && babel -d lib/ lib/ --out-file-extension .cjs && babel -d ./ ./*.mjs --out-file-extension .cjs",
"lint": "eslint --fix *.mjs lib/*.mjs lib/**/*.mjs test/*.mjs test/**/*.mjs",
"pretest": "npm run lint && npm run compile",
"test": ":",
Expand All @@ -40,6 +40,16 @@
}
}
]
],
"plugins": [
[
"replace-import-extension",
{
"extMapping": {
".mjs": ".cjs"
}
}
]
]
},
"dependencies": {
Expand All @@ -53,6 +63,7 @@
"@babel/eslint-parser": "^7.17.0",
"@babel/preset-env": "^7.15.6",
"@babel/register": "^7.15.3",
"babel-plugin-replace-import-extension": "^1.1.3",
"cssnano": "^6.0.0",
"eslint": "^8.12.0",
"eslint-plugin-import": "^2.28.1",
Expand Down

0 comments on commit a3a3af8

Please sign in to comment.