Skip to content

Commit

Permalink
feat: support both commonjs and esm
Browse files Browse the repository at this point in the history
  • Loading branch information
charsleysa committed Sep 23, 2024
1 parent f82e41c commit 80aa430
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
7 changes: 4 additions & 3 deletions package-lock.json

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

11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
"url": "git://github.com/charsleysa/node-sql-ts.git"
},
"type": "module",
"exports": "./dist/lib.js",
"exports": {
".": {
"import": "./dist/lib.js",
"require": "./dist/lib.cjs",
"types": "./dist/lib.d.ts"
}
},
"types": "./dist/lib.d.ts",
"scripts": {
"pretest": "eslint --ext .ts ./lib && eslint --ext .ts ./test && rollup -c && tsc -p ./test/tsconfig.json",
Expand All @@ -29,8 +35,7 @@
},
"dependencies": {
"lodash": "^4.17.21",
"sliced": "~1.0.x",
"tslib": "~2.7.0"
"sliced": "~1.0.x"
},
"devDependencies": {
"@rollup/plugin-typescript": "^11.1.6",
Expand Down
26 changes: 26 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,32 @@ export default [
})
]
},
{
input: './lib/index.ts',
output: {
file: './dist/lib.cjs',
format: 'commonjs',
sourcemap: true
},
external: [
'assert',
'lodash/defaults.js',
'lodash/flatten.js',
'lodash/fromPairs.js',
'lodash/isArray.js',
'lodash/isNumber.js',
'lodash/isFunction.js',
'lodash/map.js',
'lodash/padStart.js',
'lodash/reduce.js',
'sliced'
],
plugins: [
typescript({
tsconfig: './tsconfig.build.json'
})
]
},
{
input: './dist/dts/index.d.ts',
output: {
Expand Down

0 comments on commit 80aa430

Please sign in to comment.