Skip to content

Commit

Permalink
fix exports in package.json, add index.d.cts to dist
Browse files Browse the repository at this point in the history
  • Loading branch information
nygardk committed Feb 11, 2024
1 parent 31724a0 commit 1c50111
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-boxes-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-share": patch
---

Fixed `exports` in package.json to comply with the `publint` and `attw` tools. May solve issues when your project uses CommonJS modules and Node.js v16 or newer.
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"sideEffects": false,
"files": [
"dist"
],
"files": ["dist"],
"scripts": {
"build": "vite build",
"build-demo": "vite build --config vite.demo.config.js",
Expand Down
12 changes: 11 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ import dts from 'vite-plugin-dts';
const { dependencies, peerDependencies } = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));

export default defineConfig({
plugins: [react(), dts({ rollupTypes: true })],
plugins: [
react(),
dts({
rollupTypes: true,
afterBuild: () => {
// https://github.com/qmhc/vite-plugin-dts/issues/267
fs.copyFileSync('dist/index.d.ts', 'dist/index.d.cts');
},
}),
],

build: {
target: 'es2017',
lib: {
Expand Down

0 comments on commit 1c50111

Please sign in to comment.