Skip to content

Commit bf55854

Browse files
authored
Dist that supports tree shaking (#70)
* Rework dist * Move around react deps
1 parent f786fb2 commit bf55854

29 files changed

+106
-140
lines changed

build.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import path from 'path';
2-
import { Glob } from 'bun';
1+
import { glob } from 'glob';
32
import esbuild from 'esbuild';
43
import { execSync } from 'child_process';
54

65
async function build(packageDir) {
7-
const input = `${packageDir}/src/index.ts`;
6+
const files = glob.sync(`${packageDir}/src/**/*.ts*`);
7+
const entryPoints = files.filter((file) => !file.includes('.test.'));
88
const outDir = `${packageDir}/dist`;
99
const tsconfig = `${packageDir}/tsconfig.build.json`;
1010

@@ -20,23 +20,28 @@ async function build(packageDir) {
2020
process.exit(1);
2121
}
2222

23+
// prettier-ignore
24+
const banner =
25+
`/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
26+
* Paper Shaders *
27+
* https://github.com/paper-design/shaders *
28+
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
29+
`;
30+
2331
// ----- Build the package ----- //
2432
// esbuild configuration
2533
await esbuild.build({
26-
entryPoints: [input],
34+
entryPoints: entryPoints,
2735
outdir: outDir,
28-
bundle: true,
2936
banner: {
30-
js: '/***** Paper Shaders: https://github.com/paper-design/shaders *****/',
37+
js: banner,
3138
},
3239
platform: 'browser',
3340
target: 'es2022',
3441
format: 'esm',
3542
treeShaking: true,
3643
sourcemap: true,
3744
minify: false,
38-
external: ['react'],
39-
packages: 'external', // Treat workspace dependencies as external (the publish script will replace workspace:* with the actual version)
4045
});
4146

4247
console.log(`Built ${outDir}/index.js`);

bun.lock

Lines changed: 35 additions & 31 deletions
Large diffs are not rendered by default.

docs/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@
1212
"@paper-design/shaders-react": "workspace:*",
1313
"@vercel/analytics": "^1.5.0",
1414
"leva": "0.9.34",
15-
"next": "15.2.3",
16-
"react": "19.1.0",
17-
"react-dom": "19.1.0"
15+
"next": "15.2.3"
1816
},
1917
"devDependencies": {
2018
"@eslint/eslintrc": "3.2.0",
2119
"@types/node": "22.10.2",
22-
"@types/react": "19.0.12",
23-
"@types/react-dom": "19.0.4",
20+
"@types/react": "19.1.0",
21+
"@types/react-dom": "19.1.1",
2422
"eslint": "9.17.0",
2523
"eslint-config-next": "15.1.2",
2624
"postcss": "8.4.49",

docs/registry/dot-grid-example.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use client';
2-
31
import { DotGrid, type DotGridProps } from '@paper-design/shaders-react';
42

53
export function DotGridExample(props: DotGridProps) {

docs/registry/dot-orbit-example.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use client';
2-
31
import { DotOrbit, type DotOrbitProps } from '@paper-design/shaders-react';
42

53
export function DotOrbitExample(props: DotOrbitProps) {

docs/registry/god-rays-example.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use client';
2-
31
import { GodRays, GodRaysProps } from '@paper-design/shaders-react';
42

53
export function GodRaysExample(props: GodRaysProps) {

docs/registry/mesh-gradient-example.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use client';
2-
31
import { MeshGradient, MeshGradientProps } from '@paper-design/shaders-react';
42

53
export function MeshGradientExample(props: MeshGradientProps) {

docs/registry/metaballs-example.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use client';
2-
31
import { Metaballs, MetaballsProps } from '@paper-design/shaders-react';
42

53
export function MetaballsExample(props: MetaballsProps) {

docs/registry/neuro-noise-example.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use client';
2-
31
import { NeuroNoise, type NeuroNoiseProps } from '@paper-design/shaders-react';
42

53
export function NeuroNoiseExample(props: NeuroNoiseProps) {

docs/registry/perlin-noise-example.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use client';
2-
31
import { PerlinNoise, PerlinNoiseProps } from '@paper-design/shaders-react';
42

53
export function PerlinNoiseExample(props: PerlinNoiseProps) {

0 commit comments

Comments
 (0)