Skip to content

Commit 958c2a4

Browse files
authored
fix: esm/cjs exports (#2101)
1 parent 71089c0 commit 958c2a4

24 files changed

+191
-33
lines changed

.changeset/fresh-moles-shake.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@react-spring/types': patch
3+
'@react-spring/core': patch
4+
'@react-spring/animated': patch
5+
'@react-spring/parallax': patch
6+
'@react-spring/rafz': patch
7+
'react-spring': patch
8+
'@react-spring/shared': patch
9+
'@react-spring/konva': patch
10+
'@react-spring/native': patch
11+
'@react-spring/three': patch
12+
'@react-spring/web': patch
13+
'@react-spring/zdog': patch
14+
---
15+
16+
fix types package

.changeset/warm-schools-sell.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'react-spring': patch
3+
'@react-spring/animated': patch
4+
'@react-spring/parallax': patch
5+
'@react-spring/shared': patch
6+
'@react-spring/types': patch
7+
'@react-spring/native': patch
8+
'@react-spring/core': patch
9+
'@react-spring/rafz': patch
10+
'@react-spring/konva': patch
11+
'@react-spring/three': patch
12+
'@react-spring/zdog': patch
13+
'@react-spring/web': patch
14+
---
15+
16+
chore: add exports to package.json

packages/animated/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
"version": "9.7.0",
44
"description": "Animated component props for React",
55
"main": "dist/index.js",
6-
"module": "dist/index.mjs",
6+
"module": "dist/esm/index.js",
77
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/esm/index.js",
12+
"module": "./dist/esm/index.js",
13+
"require": "./dist/index.js"
14+
},
15+
"./package.json": "./package.json"
16+
},
817
"files": [
918
"dist/*",
1019
"README.md",
@@ -29,7 +38,7 @@
2938
"Josh Ellis (https://github.com/joshuaellis)"
3039
],
3140
"scripts": {
32-
"build": "tsup",
41+
"build": "tsup --legacy-output",
3342
"dev": "tsup"
3443
},
3544
"dependencies": {

packages/core/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
"name": "@react-spring/core",
33
"version": "9.7.0",
44
"main": "dist/index.js",
5-
"module": "dist/index.mjs",
5+
"module": "dist/esm/index.js",
66
"types": "dist/index.d.ts",
7+
"exports": {
8+
".": {
9+
"types": "./dist/index.d.ts",
10+
"import": "./dist/esm/index.js",
11+
"module": "./dist/esm/index.js",
12+
"require": "./dist/index.js"
13+
},
14+
"./package.json": "./package.json"
15+
},
716
"files": [
817
"dist/*",
918
"README.md",
@@ -32,7 +41,7 @@
3241
"Josh Ellis (https://github.com/joshuaellis)"
3342
],
3443
"scripts": {
35-
"build": "tsup",
44+
"build": "tsup --legacy-output",
3645
"dev": "tsup"
3746
},
3847
"dependencies": {

packages/core/src/index.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ export {
2121
export { inferTo } from './helpers'
2222

2323
export * from './types'
24-
export type { UnknownProps } from '@react-spring/types'
25-
export * from '@react-spring/types/animated'
26-
export * from '@react-spring/types/interpolation'
24+
export * from '@react-spring/types'

packages/parallax/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
"name": "@react-spring/parallax",
33
"version": "9.7.0",
44
"main": "dist/index.js",
5-
"module": "dist/index.mjs",
5+
"module": "dist/esm/index.js",
66
"types": "dist/index.d.ts",
7+
"exports": {
8+
".": {
9+
"types": "./dist/index.d.ts",
10+
"import": "./dist/esm/index.js",
11+
"module": "./dist/esm/index.js",
12+
"require": "./dist/index.js"
13+
},
14+
"./package.json": "./package.json"
15+
},
716
"files": [
817
"dist/*",
918
"README.md",
@@ -28,7 +37,7 @@
2837
"Josh Ellis (https://github.com/joshuaellis)"
2938
],
3039
"scripts": {
31-
"build": "tsup",
40+
"build": "tsup --legacy-output",
3241
"dev": "tsup",
3342
"test": "vite serve ./test"
3443
},

packages/rafz/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
"version": "9.7.0",
44
"description": "react-spring's fork of rafz one frameloop to rule them all",
55
"main": "dist/index.js",
6-
"module": "dist/index.mjs",
6+
"module": "dist/esm/index.js",
77
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/esm/index.js",
12+
"module": "./dist/esm/index.js",
13+
"require": "./dist/index.js"
14+
},
15+
"./package.json": "./package.json"
16+
},
817
"files": [
918
"dist/*",
1019
"README.md",
@@ -26,7 +35,7 @@
2635
"license": "MIT",
2736
"author": "Josh Ellis",
2837
"scripts": {
29-
"build": "tsup",
38+
"build": "tsup --legacy-output",
3039
"dev": "tsup"
3140
}
3241
}

packages/react-spring/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
"name": "react-spring",
33
"version": "9.7.0",
44
"main": "dist/index.js",
5-
"module": "dist/index.mjs",
5+
"module": "dist/esm/index.js",
66
"types": "dist/index.d.ts",
7+
"exports": {
8+
".": {
9+
"types": "./dist/index.d.ts",
10+
"import": "./dist/esm/index.js",
11+
"module": "./dist/esm/index.js",
12+
"require": "./dist/index.js"
13+
},
14+
"./package.json": "./package.json"
15+
},
716
"files": [
817
"dist/*",
918
"README.md",
@@ -40,7 +49,7 @@
4049
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
4150
},
4251
"scripts": {
43-
"build": "tsup",
52+
"build": "tsup --legacy-output",
4453
"dev": "tsup"
4554
}
4655
}

