fix: have same non-module workflow for packages (#1230)

This commit is contained in:
Matti Nannt
2023-10-16 19:36:58 +02:00
committed by GitHub
parent 8768b641b3
commit 71ff256a55
11 changed files with 88 additions and 47 deletions

View File

@@ -1,20 +1,32 @@
{
"name": "@formbricks/api",
"version": "0.1.0",
"description": "A Typescript API-wrapper for managing the Formbricks Client API.",
"license": "MIT",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"version": "1.0.0",
"description": "Formbricks-api is an api wrapper for the Formbricks client API",
"keywords": [
"Formbricks",
"surveys",
"experience management",
"api"
],
"sideEffects": false,
"files": [
"dist/**"
"dist"
],
"source": "./src/index.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.umd.js"
}
},
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"go": "tsup --watch",
"dev": "vite build --watch",
"build": "tsc && vite build",
"go": "vite build --watch",
"lint": "eslint ./src --fix",
"clean": "rimraf .turbo node_modules dist"
},
@@ -22,7 +34,9 @@
"@formbricks/types": "workspace:*",
"@formbricks/lib": "workspace:*",
"@formbricks/tsconfig": "workspace:*",
"tsup": "^7.2.0",
"eslint-config-formbricks": "workspace:*"
"eslint-config-formbricks": "workspace:*",
"terser": "^5.21.0",
"vite": "^4.4.11",
"vite-plugin-dts": "^3.6.0"
}
}

View File

@@ -1,5 +1,9 @@
{
"extends": "@formbricks/tsconfig/js-library.json",
"include": ["**/*.ts", "tsup.config.ts"],
"exclude": ["node_modules", "dist"]
"include": ["src", "package.json"],
"compilerOptions": {
"allowImportingTsExtensions": true,
"isolatedModules": true,
"noEmit": true
}
}

View File

@@ -1,13 +0,0 @@
import { defineConfig } from "tsup";
const isProduction = process.env.NODE_ENV === "production";
export default defineConfig({
clean: true,
dts: true,
splitting: true,
format: ["cjs", "esm"],
entry: ["src/index.ts"],
minify: isProduction,
sourcemap: true,
});

View File

@@ -0,0 +1,20 @@
import { resolve } from "path";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
export default defineConfig({
build: {
emptyOutDir: false, // keep the dist folder to avoid errors with pnpm go when folder is empty during build
minify: "terser",
sourcemap: true,
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "src/index.ts"),
name: "formbricks-api",
formats: ["cjs", "es", "umd"],
// the proper extensions will be added
fileName: "index",
},
},
plugins: [dts({ rollupTypes: true })],
});

View File

@@ -24,8 +24,8 @@
}
},
"scripts": {
"dev": "vite",
"build": "vite build",
"dev": "vite build --watch",
"build": "tsc && vite build",
"go": "vite build --watch",
"lint": "eslint ./src --fix",
"clean": "rimraf .turbo node_modules dist coverage",

View File

@@ -6,6 +6,7 @@ export default defineConfig({
build: {
emptyOutDir: false, // keep the dist folder to avoid errors with pnpm go when folder is empty during build
minify: "terser",
sourcemap: true,
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "src/index.ts"),

View File

@@ -4,15 +4,20 @@
"license": "MIT",
"version": "0.0.0",
"sideEffects": false,
"source": "./src/index.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.umd.js"
}
},
"./package.json": "./package.json",
"./dist/index.d.ts": "./dist/index.d.ts"
},
"main": "./dist/index.js",
"scripts": {
"dev": "tsc && vite build",
"dev": "vite build --watch",
"build": "tsc && vite build",
"go": "vite build --watch",
"lint": "eslint . --ext .ts,.js,.tsx,.jsx",

View File

@@ -5,7 +5,7 @@
"compilerOptions": {
"outDir": "./dist",
"declaration": true,
"moduleResolution": "bundler",
"moduleResolution": "node",
"lib": ["ESNext", "DOM"],
"module": "esnext",
"target": "ES2021",

View File

@@ -10,6 +10,6 @@
"@types/node": "20.8.6",
"@types/react": "18.2.28",
"@types/react-dom": "18.2.13",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
}
}

31
pnpm-lock.yaml generated
View File

