Skip to content

Commit 33f6819

Browse files
committed
feat: mime npm package
1 parent 67be273 commit 33f6819

File tree

7 files changed

+30
-37
lines changed

7 files changed

+30
-37
lines changed

.github/workflows/ci-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- uses: actions/setup-node@v4
1616
with:
17-
node-version: '20.17.0'
17+
node-version: '22.12.0'
1818

1919
- run: npm ci
2020
- run: npm run format:check

.github/workflows/ci-full.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: actions/checkout@v4
1515
- uses: actions/setup-node@v4
1616
with:
17-
node-version: '20.17.0'
17+
node-version: '22.12.0'
1818

1919
- run: npm ci
2020
- run: npm run format:check
@@ -47,7 +47,7 @@ jobs:
4747
- uses: actions/checkout@v4
4848
- uses: actions/setup-node@v4
4949
with:
50-
node-version: '20.16.0'
50+
node-version: '22.12.0'
5151
registry-url: 'https://registry.npmjs.org'
5252
- run: npm ci
5353
- run: npm run build

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change log
22

3+
## 1.6
4+
5+
### 1.6.0
6+
7+
- Using mime npm package instead of mime-types: I prefer to use standard text/javascript. It better meets today's requirements.
8+
39
## 1.5
410

511
### 1.5.2

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ In order to be able to easily update OTA, it is important - from the users' poin
1212

1313
This npm package provides a solution for **inserting any JS client application into the ESP web server** (PsychicHttp and also ESPAsyncWebServer available, PsychicHttp is the default). For this, JS, html, css, font, assets, etc. files must be converted to binary byte array. Npm mode is easy to use and easy to **integrate into your CI/CD pipeline**.
1414

15+
> Starting with version v1.6.0, mime npm package is used instead of mime-types (application/javascript -> text/javascript)
16+
1517
> Starting with version v1.5.0, PsychicHttp v2 is also supported.
1618
1719
> Version v1.4.0 has a breaking change! --no-gzip changed to --gzip. Starting with this version c++ compiler directives are available to setup operation in project level.

package-lock.json

Lines changed: 13 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelteesp32",
3-
"version": "1.5.2",
3+
"version": "1.6.0",
44
"description": "Convert Svelte (or any frontend) JS application to serve it from ESP32 webserver (PsychicHttp)",
55
"author": "BCsabaEngine",
66
"license": "ISC",
@@ -54,7 +54,6 @@
5454
"espasyncwebserver"
5555
],
5656
"devDependencies": {
57-
"@types/mime-types": "^2.1.4",
5857
"@types/node": "^22.10.1",
5958
"@typescript-eslint/eslint-plugin": "^8.17.0",
6059
"@typescript-eslint/parser": "^8.17.0",
@@ -71,7 +70,7 @@
7170
"dependencies": {
7271
"glob": "^11.0.0",
7372
"handlebars": "^4.7.8",
74-
"mime-types": "^2.1.35",
73+
"mime": "^4.0.4",
7574
"ts-command-line-args": "^2.5.1"
7675
}
7776
}

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { mkdirSync, writeFileSync } from 'node:fs';
44
import path from 'node:path';
55
import { gzipSync } from 'node:zlib';
66

7-
import { lookup } from 'mime-types';
7+
import mime from 'mime';
88

99
import { cmdLine } from './commandLine';
1010
import { greenLog, yellowLog } from './consoleColor';
@@ -31,7 +31,7 @@ console.log();
3131
console.log('Translation to header file');
3232
const longestFilename = [...files.keys()].reduce((p, c) => Math.max(c.length, p), 0);
3333
for (const [originalFilename, content] of files) {
34-
const mime = lookup(originalFilename) || 'text/plain';
34+
const mimeType = mime.getType(originalFilename) || 'text/plain';
3535
summary.filecount++;
3636

3737
const filename = originalFilename.replace(/\\/g, '/');
@@ -56,7 +56,7 @@ for (const [originalFilename, content] of files) {
5656
content,
5757
contentGzip: zipContent,
5858
isGzip: true,
59-
mime,
59+
mime: mimeType,
6060
md5
6161
});
6262
console.log(
@@ -72,7 +72,7 @@ for (const [originalFilename, content] of files) {
7272
content,
7373
contentGzip: content,
7474
isGzip: false,
75-
mime,
75+
mime: mimeType,
7676
md5
7777
});
7878
console.log(

0 commit comments

Comments
 (0)