Skip to content

Commit

Permalink
chore: migrate to package.json "exports" field
Browse files Browse the repository at this point in the history
  • Loading branch information
jiripudil committed Jul 7, 2024
1 parent 94e9916 commit b5ca1f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
"homepage": "https://naja.js.org",
"author": "Jiří Pudil",
"license": "MIT",
"main": "dist/Naja.js",
"unpkg": "dist/Naja.min.js",
"module": "dist/Naja.esm.js",
"types": "dist/index.esm.d.ts",
"exports": {
".": {
"import": "./dist/Naja.esm.js",
"types": "./dist/index.esm.d.ts",
"default": "./dist/Naja.js"
}
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
Expand Down
10 changes: 5 additions & 5 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default [
input: 'src/index.esm.ts',
output: {
...output,
file: pkg.module,
file: pkg.exports['.'].import,
format: 'esm',
},
external: [
Expand All @@ -35,7 +35,7 @@ export default [
input: 'src/index.esm.ts',
output: {
...output,
dir: path.dirname(pkg.module),
dir: path.dirname(pkg.exports['.'].types),
format: 'esm',
},
external: [
Expand All @@ -45,7 +45,7 @@ export default [
plugins: [
typescript({
declaration: true,
declarationDir: path.dirname(pkg.module),
declarationDir: path.dirname(pkg.exports['.'].types),
emitDeclarationOnly: true,
}),
],
Expand All @@ -55,7 +55,7 @@ export default [
input: 'src/index.ts',
output: {
...output,
file: pkg.unpkg,
file: pkg.exports['.'].default.replace(/\.js$/, '.min.js'),
format: 'umd',
name: 'naja',
},
Expand All @@ -72,7 +72,7 @@ export default [
input: 'src/index.ts',
output: {
...output,
file: pkg.main,
file: pkg.exports['.'].default,
format: 'umd',
name: 'naja',
},
Expand Down

0 comments on commit b5ca1f0

Please sign in to comment.