Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ jobs:
- uses: JS-DevTools/npm-publish@v3
with:
access: "public"
tag: "next"
token: ${{ secrets.NPM_TOKEN }}
15 changes: 15 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,18 @@ jobs:

- name: Build
run: pnpm build

npm:
runs-on: ubuntu-latest
steps:
- uses: P5-wrapper/setup-action@v1.0.6

- name: Build the component
run: pnpm build:component

- uses: JS-DevTools/npm-publish@v3
with:
access: "public"
tag: "next"
dry-run: true
token: ${{ secrets.NPM_TOKEN }}
24 changes: 0 additions & 24 deletions config/eslint/eslint.config.js

This file was deleted.

30 changes: 30 additions & 0 deletions config/eslint/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// @ts-expect-error The react team don't expose types for the eslint plugin currently
import * as reactCompiler from "eslint-plugin-react-compiler";
import * as tseslint from "typescript-eslint";
import { includeIgnoreFile } from "@eslint/compat";
import eslint from "@eslint/js";
import { resolve } from "node:path";
import { dirname } from "path";
import { type ConfigArray } from "typescript-eslint";

const configDirectory: string = dirname(import.meta.dirname);
const rootDirectory: string = dirname(configDirectory);
const gitignore: string = resolve(rootDirectory, ".gitignore");

const config: ConfigArray = tseslint.config(
eslint.configs.recommended,
tseslint.configs.strict,
tseslint.configs.stylistic,
includeIgnoreFile(gitignore),
{
...reactCompiler.configs.recommended,
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: rootDirectory
}
}
}
);

export default config;
7 changes: 3 additions & 4 deletions config/typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
{
"compilerOptions": {
"target": "ESNext",
"composite": true,
"useDefineForClassFields": true,
"types": ["vite/client"],
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "bundler",
"moduleResolution": "node",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"moduleResolution": "node",
"moduleResolution": "bundler",

This can be as is, since it has no effect on compilation errors

"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": false,
"jsx": "react-jsx",
"noImplicitAny": true
},
"include": ["../../"],
"include": ["../../config", "../../src", "../../tests", "../../demo"],
"references": [{ "path": "./tsconfig.node.json" }]
}
2 changes: 1 addition & 1 deletion config/typescript/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "bundler",
"moduleResolution": "node",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"moduleResolution": "node",
"moduleResolution": "bundler",

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to check on my end if this has any effect. If not, it's definitely a worthy change considering 'node' is deprecated. Could be a separate ticket though.

"allowSyntheticDefaultImports": true
},
"include": ["../vite/vite.component.config.ts"]
Expand Down
17 changes: 9 additions & 8 deletions config/vite/vite.component.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { resolve } from "node:path";
import dts from "vite-plugin-dts";
import { defineConfig } from "vitest/config";

const outputDirectory = resolve(__dirname, "..", "..", "dist", "component");

