Skip to content

Commit 490f3de

Browse files
committed
Vite 7 [publish]
1 parent 98299ff commit 490f3de

File tree

11 files changed

+186
-274
lines changed

11 files changed

+186
-274
lines changed

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"typescript.tsdk": "node_modules/typescript/lib"
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"terminal.integrated.env.osx": {
4+
"PATH": "./node_modules/.bin:${env:PATH}"
5+
}
36
}

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
# Changelog
22

3+
## 4.0.0
4+
5+
- Align with Vite 7: ESM only, node 20.19+
6+
37
## 3.1.1
48

59
- Correctly display component using forwardRef
6-
- Fix menu position when div is taller than viewport
10+
- Fix menu position when the target is taller than viewport
711
- Use dynamic z-index to always be on top of the targeted element (like MUI dialog) (fixes #9)
812

913
## 3.1.0

bun.lock

100755100644
Lines changed: 135 additions & 233 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
{
22
"name": "vite-plugin-react-click-to-component",
33
"type": "module",
4-
"version": "3.1.1",
4+
"version": "4.0.0",
5+
"private": true,
56
"license": "MIT",
67
"scripts": {
78
"postinstall": "cd playground && bun i",
89
"dev": "scripts/bundle.ts --dev",
910
"build": "scripts/bundle.ts",
10-
"tsc": "tsc",
11+
"tsc": "tsl",
1112
"lint": "bun lint-ci --fix --cache",
1213
"lint-ci": "eslint --max-warnings 0",
1314
"prettier": "bun prettier-ci --write",
1415
"prettier-ci": "prettier --ignore-path=.gitignore --check '**/*.{ts,tsx,html,css,json,md,yml}'",
15-
"ci": "tsc && bun run build && bun lint-ci && bun prettier-ci && cd playground && tsc && bun lint-ci && cd ../dist && bun publint"
16+
"ci": "tsl && bun run build && bun lint-ci && bun prettier-ci && cd playground && tsc && bun lint-ci && cd ../dist && bun publint"
1617
},
1718
"prettier": {
1819
"trailingComma": "all"
1920
},
2021
"peerDependencies": {
2122
"react": "^18.3.1 || ^19.0.0",
22-
"vite": "^4 || ^5 || ^6"
23+
"vite": "^7"
2324
},
2425
"devDependencies": {
25-
"@arnaud-barre/eslint-config": "^5.2.0",
26-
"@arnaud-barre/tnode": "^0.24.0",
26+
"@arnaud-barre/eslint-config": "6.0.0",
27+
"@arnaud-barre/tsl-config": "^0.1.0",
28+
"@arnaud-barre/tnode": "^0.25.0",
2729
"@types/node": "^20.17.8",
28-
"eslint": "^9.15.0",
30+
"eslint": "^9.29.0",
2931
"prettier": "3.0.3",
30-
"publint": "^0.2.12",
31-
"typescript": "~5.7.2",
32-
"vite": "^6.0.0"
32+
"publint": "^0.3.12",
33+
"tsl": "^1.0.17",
34+
"typescript": "~5.8.3",
35+
"vite": "^7.0.0"
3336
}
3437
}

playground/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { defineConfig } from "vite";
22
import react from "@vitejs/plugin-react-swc";
3-
import { reactClickToComponent } from "../dist/index.mjs";
3+
import { reactClickToComponent } from "../dist/index.js";
44
import restart from "vite-plugin-restart";
55

66
export default defineConfig({
77
plugins: [
88
react(),
99
reactClickToComponent(),
10-
restart({ restart: ["../dist/client.js", "../dist/index.mjs"] }),
10+
restart({ restart: ["../dist/client.js", "../dist/index.js"] }),
1111
],
1212
server: { open: true },
1313
});

scripts/bundle.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const dev = process.argv.includes("--dev");
1010
rmSync("dist", { force: true, recursive: true });
1111

1212
const buildOrWatch = async (options: BuildOptions) => {
13-
if (!dev) return build(options);
13+
if (!dev) return await build(options);
1414
const ctx = await context(options);
1515
await ctx.watch();
1616
await ctx.rebuild();
@@ -19,10 +19,10 @@ const buildOrWatch = async (options: BuildOptions) => {
1919
await Promise.all([
2020
buildOrWatch({
2121
bundle: true,
22-
entryPoints: ["src/index.mts"],
23-
outfile: "dist/index.mjs",
22+
entryPoints: ["src/index.ts"],
23+
outfile: "dist/index.js",
2424
platform: "node",
25-
target: "node18",
25+
target: "node20",
2626
format: "esm",
2727
legalComments: "inline",
2828
external: Object.keys(packageJSON.peerDependencies),
@@ -33,14 +33,14 @@ await Promise.all([
3333
outfile: "dist/client.js",
3434
platform: "browser",
3535
format: "esm",
36-
target: "safari14",
36+
target: "safari16",
3737
legalComments: "inline",
3838
}),
3939
]).then(() => {
40-
execSync("cp LICENSE README.md src/index.cjs dist/");
40+
execSync("cp LICENSE README.md dist/");
4141

4242
writeFileSync(
43-
"dist/index.d.mts",
43+
"dist/index.d.ts",
4444
`import { PluginOption } from "vite";
4545
export declare const reactClickToComponent: () => PluginOption;
4646
`,
@@ -58,15 +58,8 @@ export declare const reactClickToComponent: () => PluginOption;
5858
license: packageJSON.license,
5959
repository: "github:ArnaudBarre/vite-plugin-react-click-to-component",
6060
type: "module",
61-
main: "index.cjs",
62-
types: "index.d.mts",
63-
module: "index.mjs",
6461
exports: {
65-
".": {
66-
types: "./index.d.mts",
67-
require: "./index.cjs",
68-
import: "./index.mjs",
69-
},
62+
".": "./index.js",
7063
},
7164
keywords: [
7265
"vite",

src/client.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ const getReactInstanceForElement = (element: Element): Fiber | undefined => {
208208
for (const renderer of renderers.values()) {
209209
try {
210210
const fiber = renderer.findFiberByHostInstance(element);
211+
// tsl-ignore core/strictBooleanExpressions
211212
if (fiber) return fiber;
212213
} catch {
213214
// If React is mid-render, references to previous nodes may disappear during the click events

src/index.cjs

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

src/index.mts renamed to src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { readFileSync } from "node:fs";
2-
import { join, dirname } from "node:path";
3-
import { fileURLToPath } from "node:url";
2+
import { join } from "node:path";
43
import type { PluginOption } from "vite";
54

65
let root = "";
@@ -16,7 +15,7 @@ export const reactClickToComponent = (): PluginOption => ({
1615
tag: "script",
1716
attrs: { type: "module" },
1817
children: readFileSync(
19-
join(dirname(fileURLToPath(import.meta.url)), "client.js"),
18+
join(import.meta.dirname, "client.js"),
2019
"utf-8",
2120
).replace("__ROOT__", root),
2221
},

tsconfig.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
{
22
"include": ["src", "scripts"],
33
"compilerOptions": {
4-
/* Target node 18 / Safari 14 */
5-
"target": "ES2021",
6-
"jsx": "react-jsx",
4+
/* Target node 20 / Safari 16 */
5+
"target": "ES2022",
76
"module": "ESNext",
8-
"lib": ["ES2021", "DOM", "DOM.Iterable"],
7+
"moduleDetection": "force",
8+
"lib": ["ES2023", "DOM", "DOM.Iterable"],
9+
"types": ["node", "tsl/patches"],
10+
"skipLibCheck": true,
911

1012
/* Bundler mode */
1113
"moduleResolution": "bundler",
1214
"allowImportingTsExtensions": true,
1315
"verbatimModuleSyntax": true,
16+
"erasableSyntaxOnly": true,
1417
"noEmit": true,
1518

1619
/* Linting */
17-
"skipLibCheck": true,
1820
"strict": true,
1921
"noUnusedLocals": true,
2022
"noUnusedParameters": true,
2123
"noFallthroughCasesInSwitch": true,
2224
"useUnknownInCatchVariables": true,
2325
"noUncheckedSideEffectImports": true,
24-
"noPropertyAccessFromIndexSignature": true
26+
"noPropertyAccessFromIndexSignature": true,
27+
28+
"plugins": [{ "name": "tsl/plugin" }]
2529
}
2630
}

0 commit comments

Comments
 (0)