packages/shared/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
"version": "9.7.0",
44
"description": "Globals and shared modules",
55
"main": "dist/index.js",
6-
"module": "dist/index.mjs",
6+
"module": "dist/esm/index.js",
77
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/esm/index.js",
12+
"module": "./dist/esm/index.js",
13+
"require": "./dist/index.js"
14+
},
15+
"./package.json": "./package.json"
16+
},
817
"files": [
918
"dist/*",
1019
"README.md",
@@ -36,7 +45,7 @@
3645
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
3746
},
3847
"scripts": {
39-
"build": "tsup",
48+
"build": "tsup --legacy-output",
4049
"dev": "tsup"
4150
}
4251
}

packages/types/animated.js

Whitespace-only changes.

packages/types/index.js

Whitespace-only changes.

packages/types/interpolation.js

Whitespace-only changes.

packages/types/package.json

+22-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,23 @@
22
"name": "@react-spring/types",
33
"version": "9.7.0",
44
"description": "Internal package with TypeScript stuff",
5-
"main": "index.js",
6-
"types": "index.d.ts",
5+
"main": "dist/index.js",
6+
"module": "dist/esm/index.js",
7+
"types": "dist/index.d.ts",
8+
"exports": {
9+
".": {
10+
"types": "./dist/index.d.ts",
11+
"import": "./dist/esm/index.js",
12+
"module": "./dist/esm/index.js",
13+
"require": "./dist/index.js"
14+
},
15+
"./package.json": "./package.json"
16+
},
17+
"files": [
18+
"dist/*",
19+
"README.md",
20+
"LICENSE"
21+
],
722
"repository": "pmndrs/react-spring",
823
"homepage": "https://github.com/pmndrs/react-spring#readme",
924
"keywords": [
@@ -21,5 +36,9 @@
2136
"author": "Paul Henschel",
2237
"maintainers": [
2338
"Josh Ellis (https://github.com/joshuaellis)"
24-
]
39+
],
40+
"scripts": {
41+
"build": "tsup --legacy-output",
42+
"dev": "tsup"
43+
}
2544
}
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export * from './animated'
22
export * from './interpolation'
3-
export * from './util'
3+
export * from './utils'

