Skip to content

Commit 126c56c

Browse files
Copilothotlong
andcommitted
fix: compile plugin.ts to JS for Node.js runtime compatibility
The @object-ui/console package had "main": "./plugin.ts" pointing to raw TypeScript. Downstream projects (e.g. hotcrm on Vercel) that keep node_modules external during bundling would fail at runtime with ERR_MODULE_NOT_FOUND because Node.js cannot execute .ts files natively. Changes: - Add tsconfig.plugin.json to compile plugin.ts → plugin.js + plugin.d.ts - Add build:plugin script, integrated into build and build:vercel - Update package.json main/exports/types to point to compiled .js/.d.ts - Add plugin.js and plugin.d.ts to .gitignore (build artifacts) - Keep plugin.ts in published files for source reference Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 96fd524 commit 126c56c

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

apps/console/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ dist
1212
dist-ssr
1313
*.local
1414

15+
# Compiled plugin output (generated by tsc -p tsconfig.plugin.json)
16+
plugin.js
17+
plugin.d.ts
18+
1519
# Editor directories and files
1620
.vscode/*
1721
!.vscode/extensions.json

apps/console/package.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@
33
"version": "3.0.1",
44
"description": "ObjectStack Console - The standard runtime UI for ObjectStack applications",
55
"type": "module",
6-
"main": "./plugin.ts",
6+
"main": "./plugin.js",
7+
"types": "./plugin.d.ts",
78
"exports": {
89
".": {
9-
"import": "./plugin.ts",
10-
"default": "./plugin.ts"
10+
"types": "./plugin.d.ts",
11+
"import": "./plugin.js",
12+
"default": "./plugin.js"
1113
}
1214
},
1315
"files": [
1416
"dist",
15-
"plugin.ts"
17+
"plugin.ts",
18+
"plugin.js",
19+
"plugin.d.ts"
1620
],
1721
"scripts": {
1822
"msw:init": "msw init -y public",
1923
"dev": "pnpm msw:init && vite",
2024
"start": "tsx ../../node_modules/@objectstack/cli/bin/objectstack.js serve objectstack.config.ts",
2125
"start:mock": "pnpm msw:init && vite preview",
22-
"build": "pnpm msw:init && tsc && VITE_USE_MOCK_SERVER=false vite build",
23-
"build:vercel": "pnpm msw:init && tsc && VITE_USE_MOCK_SERVER=true vite build",
26+
"build:plugin": "tsc -p tsconfig.plugin.json",
27+
"build": "pnpm msw:init && tsc && VITE_USE_MOCK_SERVER=false vite build && pnpm build:plugin",
28+
"build:vercel": "pnpm msw:init && tsc && VITE_USE_MOCK_SERVER=true vite build && pnpm build:plugin",
2429
"build:analyze": "pnpm build && echo 'Bundle analysis available at dist/stats.html'",
2530
"preview": "vite preview",
2631
"test": "vitest run",

apps/console/tsconfig.plugin.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"declaration": true,
7+
"strict": true,
8+
"skipLibCheck": true,
9+
"esModuleInterop": true
10+
},
11+
"include": ["plugin.ts"]
12+
}

0 commit comments

Comments
 (0)