Skip to content

Commit fdbdaf1

Browse files
fix: dependencies, tree-shaking
1 parent 4867c5f commit fdbdaf1

File tree

4 files changed

+102
-43
lines changed

4 files changed

+102
-43
lines changed

package-lock.json

Lines changed: 30 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "ecctrl",
3-
"private": true,
4-
"version": "1.0.0",
3+
"version": "1.0.30",
54
"author": "Erdong Chen",
65
"license": "MIT",
76
"description": "A floating rigibody character controller for R3F",
@@ -17,27 +16,44 @@
1716
"type": "git",
1817
"url": "git+https://github.com/pmndrs/ecctrl.git"
1918
},
19+
"files": [
20+
"dist/*",
21+
"src/*"
22+
],
2023
"type": "module",
21-
"scripts": {
22-
"dev": "vite",
23-
"build": "vite build",
24-
"preview": "vite preview"
24+
"types": "./dist/Ecctrl.d.ts",
25+
"main": "./dist/Ecctrl.cjs",
26+
"module": "./dist/Ecctrl.js",
27+
"exports": {
28+
"require": "./dist/Ecctrl.cjs",
29+
"import": "./dist/Ecctrl.js"
2530
},
31+
"sideEffects": false,
2632
"devDependencies": {
33+
"@types/react": "^18.2.28",
2734
"@types/react-dom": "^18.2.8",
2835
"@vitejs/plugin-react": "^4.1.0",
36+
"r3f-perf": "^7.1.2",
37+
"react": "^18.2.0",
38+
"react-dom": "^18.2.0",
39+
"three": "^0.153.0",
2940
"typescript": "^5.2.2",
3041
"vite": "^4.3.9"
3142
},
3243
"dependencies": {
33-
"@react-three/drei": "^9.83.3",
34-
"@react-three/fiber": "^8.13.3",
35-
"@react-three/rapier": "^1.1.1",
44+
"@react-three/drei": "^9",
45+
"@react-three/rapier": "^1",
3646
"leva": "^0.9.34",
37-
"r3f-perf": "^7.1.2",
38-
"react": "18.2",
39-
"react-dom": "18.2",
40-
"three": "^0.153.0",
4147
"zustand": "^4.4.1"
48+
},
49+
"peerDependencies": {
50+
"@react-three/fiber": "^8.13.3",
51+
"react": ">=18",
52+
"three": ">=0.133"
53+
},
54+
"scripts": {
55+
"dev": "vite",
56+
"build": "vite build",
57+
"preview": "vite preview"
4258
}
4359
}

src/stores/useGame.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { create } from "zustand";
22
import { subscribeWithSelector } from "zustand/middleware";
33

4-
export const useGame = create(
5-
subscribeWithSelector<State>((set) => {
4+
export const useGame = /* @__PURE__ */ create(
5+
/* @__PURE__ */ subscribeWithSelector<State>((set) => {
66
return {
77
/**
88
* Character animations state manegement

vite.config.js

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
1+
import { defineConfig } from 'vite'
2+
import * as path from 'node:path'
13
import react from '@vitejs/plugin-react'
24

35
const isCodeSandbox = 'SANDBOX_URL' in process.env || 'CODESANDBOX_HOST' in process.env
46

5-
export default {
6-
plugins:
7-
[
8-
react()
9-
],
10-
root: 'src/',
11-
publicDir: "../public/",
12-
base: './',
13-
server:
14-
{
15-
host: true,
16-
open: !isCodeSandbox // Open if it's not a CodeSandbox
7+
const dev = defineConfig({
8+
plugins: [react()],
9+
root: 'src/',
10+
publicDir: "../public/",
11+
base: './',
12+
server: {
13+
host: true,
14+
open: !isCodeSandbox // Open if it's not a CodeSandbox
15+
},
16+
})
17+
18+
const build = defineConfig({
19+
publicDir: false,
20+
build: {
21+
minify: false,
22+
sourcemap: true,
23+
target: 'es2018',
24+
lib: {
25+
formats: ['cjs', 'es'],
26+
entry: 'src/Ecctrl.tsx',
27+
fileName: '[name]',
1728
},
18-
build:
19-
{
20-
outDir: '../dist',
21-
emptyOutDir: true,
22-
sourcemap: false
29+
rollupOptions: {
30+
external: (id) => !id.startsWith('.') && !path.isAbsolute(id),
31+
output: {
32+
sourcemapExcludeSources: true,
33+
},
2334
}
24-
}
35+
},
36+
plugins: [
37+
{
38+
name: 'vite-tsc',
39+
generateBundle(options) {
40+
const ext = options.format === 'es' ? 'ts' : 'cts'
41+
this.emitFile({ type: 'asset', fileName: `Ecctrl.d.${ext}`, source: `export * from '../src/Ecctrl.tsx'` })
42+
},
43+
},
44+
]
45+
})
46+
47+
export default process.argv[2] ? build : dev

0 commit comments

Comments
 (0)