Skip to content

Commit

Permalink
Add exports entry points to package.json
Browse files Browse the repository at this point in the history
This supports newer versions of Node and specifies different entrypoints
for import and require.

It also makes the public interface of the package explicit.
  • Loading branch information
lucaong committed May 30, 2022
1 parent 3db4f90 commit d405076
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 12 additions & 3 deletions package.json
Expand Up @@ -7,10 +7,19 @@
"es2015": "dist/es/index.js",
"type": "module",
"exports": {
"types": "dist/types/index.d.ts",
"require": "dist/cjs/index.cjs",
"default": "dist/es/index.js"
".": {
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.cjs",
"default": "./dist/es/index.js"
},
"./SearchableMap": {
"types": "./dist/types/SearchableMap.d.ts",
"require": "./dist/cjs/SearchableMap.cjs",
"default": "./dist/es/SearchableMap.js"
}
},
"unpkg": "./dist/umd/index.js",
"jsdelivr": "./dist/umd/index.js",
"types": "./dist/types/index.d.ts",
"author": "Luca Ongaro",
"homepage": "https://lucaong.github.io/minisearch/",
Expand Down
9 changes: 5 additions & 4 deletions rollup.config.js
Expand Up @@ -47,12 +47,13 @@ export default process.env.BENCHMARKS === 'true' ? [benchmarks] : [
config({ format: 'cjs', input: 'src/index.ts', output: 'cjs', dir: 'cjs', extension: 'cjs', exports: 'default' }),
config({ format: 'umd', input: 'src/index.ts', output: 'umd', name: 'MiniSearch' }),

// Type declarations
config({ format: 'es', input: 'src/index.ts', output: 'dts', dir: 'types', extension: 'd.ts' }),

// SearchableMap
config({ format: 'es', input: 'src/SearchableMap/SearchableMap.ts', output: 'es6' }),
config({ format: 'es', input: 'src/SearchableMap/SearchableMap.ts', output: 'es5m', dir: 'es5m' }),
config({ format: 'cjs', input: 'src/SearchableMap/SearchableMap.ts', output: 'cjs', dir: 'cjs', extension: 'cjs', exports: 'default' }),
config({ format: 'umd', input: 'src/SearchableMap/SearchableMap.ts', output: 'umd', name: 'MiniSearch' })
config({ format: 'umd', input: 'src/SearchableMap/SearchableMap.ts', output: 'umd', name: 'MiniSearch' }),

// Type declarations
config({ format: 'es', input: 'src/index.ts', output: 'dts', dir: 'types', extension: 'd.ts' }),
config({ format: 'es', input: 'src/SearchableMap/SearchableMap.ts', output: 'dts', dir: 'types', extension: 'd.ts' })
]

0 comments on commit d405076

Please sign in to comment.