Skip to content

Commit

Permalink
Merge pull request #39 from futureforging/jrayback_240328_fix-module-…
Browse files Browse the repository at this point in the history
…issues-in-npm-package

Use @swc/jest, fix module exports for npm package
  • Loading branch information
jrayback authored Mar 28, 2024
2 parents 6819ecc + 447cd10 commit ec37bdb
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 13 deletions.
15 changes: 10 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/* eslint-disable @typescript-eslint/no-var-requires */

export * as cesr from './src/api/api.js'

Object.assign(module.exports, require('./src/api/api.js')) // presumably for CommonJS
// Note: Main entry point for the library
// This represents the public API of the library
export {
encodeRaw,
encodeText,
encodeBinary,
toRaw,
toText,
toBinary
} from './src/api/api.js'
11 changes: 6 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
// need esm preset to support esm modules
Expand All @@ -10,11 +11,11 @@ export default {
transform: {
// allows jest to resolve module paths to a .ts source file using a .js extension
// see dox for more information on this setting: https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/
'^.+\\.[tj]sx?$': [
'ts-jest',
{
useESM: true
}
'^.+\\.[t|j]sx?$': [
'@swc/jest' // use swc swap in for faster tests
// {
// useESM: true // don't seem to need this section when using @swc/jest
// }
]
},
// use a fancier test reporter
Expand Down
40 changes: 38 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@jrayback/simple-cesr",
"type": "module",
"version": "0.1.1",
"version": "0.1.2",
"description": "A simple, limited, true-to-spec implementation of the CESR protocol.",
"main": "dist/index.js",
"files": [
Expand Down Expand Up @@ -33,6 +33,7 @@
"devDependencies": {
"@swc/cli": "^0.3.10",
"@swc/core": "^1.4.11",
"@swc/jest": "^0.2.36",
"@tsconfig/node18": "^18.2.4",
"@types/jest": "^29.5.5",
"jest": "^29.7.0",
Expand Down

0 comments on commit ec37bdb

Please sign in to comment.