Skip to content

Commit 2d0342e

Browse files
feat: INT-11 switch to esbuild, upgrade is-image package
1 parent 8f83dc7 commit 2d0342e

File tree

8 files changed

+45
-23
lines changed

8 files changed

+45
-23
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ lib/
66
*.log
77
.DS_Store
88
yarn.lock
9-
test.js
109
!.husky/_/husky.sh

esbuild.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires
2+
require('esbuild').buildSync({
3+
entryPoints: ['src/index.ts'],
4+
bundle: true,
5+
platform: 'node',
6+
outfile: 'lib/index.js',
7+
});

jest.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const ES_PACKAGES_TO_TRANSFORM = ['is-image'];
2+
3+
/** @type {import("jest").Config} */
4+
const config = {
5+
transform: {
6+
'^.+\\.(t|j)sx?$': [
7+
'@swc/jest',
8+
{
9+
jsc: {
10+
parser: {
11+
syntax: 'typescript',
12+
},
13+
},
14+
},
15+
],
16+
},
17+
transformIgnorePatterns: [
18+
`node_modules/(?!(${ES_PACKAGES_TO_TRANSFORM.join('|')}))/node_modules/.+\\.js`,
19+
],
20+
};
21+
22+
module.exports = config;

package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"bin/tt.tar.gz"
2323
],
2424
"scripts": {
25-
"build": "rm -rf lib/ && yarn build:types && babel src --out-dir lib --ignore '**/*.test.ts' --extensions '.ts'",
25+
"build": "rm -rf lib/ && yarn build:types && node esbuild.js",
2626
"build:types": "tsc --emitDeclarationOnly --declaration --isolatedModules false --declarationDir lib",
2727
"coverage": "jest --coverage",
2828
"lint": "yarn lint:ci --fix",
@@ -40,25 +40,20 @@
4040
"eslint --fix"
4141
]
4242
},
43-
"babel": {
44-
"extends": "@shelf/babel-config/backend"
45-
},
4643
"prettier": "@shelf/prettier-config",
4744
"dependencies": {
48-
"is-image": "3.1.0",
45+
"is-image": "4.0.0",
4946
"tar": "6.2.0"
5047
},
5148
"devDependencies": {
52-
"@babel/cli": "7.23.0",
53-
"@babel/core": "7.23.2",
54-
"@babel/preset-env": "7.23.2",
55-
"@babel/preset-typescript": "7.22.15",
56-
"@shelf/babel-config": "2.0.2",
5749
"@shelf/eslint-config": "3.10.0",
5850
"@shelf/prettier-config": "1.0.0",
51+
"@swc/core": "1.3.96",
52+
"@swc/jest": "0.2.29",
5953
"@types/jest": "29.5.8",
6054
"@types/node": "18",
6155
"@types/tar": "6.1.7",
56+
"esbuild": "0.19.5",
6257
"eslint": "8.48.0",
6358
"husky": "8.0.3",
6459
"jest": "29.7.0",

test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const {execSync} = require('child_process');
2+
const {getTextFromImage} = require('./lib/index.js');
3+
4+
module.exports = {
5+
handler() {
6+
execSync(`cp ./test.png /tmp/test.png`);
7+
8+
return getTextFromImage('/tmp/test.png');
9+
}
10+
}

test.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ cd bin
44
tar -xvzf tt.tar.gz
55
cd ..
66

7-
yarn babel test.ts --out-file test.js
8-
97
(sleep 5; curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"payload":"hello world!"}') &
108

119

test.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"target": "esnext"
1010
},
1111
"exclude": ["node_modules"],
12-
"include": ["src", "test.ts"]
12+
"include": ["src/index.ts"]
1313
}

0 commit comments

Comments
 (0)