Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rslib support #1545

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ kubb.log
hello
.log
.kubb
.rslib
*/mocks/hellowWorld.js
docs/.vitepress/cache/**
docs/.vitepress/dist/**
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
],
"scripts": {
"build": "tsup",
"build:beta": "rslib build",
"clean": "npx rimraf ./dist",
"lint": "bun biome lint .",
"lint:fix": "bun biome lint --apply-unsafe .",
Expand Down Expand Up @@ -67,12 +68,14 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@kubb/config-tsup": "workspace:*",
"@kubb/config-rslib": "workspace:*",
"@kubb/plugin-oas": "workspace:*",
"@types/cli-progress": "^3.11.6",
"@types/node": "^20.17.27",
"@types/semver": "^7.5.8",
"source-map-support": "^0.5.21",
"tsup": "catalog:",
"@rslib/core": "catalog:",
"typescript": "catalog:"
},
"engines": {
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { options } from '@kubb/config-rslib'
import { defineConfig } from '@rslib/core'

export default defineConfig({
...options,
source: {
...options.source,
tsconfigPath: './tsconfig.build.json',
},
})
9 changes: 9 additions & 0 deletions packages/cli/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"paths": {}
},
"include": ["src/**/*"]
}
1 change: 1 addition & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"include": ["src/**/*", "./package.json", "./tsup.config.ts", "./vitest.config.ts"]
}
2 changes: 2 additions & 0 deletions packages/cli/tsup.config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _default: import("tsup").Options | import("tsup").Options[] | ((overrideOptions: import("tsup").Options) => import("tsup").Options | import("tsup").Options[] | Promise<import("tsup").Options | import("tsup").Options[]>);
export default _default;
2 changes: 2 additions & 0 deletions packages/cli/vitest.config.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _default: import("vite").UserConfig;
export default _default;
53 changes: 53 additions & 0 deletions packages/config-rslib/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "@kubb/config-rslib",
"version": "3.5.7",
"private": true,
"sideEffects": false,
"type": "module",
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"default": "./dist/index.cjs"
},
"./package.json": "./package.json",
"./*": "./*"
},
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"src",
"dist",
"!/**/**.test.**",
"!/**/__tests__/**"
],
"scripts": {
"build": "rslib build",
"clean": "npx rimraf ./dist",
"lint": "bun biome lint .",
"lint:fix": "bun biome lint --apply-unsafe .",
"release": "pnpm publish --no-git-check",
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
"start": "rslib build --watch",
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
},
"dependencies": {
"@microsoft/api-extractor": "^7.52.1"
},
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@types/node": "^20.17.17",
"@rslib/core": "catalog:"
},
"peerDependencies": {
"@rslib/core": "^0.4.0"
},
"engines": {
"node": ">=20"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
}
}
4 changes: 4 additions & 0 deletions packages/config-rslib/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { defineConfig } from '@rslib/core'
import { options } from './src/index.ts'

export default defineConfig(options)
55 changes: 55 additions & 0 deletions packages/config-rslib/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { LibConfig, RslibConfig } from '@rslib/core'

export const optionsESM: LibConfig = {
bundle: false,
format: 'esm',
dts: { bundle: true, autoExtension: true },
syntax: ['es2015', 'node 20'],
shims: {
cjs: {
'import.meta.url': true,
},
esm: {
__dirname: true,
__filename: true,
require: true,
},
},
}

export const optionsCJS: LibConfig = {
bundle: false,
format: 'cjs',
dts: { bundle: true, autoExtension: true },
syntax: ['es2015', 'node 20'],
shims: {
cjs: {
'import.meta.url': true,
},
esm: {
__dirname: true,
__filename: true,
require: true,
},
},
}

export const options: RslibConfig = {
source: {
entry: {
index: 'src/index.ts',
},
},
lib: [optionsESM, optionsCJS],
output: {
target: 'node',
sourceMap: true,
cleanDistPath: true,
},
}

export default {
default: options,
esm: optionsESM,
cjs: optionsCJS,
} as const
5 changes: 5 additions & 0 deletions packages/config-rslib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"include": ["src/**/*", "./package.json", "./tsup.config.ts", "./vitest.config.ts"]
}
2 changes: 1 addition & 1 deletion packages/config-tsup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"devDependencies": {
"@kubb/config-ts": "workspace:*",
"@types/node": "^20.17.27",
"tsup": "^8.4.0"
"tsup": "catalog:"
},
"peerDependencies": {
"tsup": "^8.1.0"
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
],
"scripts": {
"build": "tsup",
"build:beta": "rslib build",
"clean": "npx rimraf ./dist",
"lint": "bun biome lint .",
"lint:fix": "bun biome lint --apply-unsafe .",
Expand Down
26 changes: 26 additions & 0 deletions packages/core/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { options, optionsCJS, optionsESM } from '@kubb/config-rslib'
import { defineConfig } from '@rslib/core'

export default defineConfig({
...options,
source: {
...options.source,
entry: {
index: 'src/index.ts',
transformers: 'src/transformers.ts',
// utils: 'src/utils/index.ts',
logger: 'src/logger.ts',
// mocks: 'src/mocks/index.ts',
},
tsconfigPath: './tsconfig.build.json',
},
lib: [
{
...optionsCJS,
output: {
externals: [/p-queue/, /find-up/, /camelcase/],
},
},
optionsESM,
],
})
2 changes: 1 addition & 1 deletion packages/core/src/FileManager.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import path from 'node:path'

import { format } from '../mocks/format.ts'
import { FileManager, combineExports, combineImports, combineSources, getSource } from './FileManager.ts'
import { format } from './mocks/format.ts'

import type * as KubbFile from '@kubb/fs/types'
import { createFile } from './utils'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { camelCase, pascalCase } from '../src/transformers/casing.ts'
import { camelCase, pascalCase } from '../transformers/casing.ts'

import path from 'node:path'
import type { File, ResolvedFile } from '@kubb/fs/types'
import { getSource } from '../src/FileManager'
import type { PluginManager } from '../src/PluginManager.ts'
import type { Logger } from '../src/logger'
import type { Plugin } from '../src/types.ts'
import { createFile } from '../src/utils'
import { getSource } from '../FileManager'
import type { PluginManager } from '../PluginManager.ts'
import type { Logger } from '../logger'
import type { Plugin } from '../types.ts'
import { createFile } from '../utils'

export const mockedLogger = {
emit(_type, _message) {},
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions packages/core/src/transformers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './transformers/index.ts'
9 changes: 9 additions & 0 deletions packages/core/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"paths": {}
},
"include": ["src/**/*"]
}
9 changes: 4 additions & 5 deletions packages/core/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ export default defineConfig([
...optionsCJS,
entry: {
index: 'src/index.ts',
transformers: 'src/transformers/index.ts',
transformers: 'src/transformers.ts',
utils: 'src/utils/index.ts',
logger: 'src/logger.ts',
mocks: 'mocks/index.ts',
mocks: 'src/mocks/index.ts',
},
noExternal: [/p-queue/, /find-up/, /natural-orderby/, /camelcase/, /tinyrainbow/],
},
{
...optionsESM,
Expand All @@ -21,8 +20,8 @@ export default defineConfig([
transformers: 'src/transformers/index.ts',
utils: 'src/utils/index.ts',
logger: 'src/logger.ts',
mocks: 'mocks/index.ts',
mocks: 'src/mocks/index.ts',
},
noExternal: [/natural-orderby/, /tinyrainbow/],
external: [/p-queue/, /find-up/, /camelcase/],
},
])
Loading
Loading