@@ -438,9 +438,15 @@ importers:
eslint-config-formbricks:
specifier: workspace:*
version: link:../eslint-config-formbricks
tsup:
specifier: ^7.2.0
version: 7.2.0(typescript@5.2.2)
terser:
specifier: ^5.21.0
version: 5.21.0
vite:
specifier: ^4.4.11
version: 4.4.11(terser@5.21.0)
vite-plugin-dts:
specifier: ^3.6.0
version: 3.6.0(typescript@5.2.2)(vite@4.4.11)
packages/database:
dependencies:
@@ -748,7 +754,7 @@ importers:
specifier: 18.2.13
version: 18.2.13
typescript:
specifier: ^5.1.6
specifier: ^5.2.2
version: 5.2.2
packages/types:
@@ -4184,14 +4190,14 @@ packages:
engines: {node: '>=6.0.0'}
dependencies:
'@jridgewell/set-array': 1.1.2
'@jridgewell/sourcemap-codec': 1.4.14
'@jridgewell/sourcemap-codec': 1.4.15
/@jridgewell/gen-mapping@0.3.2:
resolution: {integrity: sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==}
engines: {node: '>=6.0.0'}
dependencies:
'@jridgewell/set-array': 1.1.2
'@jridgewell/sourcemap-codec': 1.4.14
'@jridgewell/sourcemap-codec': 1.4.15
'@jridgewell/trace-mapping': 0.3.18
/@jridgewell/resolve-uri@3.1.0:
@@ -4582,7 +4588,7 @@ packages:
'@rushstack/ts-command-line': 4.16.1
colors: 1.2.5
lodash: 4.17.21
resolve: 1.22.6
resolve: 1.22.8
semver: 7.5.4
source-map: 0.6.1
typescript: 5.0.4
@@ -6747,7 +6753,7 @@ packages:
/@rushstack/rig-package@0.5.1:
resolution: {integrity: sha512-pXRYSe29TjRw7rqxD4WS3HN/sRSbfr+tJs4a9uuaSIBAITbUggygdhuG0VrO0EO+QqH91GhYMN4S6KRtOEmGVA==}
dependencies:
resolve: 1.22.6
resolve: 1.22.8
strip-json-comments: 3.1.1
dev: true
@@ -18039,7 +18045,7 @@ packages:
resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==}
dependencies:
hosted-git-info: 2.8.9
resolve: 1.22.6
resolve: 1.22.8
semver: 5.7.2
validate-npm-package-license: 3.0.4
@@ -18822,7 +18828,7 @@ packages:
postcss: 8.4.21
postcss-value-parser: 4.2.0
read-cache: 1.0.0
resolve: 1.22.6
resolve: 1.22.8
dev: false
/postcss-import@15.1.0(postcss@8.4.31):
@@ -19897,7 +19903,7 @@ packages:
resolution: {integrity: sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==}
engines: {node: '>= 0.10'}
dependencies:
resolve: 1.22.6
resolve: 1.22.8
/redent@3.0.0:
resolution: {integrity: sha512-6tDA8g98We0zd0GvVeMT9arEOnTw9qM03L9cJXaCjrip1OO764RDBLBfrB4cwzNGDj5OA5ioymC9GkizgWJDUg==}
@@ -20307,7 +20313,6 @@ packages:
is-core-module: 2.13.0
path-parse: 1.0.7
supports-preserve-symlinks-flag: 1.0.0
dev: true
/resolve@2.0.0-next.4:
resolution: {integrity: sha512-iMDbmAWtfU+MHpxt/I5iWI7cY6YVEZUQ3MBgPQ++XD1PELuJHIl82xBmObyP2KyQmkNB2dsqF7seoQQiAn5yDQ==}
@@ -21450,7 +21455,7 @@ packages:
postcss-selector-parser: 6.0.11
postcss-value-parser: 4.2.0
quick-lru: 5.1.1
resolve: 1.22.6
resolve: 1.22.8
transitivePeerDependencies:
- ts-node
dev: false

View File

@@ -37,6 +37,11 @@
"persistent": true,
"dependsOn": ["@formbricks/js#build"]
},
"@formbricks/api#go": {
"cache": false,
"persistent": true,
"dependsOn": ["@formbricks/api#build"]
},
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", ".next/**"],