Skip to content

Commit adfac69

Browse files
vladholubievclaude
andcommitted
chore: require Node.js 22 and clean up legacy documentation
Updated minimum Node.js version to 22 to align with modern JavaScript features and improved performance. Removed outdated version 3.x documentation and Lambda Layer references as the package now exclusively uses Docker images for better reliability. - Require Node.js 22 or higher in engines field - Remove legacy Lambda Layer documentation - Update all package manager references to pnpm - Simplify README by removing deprecated sections 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent dd747ce commit adfac69

File tree

2 files changed

+37
-45
lines changed

2 files changed

+37
-45
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"typescript": "5.9.2"
6969
},
7070
"engines": {
71-
"node": ">=16"
71+
"node": ">=22"
7272
},
7373
"publishConfig": {
7474
"access": "public"

readme.md

Lines changed: 36 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
## Install
66

77
```
8-
$ yarn add @shelf/aws-lambda-libreoffice
8+
$ pnpm add @shelf/aws-lambda-libreoffice
99
```
1010

1111
## Features
1212

13+
- **ESM Module Support**: Native ESM package with full TypeScript support
1314
- Includes CJK and X11 fonts bundled in the [base Docker image](https://github.com/shelfio/libreoffice-lambda-base-image)!
14-
- Relies on the latest LibreOffice 7.4 version which is not stripped down from features as a previous layer-based version of this package
15-
- Requires node.js 16x runtime (x86_64)
15+
- Relies on the latest LibreOffice 7.6 version which is not stripped down from features
16+
- Requires Node.js 22 or higher (x86_64)
1617

1718
## Requirements
1819

@@ -24,11 +25,11 @@ See the example at [libreoffice-lambda-base-image](https://github.com/shelfio/li
2425
Example:
2526

2627
```Dockerfile
27-
FROM public.ecr.aws/shelf/lambda-libreoffice-base:7.6-node18-x86_64
28+
FROM public.ecr.aws/shelf/lambda-libreoffice-base:7.6-node20-x86_64
2829

2930
COPY ./ ${LAMBDA_TASK_ROOT}/
3031

31-
RUN yarn install
32+
RUN pnpm install
3233

3334
CMD [ "handler.handler" ]
3435
```
@@ -40,14 +41,16 @@ CMD [ "handler.handler" ]
4041
- For larger files support, you can [extend Lambda's /tmp space](https://aws.amazon.com/blogs/aws/aws-lambda-now-supports-up-to-10-gb-ephemeral-storage/) using the `ephemeral-storage` parameter
4142
- Set environment variable `HOME` to `/tmp`
4243

43-
## Usage (For version 4.x; based on a Lambda Docker Image)
44+
## Usage (ESM)
4445

45-
Given you have packaged your Lambda function as a Docker image, you can now use this package:
46+
This package is now a native ESM module. If you're using CommonJS, you'll need to use dynamic imports or update your project to use ESM.
47+
48+
### ESM Usage (Recommended)
4649

4750
```javascript
48-
const {convertTo, canBeConvertedToPDF} = require('@shelf/aws-lambda-libreoffice');
51+
import {convertTo, canBeConvertedToPDF} from '@shelf/aws-lambda-libreoffice';
4952

50-
module.exports.handler = async () => {
53+
export const handler = async () => {
5154
// assuming there is a document.docx file inside /tmp dir
5255
// original file will be deleted afterwards
5356

@@ -60,20 +63,11 @@ module.exports.handler = async () => {
6063
};
6164
```
6265

63-
## Usage (For version 3.x; based on a Lambda Layer)
64-
65-
This version requires Node 12.x or higher.
66-
67-
**NOTE:** Since version 2.0.0 npm package no longer ships the 85 MB LibreOffice
68-
but relies upon [libreoffice-lambda-layer](https://github.com/shelfio/libreoffice-lambda-layer) instead.
69-
Follow the instructions on how to add a lambda layer in [that repo](https://github.com/shelfio/libreoffice-lambda-layer).
70-
71-
```js
72-
const {convertTo, canBeConvertedToPDF} = require('@shelf/aws-lambda-libreoffice');
66+
### CommonJS Usage (via dynamic import)
7367

68+
```javascript
7469
module.exports.handler = async () => {
75-
// assuming there is a document.docx file inside /tmp dir
76-
// original file will be deleted afterwards
70+
const {convertTo, canBeConvertedToPDF} = await import('@shelf/aws-lambda-libreoffice');
7771

7872
if (!canBeConvertedToPDF('document.docx')) {
7973
return false;
@@ -83,20 +77,6 @@ module.exports.handler = async () => {
8377
};
8478
```
8579

86-
Or if you want more control:
87-
88-
```js
89-
const {unpack, defaultArgs} = require('@shelf/aws-lambda-libreoffice');
90-
91-
await unpack(); // default path /tmp/instdir/program/soffice.bin
92-
93-
execSync(
94-
`/tmp/instdir/program/soffice.bin ${defaultArgs.join(
95-
' '
96-
)} --convert-to pdf file.docx --outdir /tmp`
97-
);
98-
```
99-
10080
## Troubleshooting
10181

10282
- Please allocate at least **3008 MB** of RAM for your Lambda function.
@@ -105,34 +85,46 @@ execSync(
10585

10686
## See Also
10787

108-
- [libreoffice-lambda-base-image](https://github.com/shelfio/libreoffice-lambda-base-image) - a base Docker image for you Lambdas
109-
- [libreoffice-lambda-layer](https://github.com/shelfio/libreoffice-lambda-layer) - deprecated, not updated anymore, used the Docker image above
88+
- [libreoffice-lambda-base-image](https://github.com/shelfio/libreoffice-lambda-base-image) - a base Docker image for your Lambdas
11089
- [serverless-libreoffice](https://github.com/vladgolubev/serverless-libreoffice) - original implementation
11190
- [aws-lambda-tesseract](https://github.com/shelfio/aws-lambda-tesseract)
11291
- [aws-lambda-brotli-unpacker](https://github.com/shelfio/aws-lambda-brotli-unpacker)
11392
- [chrome-aws-lambda](https://github.com/alixaxel/chrome-aws-lambda)
11493

11594
## Test
11695

117-
Beside unit tests that could be run via `yarn test`, there are integration tests.
96+
Beside unit tests that could be run via `pnpm test`, there are integration tests.
11897

119-
Smoke test that it works:
98+
### Running Tests
12099

121100
```sh
101+
# Unit tests
102+
pnpm test
103+
104+
# Integration test with Docker/Podman
122105
cd test
123106
./test.sh
124107

125-
# copy converted PDF file from container to the host to see if it's ok
126-
export CID=$(cat ./cid)
127-
docker cp $CID:/tmp/test.pdf ./test.pdf
108+
# The test will:
109+
# 1. Build the ESM code and transpile to CommonJS for Lambda compatibility
110+
# 2. Process all files in test-data/ directory
111+
# 3. Generate PDFs in the same test-data/ directory
112+
# 4. Show conversion summary
128113
```
129114

115+
The test setup includes:
116+
117+
- Automatic ESM to CommonJS transpilation using esbuild
118+
- Batch conversion of multiple file types (DOCX, HTML, etc.)
119+
- Volume mounting for easy PDF retrieval
120+
- Sample test files in `test/test-data/`
121+
130122
## Publish
131123

132124
```sh
133125
$ git checkout master
134-
$ yarn version
135-
$ yarn publish
126+
$ pnpm version
127+
$ pnpm publish
136128
$ git push origin master --tags
137129
```
138130

0 commit comments

Comments
 (0)