diff --git a/packages/plugins/swr/package.json b/packages/plugins/swr/package.json index 75897b99f..d38a7dcd7 100644 --- a/packages/plugins/swr/package.json +++ b/packages/plugins/swr/package.json @@ -10,8 +10,8 @@ }, "scripts": { "clean": "rimraf dist", - "build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && copyfiles ./package.json ./README.md ./LICENSE dist && pnpm pack dist --pack-destination '../../../../.build'", - "watch": "tsc --watch", + "build": "pnpm lint --max-warnings=0 && pnpm clean && tsc && tsup-node --config ./tsup.config.ts && copyfiles ./package.json ./README.md ./LICENSE dist && pnpm pack dist --pack-destination '../../../../.build'", + "watch": "concurrently \"tsc --watch\" \"tsup-node --config ./tsup.config.ts --watch\"", "lint": "eslint src --ext ts", "test": "ZENSTACK_TEST=1 jest", "prepublishOnly": "pnpm build" @@ -23,6 +23,20 @@ "keywords": [], "author": "ZenStack Team", "license": "MIT", + "exports": { + ".": { + "default": "./index.js" + }, + "./package.json": { + "default": "./package.json" + }, + "./runtime": { + "types": "./runtime/index.d.ts", + "import": "./runtime/index.mjs", + "require": "./runtime/index.js", + "default": "./runtime/index.js" + } + }, "dependencies": { "@prisma/generator-helper": "^5.0.0", "@zenstackhq/runtime": "workspace:*", diff --git a/packages/plugins/swr/tsconfig.json b/packages/plugins/swr/tsconfig.json index 9f979b87b..9e4f772c5 100644 --- a/packages/plugins/swr/tsconfig.json +++ b/packages/plugins/swr/tsconfig.json @@ -5,5 +5,6 @@ "outDir": "dist", "jsx": "react" }, - "include": ["src/**/*.ts"] + "include": ["src/**/*.ts"], + "exclude": ["src/runtime"] } diff --git a/packages/plugins/swr/tsup.config.ts b/packages/plugins/swr/tsup.config.ts new file mode 100644 index 000000000..2735372fa --- /dev/null +++ b/packages/plugins/swr/tsup.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig({ + entry: ['src/runtime/index.ts'], + outDir: 'dist/runtime', + splitting: false, + sourcemap: true, + clean: true, + dts: true, + format: ['cjs', 'esm'], +}); diff --git a/packages/server/package.json b/packages/server/package.json index 330b227fb..2d02ee7e5 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -26,7 +26,6 @@ "author": "", "license": "MIT", "dependencies": { - "@zenstackhq/openapi": "workspace:*", "@zenstackhq/runtime": "workspace:*", "change-case": "^4.1.2", "lower-case-first": "^2.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3fb8434ef..f209cbdac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -588,9 +588,6 @@ importers: packages/server: dependencies: - '@zenstackhq/openapi': - specifier: workspace:* - version: link:../plugins/openapi/dist '@zenstackhq/runtime': specifier: workspace:* version: link:../runtime/dist diff --git a/tests/integration/tests/frameworks/nextjs/generation.test.ts b/tests/integration/tests/frameworks/nextjs/generation.test.ts index 846634d94..8b76afbd1 100644 --- a/tests/integration/tests/frameworks/nextjs/generation.test.ts +++ b/tests/integration/tests/frameworks/nextjs/generation.test.ts @@ -14,6 +14,16 @@ describe('SWR Hooks Generation Tests', () => { process.chdir(origDir); }); + // deps + const ver = require('../../../../../package.json').version; + const depPkgs = [ + `${path.join(__dirname, '../../../../../.build/zenstackhq-language-' + ver + '.tgz')}`, + `${path.join(__dirname, '../../../../../.build/zenstackhq-sdk-' + ver + '.tgz')}`, + `${path.join(__dirname, '../../../../../.build/zenstackhq-runtime-' + ver + '.tgz')}`, + `${path.join(__dirname, '../../../../../.build/zenstackhq-swr-' + ver + '.tgz')}`, + ]; + const deps = depPkgs.join(' '); + it('sqlite', async () => { const testDir = path.join(__dirname, './test-run/sqlite'); if (fs.existsSync(testDir)) { @@ -25,6 +35,7 @@ describe('SWR Hooks Generation Tests', () => { process.chdir(testDir); const nodePath = path.join(testDir, 'node_modules'); run('npm install'); + run('npm install ' + deps); run('npx zenstack generate --schema ./sqlite.zmodel', { NODE_PATH: nodePath }); run('npm run build', { NODE_PATH: nodePath }); }); @@ -40,6 +51,7 @@ describe('SWR Hooks Generation Tests', () => { process.chdir(testDir); const nodePath = path.join(testDir, 'node_modules'); run('npm install'); + run('npm install ' + deps); run('npx zenstack generate --schema ./postgres.zmodel', { NODE_PATH: nodePath }); run('npm run build', { NODE_PATH: nodePath }); }); diff --git a/tests/integration/tests/frameworks/nextjs/test-project/package.json b/tests/integration/tests/frameworks/nextjs/test-project/package.json index 589760cc7..1461849f1 100644 --- a/tests/integration/tests/frameworks/nextjs/test-project/package.json +++ b/tests/integration/tests/frameworks/nextjs/test-project/package.json @@ -13,8 +13,6 @@ "@types/node": "18.11.18", "@types/react": "18.0.27", "@types/react-dom": "18.0.10", - "@zenstackhq/runtime": "../../../../../../../packages/runtime/dist", - "@zenstackhq/swr": "../../../../../../../packages/plugins/swr/dist", "next": "13.1.4", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/tests/integration/tests/frameworks/trpc/generation.test.ts b/tests/integration/tests/frameworks/trpc/generation.test.ts index 3b0dd0610..5e15d9943 100644 --- a/tests/integration/tests/frameworks/trpc/generation.test.ts +++ b/tests/integration/tests/frameworks/trpc/generation.test.ts @@ -14,6 +14,16 @@ describe('tRPC Routers Generation Tests', () => { process.chdir(origDir); }); + // deps + const ver = require('../../../../../package.json').version; + const depPkgs = [ + `${path.join(__dirname, '../../../../../.build/zenstackhq-language-' + ver + '.tgz')}`, + `${path.join(__dirname, '../../../../../.build/zenstackhq-sdk-' + ver + '.tgz')}`, + `${path.join(__dirname, '../../../../../.build/zenstackhq-runtime-' + ver + '.tgz')}`, + `${path.join(__dirname, '../../../../../.build/zenstackhq-trpc-' + ver + '.tgz')}`, + ]; + const deps = depPkgs.join(' '); + it('basic', async () => { const testDir = path.join(__dirname, './test-run/basic'); if (fs.existsSync(testDir)) { @@ -24,6 +34,7 @@ describe('tRPC Routers Generation Tests', () => { process.chdir(testDir); run('npm install'); + run('npm install ' + deps); run('npx zenstack generate --no-dependency-check --schema ./todo.zmodel', { NODE_PATH: 'node_modules' }); run('npm run build', { NODE_PATH: 'node_modules' }); }); diff --git a/tests/integration/tests/frameworks/trpc/test-project/package.json b/tests/integration/tests/frameworks/trpc/test-project/package.json index b5c6fd901..f27687e63 100644 --- a/tests/integration/tests/frameworks/trpc/test-project/package.json +++ b/tests/integration/tests/frameworks/trpc/test-project/package.json @@ -23,12 +23,9 @@ "react-dom": "18.2.0", "superjson": "^1.12.2", "typescript": "4.9.4", - "zod": "^3.22.4", - "@zenstackhq/runtime": "../../../../../../../packages/runtime/dist" + "zod": "^3.22.4" }, "devDependencies": { - "prisma": "^4.8.0", - "zenstack": "../../../../../../../packages/schema/dist", - "@zenstackhq/trpc": "../../../../../../../packages/plugins/trpc/dist" + "prisma": "^4.8.0" } }