Skip to content

Commit

Permalink
DEV: support ESM and CommonJS import/require
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael O'Brien committed Feb 12, 2021
1 parent d76596b commit abe2b12
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ Import the library:
import {Model, Table} from 'dynamodb-onetable'
```

or

```javascript
const {Model, Table} = require('dynamodb-onetable')
```

Initialize your your Dynamo table instance and define your models via a schema.

```javascript
Expand Down
16 changes: 13 additions & 3 deletions fixup
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/bin/bash
#
# Rename to cjs/mjs after tsc build
# Add package.json files to cjs/mjs subtrees
#
mv dist/cjs/index.js dist/cjs/index.cjs
mv dist/mjs/index.js dist/mjs/index.mjs

cat >dist/cjs/package.json <<!EOF
{
"type": "commonjs"
}
!EOF

cat >dist/mjs/package.json <<!EOF
{
"type": "module"
}
!EOF
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
"name": "dynamodb-onetable",
"version": "0.6.10",
"description": "DynamoDB OneTable",
"type": "module",
"exports": {
".": {
"import": "./dist/mjs/index.mjs",
"require": "./dist/cjs/index.cjs"
"import": "./dist/mjs/index.js",
"require": "./dist/cjs/index.js"
}
},
"keywords": [
Expand Down

0 comments on commit abe2b12

Please sign in to comment.