Skip to content

Commit aaefe67

Browse files
authored
chore(internals): [v6] use preconstruct
Merge pull request #1067 from pmndrs/v6/preconstruct
1 parent 1a60e6d commit aaefe67

File tree

7 files changed

+505
-1185
lines changed

7 files changed

+505
-1185
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
node_modules/
3+
.yarn/

babel.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const { version } = require('./package.json');
2+
3+
const versionTransform = ({ types: t }) => ({
4+
visitor: {
5+
Identifier(path) {
6+
(path.node.name === 'R3F_VERSION') && path.replaceWith(t.stringLiteral(version));
7+
},
8+
},
9+
})
10+
11+
module.exports = {
12+
plugins: [versionTransform],
13+
presets: [
14+
[
15+
'@babel/preset-env',
16+
{
17+
targets: {
18+
esmodules: true,
19+
},
20+
},
21+
],
22+
'@babel/preset-react',
23+
'@babel/preset-typescript',
24+
],
25+
}

package.json

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"type": "opencollective",
2424
"url": "https://opencollective.com/react-three-fiber"
2525
},
26-
"main": "dist/index.cjs.js",
27-
"module": "dist/index.js",
26+
"main": "dist/react-three-fiber.cjs.js",
27+
"module": "dist/react-three-fiber.esm.js",
28+
"types": "dist/react-three-fiber.cjs.d.ts",
2829
"react-native": "dist/native.js",
29-
"types": "dist/web/index.d.ts",
3030
"sideEffects": false,
3131
"husky": {
3232
"hooks": {
@@ -39,18 +39,17 @@
3939
]
4040
},
4141
"scripts": {
42-
"prebuild": "rimraf dist && npm run typegen",
43-
"build": "rollup -c && rimraf dist/__tests__",
42+
"build": "preconstruct build",
43+
"dev": "preconstruct dev",
4444
"prepare": "husky install",
4545
"eslint": "eslint --fix src/**/*.{ts,tsx}",
46-
"dev": "yarn --cwd ./examples start",
4746
"test": "echo null",
48-
"typecheck": "tsc --noEmit --emitDeclarationOnly false --strict --jsx react",
49-
"typegen": "tsc && mv dist/src/* dist && rm -rf dist/src || true"
47+
"typecheck": "tsc --noEmit --emitDeclarationOnly false --strict --jsx react"
5048
},
5149
"size-limit": [
5250
{
53-
"path": "dist/index.js",
51+
"path": "dist/react-three-fiber.cjs.prod.js",
52+
"import": "{ render }",
5453
"limit": "4500 ms"
5554
}
5655
],
@@ -62,8 +61,6 @@
6261
"react-use-measure": "^2.0.3",
6362
"resize-observer-polyfill": "^1.5.1",
6463
"scheduler": "0.20.1",
65-
"size-limit": "^4.10.0",
66-
"tiny-emitter": "^2.1.0",
6764
"use-asset": "^1.0.2",
6865
"utility-types": "^3.10.0",
6966
"zustand": "^3.3.3"
@@ -74,67 +71,46 @@
7471
"three": ">=0.126"
7572
},
7673
"devDependencies": {
77-
"@ampproject/rollup-plugin-closure-compiler": "^0.26.0",
7874
"@babel/core": "7.13.8",
79-
"@babel/helper-call-delegate": "^7.12.13",
80-
"@babel/plugin-transform-modules-commonjs": "7.13.8",
81-
"@babel/plugin-transform-parameters": "7.13.0",
82-
"@babel/plugin-transform-runtime": "7.13.9",
83-
"@babel/plugin-transform-template-literals": "7.13.0",
8475
"@babel/preset-env": "7.13.9",
8576
"@babel/preset-react": "7.12.13",
8677
"@babel/preset-typescript": "^7.13.0",
87-
"@rollup/plugin-commonjs": "^17.1.0",
88-
"@rollup/plugin-inject": "^4.0.2",
89-
"@rollup/plugin-strip": "^2.0.0",
78+
"@preconstruct/cli": "^2.0.6",
9079
"@types/jest": "^26.0.20",
9180
"@types/lodash-es": "^4.17.4",
92-
"@types/react": "^17.0.2",
9381
"@types/react-dom": "^17.0.1",
9482
"@types/react-native": "^0.63.51",
9583
"@types/react-reconciler": "^0.26.0",
9684
"@types/react-test-renderer": "^17.0.1",
85+
"@types/react": "^17.0.2",
9786
"@types/scheduler": "^0.16.1",
9887
"@types/three": "^0.126.0",
9988
"@typescript-eslint/eslint-plugin": "^4.16.1",
10089
"@typescript-eslint/parser": "^4.16.1",
101-
"babel-eslint": "^10.1.0",
102-
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
10390
"copyfiles": "^2.4.1",
104-
"cypress": "^6.6.0",
105-
"eslint": "^7.21.0",
10691
"eslint-config-prettier": "^8.1.0",
10792
"eslint-import-resolver-alias": "^1.1.2",
10893
"eslint-plugin-import": "^2.22.1",
10994
"eslint-plugin-jest": "^24.1.7",
11095
"eslint-plugin-prettier": "^3.3.1",
111-
"eslint-plugin-react": "^7.22.0",
11296
"eslint-plugin-react-hooks": "^4.2.0",
113-
"expo-gl": "^10.1.0",
114-
"expo-three": "^5.6.2",
97+
"eslint-plugin-react": "^7.22.0",
98+
"eslint": "^7.21.0",
11599
"husky": "^5.1.3",
116-
"jest": "^26.6.3",
117100
"jest-cli": "^26.6.3",
118101
"jest-image-snapshot": "^4.4.0",
119102
"jest-puppeteer": "^4.4.0",
120-
"json": "^10.0.0",
103+
"jest": "^26.6.3",
121104
"lint-staged": "^10.5.4",
122105
"prettier": "^2.2.1",
123106
"puppeteer": "^8.0.0",
124-
"react": "^16.11.0",
125107
"react-dom": "^16.11.0",
126108
"react-native": "^0.63.4",
127109
"react-test-renderer": "^17.0.1",
128-
"rimraf": "^3.0.2",
129-
"rollup": "^2.40.0",
130-
"rollup-plugin-babel": "^4.4.0",
131-
"rollup-plugin-commonjs": "^10.1.0",
132-
"rollup-plugin-json": "^4.0.0",
133-
"rollup-plugin-node-resolve": "^5.2.0",
134-
"rollup-plugin-terser": "^7.0.2",
110+
"react": "^16.11.0",
111+
"size-limit": "^4.10.0",
135112
"three": "^0.126.1",
136113
"ts-jest": "^26.5.3",
137-
"typescript": "^4.2.3",
138-
"wait-on": "^5.2.1"
114+
"typescript": "^4.2.3"
139115
}
140116
}

rollup.config.js

Lines changed: 0 additions & 98 deletions
This file was deleted.

src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './web'

src/web/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as THREE from 'three'
22
import * as React from 'react'
3-
import { name as rendererPackageName, version } from '../../package.json'
43
import { is } from '../core/is'
54
import { createStore, StoreProps, isRenderer, context } from '../core/store'
65
import { createRenderer, extend, Root } from '../core/renderer'
@@ -115,8 +114,9 @@ function createPortal(children: React.ReactNode, container: any, impl?: any, key
115114

116115
reconciler.injectIntoDevTools({
117116
bundleType: process.env.NODE_ENV === 'production' ? 0 : 1,
118-
rendererPackageName,
119-
version,
117+
rendererPackageName: "react-three-fiber",
118+
// @ts-ignore
119+
version: R3F_VERSION,
120120
})
121121

122122
export * from '../core/hooks'

0 commit comments

Comments
 (0)