Skip to content

Commit 2d41a9f

Browse files
authored
fix: change back to loading from literal ".zenstack" path otherwise Vercel breaks :( (#701)
1 parent cc6f286 commit 2d41a9f

File tree

12 files changed

+35
-25
lines changed

12 files changed

+35
-25
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zenstack-monorepo",
3-
"version": "1.0.0-beta.22",
3+
"version": "1.0.0-beta.23",
44
"description": "",
55
"scripts": {
66
"build": "pnpm -r build",

packages/language/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/language",
3-
"version": "1.0.0-beta.22",
3+
"version": "1.0.0-beta.23",
44
"displayName": "ZenStack modeling language compiler",
55
"description": "ZenStack modeling language compiler",
66
"homepage": "https://zenstack.dev",

packages/plugins/openapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/openapi",
33
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
4-
"version": "1.0.0-beta.22",
4+
"version": "1.0.0-beta.23",
55
"description": "ZenStack plugin and runtime supporting OpenAPI",
66
"main": "index.js",
77
"repository": {

packages/plugins/swr/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/swr",
33
"displayName": "ZenStack plugin for generating SWR hooks",
4-
"version": "1.0.0-beta.22",
4+
"version": "1.0.0-beta.23",
55
"description": "ZenStack plugin for generating SWR hooks",
66
"main": "index.js",
77
"repository": {

packages/plugins/tanstack-query/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/tanstack-query",
33
"displayName": "ZenStack plugin for generating tanstack-query hooks",
4-
"version": "1.0.0-beta.22",
4+
"version": "1.0.0-beta.23",
55
"description": "ZenStack plugin for generating tanstack-query hooks",
66
"main": "index.js",
77
"exports": {

packages/plugins/trpc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/trpc",
33
"displayName": "ZenStack plugin for tRPC",
4-
"version": "1.0.0-beta.22",
4+
"version": "1.0.0-beta.23",
55
"description": "ZenStack plugin for tRPC",
66
"main": "index.js",
77
"repository": {

packages/runtime/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zenstackhq/runtime",
33
"displayName": "ZenStack Runtime Library",
4-
"version": "1.0.0-beta.22",
4+
"version": "1.0.0-beta.23",
55
"description": "Runtime of ZenStack for both client-side and server-side environments.",
66
"repository": {
77
"type": "git",

packages/runtime/src/loader.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
import path from 'path';
3-
import { DEFAULT_RUNTIME_LOAD_PATH } from './constants';
43
import { ModelMeta, PolicyDef, ZodSchemas } from './enhancements';
54

65
/**
@@ -10,15 +9,18 @@ import { ModelMeta, PolicyDef, ZodSchemas } from './enhancements';
109
* will use default load path.
1110
*/
1211
export function getDefaultModelMeta(loadPath: string | undefined): ModelMeta {
13-
const toLoad = loadPath ? path.resolve(loadPath, 'model-meta') : `${DEFAULT_RUNTIME_LOAD_PATH}/model-meta`;
1412
try {
15-
// normal load
16-
return require(toLoad).default;
13+
if (loadPath) {
14+
const toLoad = path.resolve(loadPath, 'model-meta');
15+
return require(toLoad).default;
16+
} else {
17+
return require('.zenstack/model-meta').default;
18+
}
1719
} catch {
18-
if (process.env.ZENSTACK_TEST === '1' && !path.isAbsolute(toLoad)) {
20+
if (process.env.ZENSTACK_TEST === '1' && !loadPath) {
1921
try {
2022
// special handling for running as tests, try resolving relative to CWD
21-
return require(path.join(process.cwd(), 'node_modules', toLoad)).default;
23+
return require(path.join(process.cwd(), 'node_modules', '.zenstack', 'model-meta')).default;
2224
} catch {
2325
throw new Error('Model meta cannot be loaded. Please make sure "zenstack generate" has been run.');
2426
}
@@ -34,14 +36,18 @@ export function getDefaultModelMeta(loadPath: string | undefined): ModelMeta {
3436
* will use default load path.
3537
*/
3638
export function getDefaultPolicy(loadPath: string | undefined): PolicyDef {
37-
const toLoad = loadPath ? path.resolve(loadPath, 'policy') : `${DEFAULT_RUNTIME_LOAD_PATH}/policy`;
3839
try {
39-
return require(toLoad).default;
40+
if (loadPath) {
41+
const toLoad = path.resolve(loadPath, 'policy');
42+
return require(toLoad).default;
43+
} else {
44+
return require('.zenstack/policy').default;
45+
}
4046
} catch {
41-
if (process.env.ZENSTACK_TEST === '1' && !path.isAbsolute(toLoad)) {
47+
if (process.env.ZENSTACK_TEST === '1' && !loadPath) {
4248
try {
4349
// special handling for running as tests, try resolving relative to CWD
44-
return require(path.join(process.cwd(), 'node_modules', toLoad)).default;
50+
return require(path.join(process.cwd(), 'node_modules', '.zenstack', 'policy')).default;
4551
} catch {
4652
throw new Error(
4753
'Policy definition cannot be loaded from default location. Please make sure "zenstack generate" has been run.'
@@ -61,14 +67,18 @@ export function getDefaultPolicy(loadPath: string | undefined): PolicyDef {
6167
* will use default load path.
6268
*/
6369
export function getDefaultZodSchemas(loadPath: string | undefined): ZodSchemas | undefined {
64-
const toLoad = loadPath ? path.resolve(loadPath, 'zod') : `${DEFAULT_RUNTIME_LOAD_PATH}/zod`;
6570
try {
66-
return require(toLoad);
71+
if (loadPath) {
72+
const toLoad = path.resolve(loadPath, 'zod');
73+
return require(toLoad);
74+
} else {
75+
return require('.zenstack/zod');
76+
}
6777
} catch {
68-
if (process.env.ZENSTACK_TEST === '1' && !path.isAbsolute(toLoad)) {
78+
if (process.env.ZENSTACK_TEST === '1' && !loadPath) {
6979
try {
7080
// special handling for running as tests, try resolving relative to CWD
71-
return require(path.join(process.cwd(), 'node_modules', toLoad));
81+
return require(path.join(process.cwd(), 'node_modules', '.zenstack', 'zod'));
7282
} catch {
7383
return undefined;
7484
}

packages/schema/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "zenstack",
44
"displayName": "ZenStack Language Tools",
55
"description": "A toolkit for building secure CRUD apps with Next.js + Typescript",
6-
"version": "1.0.0-beta.22",
6+
"version": "1.0.0-beta.23",
77
"author": {
88
"name": "ZenStack Team"
99
},

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zenstackhq/sdk",
3-
"version": "1.0.0-beta.22",
3+
"version": "1.0.0-beta.23",
44
"description": "ZenStack plugin development SDK",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)