packages/types/interpolation.d.ts renamed to packages/types/src/interpolation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Arrify, Constrain } from './util'
1+
import { Arrify, Constrain } from './utils'
22
import { Animatable } from './animated'
33

44
export type EasingFunction = (t: number) => number

packages/types/util.d.ts renamed to packages/types/src/utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export interface UnknownProps extends Lookup<unknown> {}
9292

9393
/** Use `[T] extends [Any]` to know if a type parameter is `any` */
9494
export class Any {
95+
// @ts-ignore
9596
private _: never
9697
}
9798

packages/types/tsup.config.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from 'tsup'
2+
import { defaultConfig } from '../../tsup.config.base'
3+
4+
export default defineConfig(opts => {
5+
return defaultConfig(
6+
{
7+
entry: ['src/index.ts'],
8+
outDir: 'dist',
9+
},
10+
opts
11+
)
12+
})

scripts/version-and-publish.sh

-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ if [[ -z "$distTag" ]]; then
1818
read -r distTag
1919
fi
2020

21-
22-
echo "$version"
23-
2421
# publish packages
2522
./node_modules/.bin/changeset version --snapshot "$version"
2623
./node_modules/.bin/changeset publish --no-git-tag --snapshot --tag "$distTag"

targets/konva/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
"name": "@react-spring/konva",
33
"version": "9.7.0",
44
"main": "dist/index.js",
5-
"module": "dist/index.mjs",
5+
"module": "dist/esm/index.js",
66
"types": "dist/index.d.ts",
7+
"exports": {
8+
".": {
9+
"types": "./dist/index.d.ts",
10+
"import": "./dist/esm/index.js",
11+
"module": "./dist/esm/index.js",
12+
"require": "./dist/index.js"
13+
},
14+
"./package.json": "./package.json"
15+
},
716
"files": [
817
"dist/*",
918
"README.md",
@@ -39,7 +48,7 @@
3948
"react-konva": "^16.8.0 || ^16.8.7-0 || ^16.9.0-0 || ^16.10.1-0 || ^16.12.0-0 || ^16.13.0-0 || ^17.0.0-0 || ^17.0.1-0 || ^17.0.2-0 || ^18.0.0-0"
4049
},
4150
"scripts": {
42-
"build": "tsup",
51+
"build": "tsup --legacy-output",
4352
"dev": "tsup"
4453
}
4554
}

targets/native/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
"name": "@react-spring/native",
33
"version": "9.7.0",
44
"main": "dist/index.js",
5-
"module": "dist/index.mjs",
5+
"module": "dist/esm/index.js",
66
"types": "dist/index.d.ts",
7+
"exports": {
8+
".": {
9+
"types": "./dist/index.d.ts",
10+
"import": "./dist/esm/index.js",
11+
"module": "./dist/esm/index.js",
12+
"require": "./dist/index.js"
13+
},
14+
"./package.json": "./package.json"
15+
},
716
"files": [
817
"dist/*",
918
"README.md",
@@ -38,7 +47,7 @@
3847
"react-native": ">=0.58"
3948
},
4049
"scripts": {
41-
"build": "tsup",
50+
"build": "tsup --legacy-output",
4251
"dev": "tsup"
4352
}
4453
}

targets/three/package.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
"name": "@react-spring/three",
33
"version": "9.7.0",
44
"main": "dist/index.js",
5-
"module": "dist/index.mjs",
5+
"module": "dist/esm/index.js",
66
"types": "dist/index.d.ts",
7+
"exports": {
8+
".": {
9+
"types": "./dist/index.d.ts",
10+
"import": "./dist/esm/index.js",
11+
"module": "./dist/esm/index.js",
12+
"require": "./dist/index.js"
13+
},
14+
"./package.json": "./package.json"
15+
},
716
"files": [
817
"dist/*",
918
"README.md",
@@ -39,7 +48,7 @@
3948
"three": ">=0.126"
4049
},
4150
"scripts": {
42-
"build": "tsup",
51+
"build": "tsup --legacy-output",
4352
"dev": "tsup"
4453
}
4554
}

0 commit comments

Comments
 (0)