Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/deploy-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ jobs:
deploy:
uses: croct-tech/shared-public-configs/.github/workflows/publish-public-npm-package.yml@master
with:
build-dir: .
prepare-script: >-
cp package.json README.md build/ &&
cd build &&
tmp=$(mktemp) &&
jq --arg version "$GITHUB_REF_NAME" '.version = $version' package.json > "$tmp" &&
mv "$tmp" package.json
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ We recommend using [NPM](https://www.npmjs.com) to install the package:
npm install @croct/cache
```

The package ships both ESM and CommonJS entry points. ESM consumers can import named exports directly:

```ts
import {InMemoryCache} from '@croct/cache';
```

CommonJS consumers can load the matching CommonJS build with `require`:

```js
const {InMemoryCache} = require('@croct/cache');
```

All source modules are also available as subpath exports, for example `@croct/cache/inMemory`.

## Basic usage

The most common use case of this library is to decorate implementations with caching capabilities:
Expand Down Expand Up @@ -192,12 +206,25 @@ Before building the project, the dependencies must be installed:
npm install
```

The following command builds the library:
The following command builds the library with tsup:

```sh
npm run build
```

The build emits ESM, CommonJS, source map, and TypeScript declaration files in `build/` for the root entry point and each source module:

- `build/*.js` for ESM consumers
- `build/*.cjs` for CommonJS consumers
- `build/*.js.map` and `build/*.cjs.map` for runtime debugging
- `build/*.d.ts` and `build/*.d.cts` for TypeScript consumers

To verify the published package contract, including runtime exports, declaration resolution, and dry-run package contents, run:

```sh
npm run test:package
```

## License

Copyright © 2015-2021 Croct Limited, All Rights Reserved.
Expand Down
28 changes: 27 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@ import { defineConfig } from 'eslint/config';
import { configs } from '@croct/eslint-plugin';

export default defineConfig(
configs.typescript,
configs.typescript.map(config => ({
...config,
files: config.files ?? ['**/*.ts', '**/*.tsx'],
...(config.languageOptions === undefined
? {}
: {languageOptions: {
...config.languageOptions,
parserOptions: {
...config.languageOptions.parserOptions,
projectService: config.languageOptions.parserOptions?.projectService === true
? {allowDefaultProject: ['*.config.ts']}
: config.languageOptions.parserOptions?.projectService,
},
}}),
})),
{
files: ['src/**/*.ts'],
rules: {
'import-x/extensions': 'off',
'no-restricted-syntax': [
'error',
{
Expand Down Expand Up @@ -53,5 +68,16 @@ export default defineConfig(
},
],
},
},
{
files: ['tsup.config.ts'],
languageOptions: {
parserOptions: {
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'import-x/no-default-export': 'off',
},
}
);
7 changes: 0 additions & 7 deletions jest.config.js

This file was deleted.

17 changes: 17 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
restoreMocks: true,
resetMocks: true,
extensionsToTreatAsEsm: ['.ts'],
transform: {
'^.+\\.ts$': [
'ts-jest',
{
useESM: true,
},
],
},
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
setupFilesAfterEnv: ['<rootDir>/test/setup-jest.mjs'],
};
Loading
Loading