export default defineConfig({
const rootDir = resolve(__dirname, "..", "..");
const outputDirectory = resolve(rootDir, "dist", "component");
const tsConfigPath = resolve(rootDir, "tsconfig.json");
const config = defineConfig({
plugins: [
dts({
rollupTypes: true,
tsconfigPath: tsConfigPath,
outDir: outputDirectory
}),
react({
Expand All @@ -23,7 +25,7 @@ export default defineConfig({
build: {
emptyOutDir: true,
lib: {
entry: resolve(__dirname, "..", "..", "src", "main.tsx"),
entry: resolve(rootDir, "src", "main.tsx"),
name: "ReactP5Wrapper",
fileName: "ReactP5Wrapper",
formats: ["es", "cjs"]
Expand All @@ -49,16 +51,15 @@ export default defineConfig({
coverage: {
include: ["src"]
},
setupFiles: resolve(__dirname, "..", "..", "tests", "setup.ts"),
setupFiles: resolve(rootDir, "tests", "setup.ts"),
deps: {
optimizer: {
web: {
include: ["vitest-canvas-mock"]
}
}
},
onConsoleLog() {
return false;
}
}
});

export default config;
77 changes: 41 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@p5-wrapper/react",
"description": "A wrapper component that allows you to utilise P5 sketches within React apps.",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.2",
"type": "module",
"homepage": "https://github.com/P5-wrapper/react",
"license": "MIT",
Expand All @@ -20,17 +20,17 @@
},
"scripts": {
"build": "rimraf dist && pnpm build:component && pnpm build:demo",
"build:component": "tsc --declaration --noEmit && vite build --config config/vite/vite.component.config.ts",
"build:component": "tsc --noEmit && vite build --config config/vite/vite.component.config.ts",
"build:demo": "vite build --config config/vite/vite.demo.config.ts",
"ci": "pnpm format:check && pnpm lint && pnpm test && pnpm build",
"dev": "vite --config config/vite/vite.demo.config.ts --host",
"format": "pnpm prettier --write .",
"format:check": "pnpm prettier --check .",
"lint": "eslint --ignore-pattern dist --config config/eslint/eslint.config.js .",
"lint": "eslint --config config/eslint/eslint.config.ts",
"lint:fix": "pnpm lint --fix",
"prettier": "prettier --config config/prettier/prettier.json --ignore-path .gitignore",
"test": "vitest run --config config/vite/vite.component.config.ts",
"test:coverage": "vitest run --coverage --config config/vite/vite.component.config.ts",
"test": "vitest run --silent --config config/vite/vite.component.config.ts",
"test:coverage": "vitest run --silent --coverage --config config/vite/vite.component.config.ts",
"test:watch": "vitest watch --config config/vite/vite.component.config.ts"
},
"keywords": [
Expand Down Expand Up @@ -77,43 +77,48 @@
"bugs": {
"url": "https://github.com/P5-wrapper/react/issues"
},
"dependencies": {
"microdiff": "^1.5.0",
"react-error-boundary": "^5.0.0"
},
"peerDependencies": {
"p5": ">= 1.4.1",
"react": ">= 18.2.0",
"react-dom": ">= 18.2.0"
"p5": ">= 1.11.3",
"react": ">= 19.0.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will complain (albeit not critically) if the consumer doesn't have react >= 19.x.

Is that intended? Ideally, the library should probably support the earliest possible version of React.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this will be a major release, I'm thinking it's fine for 4.x.x users to be able to use react 18 and use the 5.x.x breaking change to update the new users or upgrading users to react 19. WDYT @yevdyko and @Qanpi, makes sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the 5th version should be available for users on both React 18 and 19 to provide a lighter wrapper. This is the primary difference from version 4. Otherwise, it won't be accessible until the app is updated to React 19, which could be a blocker due to breaking changes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe but if we use 18 and 19 we could cause issues for the people on 19 since theres some deprecations in that version and also we use the react compiler in the vite setup now also. I don't know if we can reasonably guarantee full support for users of both 18 and 19, at least not 100% compatability can be guaranteed, thin or not. Does that make sense what I am trying to say?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, but maybe we can add improvements that reduce package size to version 4 as well. WDYT?

Copy link
Contributor

@yevdyko yevdyko Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamesrweb Taking into account that these changes work in both version 18 and 19 of React, maybe we can leave the requirements for React peer dependencies as >= 18.2.0. WDYT?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would agree with @yevdyko.

"react-dom": ">= 19.0.0"
},
"devDependencies": {
"@testing-library/jest-dom": "6.6.2",
"@testing-library/react": "^16.0.0",
"@trivago/prettier-plugin-sort-imports": "^5.1.0",
"@types/jest": "^29.5.12",
"@types/node": "^22.0.0",
"@babel/eslint-plugin": "^7.25.9",
"@eslint/compat": "^1.2.6",
"@eslint/js": "^9.20.0",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/react": "^16.2.0",
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
"@types/jest": "^29.5.14",
"@types/node": "^22.13.4",
"@types/p5": "^1.7.6",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^8.1.0",
"@vitejs/plugin-react": "^4.3.0",
"@vitest/coverage-v8": "^3.0.4",
"babel-plugin-react-compiler": "0.0.0-experimental-938cd9a-20240601",
"eslint": "^9.4.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-compiler": "0.0.0-experimental-0998c1e-20240625",
"eslint-plugin-react-hooks": "^5.0.0",
"gh-pages": "^6.1.1",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@typescript-eslint/eslint-plugin": "^8.24.0",
"@vitejs/plugin-react": "^4.3.4",
"@vitest/coverage-v8": "^3.0.5",
"babel-plugin-react-compiler": "19.0.0-beta-30d8a17-20250209",
"eslint": "^9.20.1",
"eslint-plugin-react": "^7.37.4",
"eslint-plugin-react-compiler": "19.0.0-beta-30d8a17-20250209",
"eslint-plugin-react-hooks": "^5.1.0",
"gh-pages": "^6.3.0",
"jiti": "^2.4.2",
"js": "^0.1.0",
"jsdom": "^26.0.0",
"prettier": "^3.3.0",
"react": "19.0.0-rc.0",
"react-dom": "19.0.0-rc.0",
"prettier": "^3.5.1",
"react": "19.0.0",
"react-dom": "19.0.0",
"rimraf": "^6.0.1",
"typescript": "^5.4.5",
"typescript-eslint": "^8.0.0",
"vite": "^6.0.2",
"vite-plugin-dts": "^4.0.2",
"vitest": "^1.6.0",
"typescript": "^5.7.3",
"typescript-eslint": "^8.24.0",
"vite": "^6.1.0",
"vite-plugin-dts": "^4.5.0",
"vitest": "^3.0.5",
"vitest-canvas-mock": "^0.3.3"
},
"dependencies": {
"microdiff": "^1.4.0",
"react-error-boundary": "^5.0.0"
}
}
Loading
Loading