Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
semyenov committed Jul 2, 2024
1 parent 362d243 commit 7594e95
Show file tree
Hide file tree
Showing 28 changed files with 170 additions and 181 deletions.
11 changes: 8 additions & 3 deletions apps/backend/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import build from '@regioni/build'
export default build({
src: './src',

input: './index.ts',
input: ['./index.ts'],
pkg: './package.json',
tsconfig: './tsconfig.build.json',
resolve: {
modulePaths: [],
},
preferBuiltins: true,
modulesOnly: true,
modulePaths: [
'node_modules',
'../../packages'
],
}
})
Binary file removed mongodb.mongodb-vscode-1.5.0.vsix
Binary file not shown.
3 changes: 2 additions & 1 deletion packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/index.mjs",
"require": "./dist/cjs/index.cjs"
}
Expand Down Expand Up @@ -56,6 +56,7 @@
"defu": "^6.1.4",
"dotenv": "^16.4.5",
"esbuild": "^0.21.5",
"fast-glob": "^3.3.2",
"rollup": "^4.4.0",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/build/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export default build({

pkg: 'package.json',
tsconfig: 'tsconfig.build.json',
input: 'index.ts',
input: ['index.ts'],
})
129 changes: 75 additions & 54 deletions packages/build/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import * as fs from 'node:fs'
import * as path from 'node:path'
import * as process from 'node:process'

import glob from 'fast-glob'

import alias from '@rollup/plugin-alias'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import defu from 'defu'
import { defineConfig } from 'rollup'
import { RollupOptions, defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'

Expand All @@ -26,17 +28,19 @@ interface PackageJson {
dependencies: Record<string, string>
main: string
module: string
types: string

[key: string]: any
}

export interface Options {
cwd?: string
src?: string
out?: string

pkg?: string
tsconfig?: string
input?: string
input?: string[]

json?: RollupJsonOptions
alias?: RollupAliasOptions
Expand All @@ -49,16 +53,21 @@ export interface Options {
function build(options?: Options) {
const cwdDir = path.resolve(process.cwd(), options?.cwd || '.')
const srcDir = path.resolve(cwdDir, options?.src || './src')
const outDir = path.resolve(cwdDir, options?.out || './dist')

const pkgFile = path.join(cwdDir, options?.pkg || 'package.json')
const tsconfigFile = path.join(cwdDir, options?.tsconfig || 'tsconfig.json')
const inputFile = path.resolve(srcDir, options?.input || 'index.ts')

const inputFiles = options?.input?.flatMap((file) =>
glob.sync(path.resolve(srcDir, file)),
)

if (!inputFiles) {
throw new Error('No input files found')
}

const pkg: PackageJson = JSON.parse(
fs.readFileSync(
pkgFile,
{ encoding: 'utf-8' },
),
fs.readFileSync(pkgFile, { encoding: 'utf-8' }),
)

const author = pkg.author
Expand All @@ -75,9 +84,10 @@ function build(options?: Options) {
const defaultOptions: Options = {
cwd: cwdDir,
src: srcDir,
out: outDir,

pkg: pkgFile,
input: inputFile,
input: inputFiles,
tsconfig: tsconfigFile,

json: {
Expand Down Expand Up @@ -106,54 +116,65 @@ function build(options?: Options) {

const opts = defu(
options,
defaultOptions,
defaultOptions
)

return defineConfig([
{
input: inputFile,
external,
output: [
{
file: pkg.main,
sourcemap: true,
format: 'cjs',
banner,
},
{
file: pkg.module,
sourcemap: true,
format: 'esm',
banner,
},
],
plugins: [
json(opts.json),
alias(opts.alias),
resolve(opts.resolve),
commonjs(opts.commonjs),
esbuild(opts.esbuild),
],
},
{
input: inputFile,
external,
output: [
{
file: pkg.types,
sourcemap: true,
format: 'esm',
banner,
},
],
plugins: [
json(opts.json),
alias(opts.alias),
resolve(opts.resolve),
dts(opts.dts),
],
},
])
return defineConfig(
inputFiles.flatMap((input) => {
console.log(`Building ${input}`)

const basename = path.relative(srcDir, input).replace(/\.[^.]+$/, '')

const rollupOptions: RollupOptions = {
input,
external,
output: [
{
file: path.join(outDir, `cjs/${basename}.cjs`),
sourcemap: true,
format: 'cjs',
banner,
},
{
file: path.join(outDir, `esm/${basename}.mjs`),
sourcemap: true,
format: 'esm',
banner,
},
],
plugins: [
json(opts.json),
alias(opts.alias),
resolve(opts.resolve),
commonjs(opts.commonjs),
esbuild(opts.esbuild),
],
}
const dtsOptions: RollupOptions = {
input,
external,
output: [
{
file: path.join(outDir, `types/${basename}.d.ts`),
sourcemap: true,
format: 'esm',
banner,
},
],
plugins: [
json(opts.json),
alias(opts.alias),
resolve(opts.resolve),
dts(opts.dts),
],
}

return [
rollupOptions,
dtsOptions
]
}),
)
}

export default build
40 changes: 0 additions & 40 deletions packages/lib/automerge/index.ts

This file was deleted.

27 changes: 27 additions & 0 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@
"bugs": "https://gitea.local/regioni/lib/issues",
"keywords": [],
"sideEffects": false,
"exports": {
"./ws": {
"types": "./dist/types/index.d.ts",
"import": "./dist/esm/ws/index.mjs",
"require": "./dist/cjs/ws/index.cjs"
}
},
"main": "./dist/cjs/index.cjs",
"module": "./dist/esm/index.mjs",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
"*": [
"./dist/*",
"./dist/index.d.ts"
]
}
},
"files": [
"*"
],
Expand All @@ -33,19 +51,28 @@
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@trpc/server": "^10.45.2",
"ajv": "^8.16.0",
"ajv-errors": "^3.0.0",
"ajv-formats": "^3.0.1",
"ajv-i18n": "^4.2.0",
"ajv-keywords": "^5.1.0",
"consola": "^3.2.3",
"cross-env": "7.0.3",
"defu": "^6.1.4",
"dotenv": "^16.4.5",
"esbuild": "^0.21.5",
"fast-glob": "^3.3.2",
"rollup": "^4.4.0",
"rollup-plugin-dts": "^6.1.0",
"rollup-plugin-esbuild": "^6.1.0",
"rollup-plugin-peer-deps-external": "^2.2.4"
},
"devDependencies": {
"@sozdev/eslint-config": "^0.0.11",
"@types/events": "^3",
"esno": "^4.7.0",
"events": "^3.3.0",
"lint-staged": "^15.2.7",
"simple-git-hooks": "^2.9.0",
"typescript": "^5.2.2",
Expand Down
49 changes: 0 additions & 49 deletions packages/lib/radix/index.ts

This file was deleted.

Loading

0 comments on commit 7594e95

Please sign in to comment.