Skip to content
Closed
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
39 changes: 39 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"git": {
"commitMessage": "chore(release): ${version} [skip ci]\n\n${changelog}",
"tagName": "v${version}",
"requireCleanWorkingDir": false,
"requireBranch": false,
"commit": true,
"tag": true,
"push": true
},
"github": {
"release": true,
"releaseName": "v${version}",
"autoGenerate": false
},
"npm": {
"publish": true
},
"hooks": {
"before:init": ["npm run test"],
"after:bump": ["npm run build"],
"after:release": "echo Successfully released ${name} v${version} to ${repo.repository}."
},
"plugins": {
"@release-it/conventional-changelog": {
"preset": "conventionalcommits",
"infile": "CHANGELOG.md",
"header": "# Changelog\n\nAll notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.",
"ignoreRecommendedBump": false
},
"@release-it-plugins/workspaces": {
"workspaces": ["proxy"],
"publish": true,
"additionalManifests": {
"versionUpdates": ["proxy/package.json"]
}
}
}
}
141 changes: 141 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import * as esbuild from 'esbuild'
import AnalyzerPlugin from 'esbuild-analyzer'
import fs from 'fs'

const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'))

// Externe Dependencies (nicht bündeln)
const external = [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
...Object.keys(pkg.optionalDependencies || {}),
'util'
]

// Gemeinsame Build-Optionen für Node.js (Main Bundle)
const commonNodeOptions = {
bundle: true,
target: 'es2015',
sourcemap: true,
minify: true,
treeShaking: true,
legalComments: 'none',
logLevel: 'info',
external,
minifyWhitespace: true,
minifySyntax: true,
metafile: true,
}

// Gemeinsame Build-Optionen für Browser (Proxy Bundle)
const browserOptions = {
bundle: true,
platform: 'browser',
target: 'es2020',
format: 'esm',
sourcemap: true,
minify: true,
treeShaking: true,
legalComments: 'none',
logLevel: 'info',
external,
minifyWhitespace: true,
minifySyntax: true,
metafile: true,
charset: 'utf8',
}

// Stats-Verzeichnis erstellen
if (!fs.existsSync('stats')) {
fs.mkdirSync('stats', { recursive: true })
}

// Main Bundle (fsxa-api)
console.log('Building main bundle (fsxa-api)...')

// CJS build - use platform: 'node' for proper CommonJS exports
await esbuild.build({
...commonNodeOptions,
platform: 'node',
entryPoints: ['src/index.ts'],
outfile: 'dist/fsxa-api.cjs.js',
format: 'cjs',
plugins: [
AnalyzerPlugin({
outfile: 'stats/fsxa-api-cjs.html',
})
],
})

// ESM build - use platform: 'neutral' to avoid Node.js-specific code
await esbuild.build({
...commonNodeOptions,
platform: 'neutral',
entryPoints: ['src/index.ts'],
outfile: 'dist/fsxa-api.es5.js',
format: 'esm',
plugins: [
AnalyzerPlugin({
outfile: 'stats/fsxa-api-esm.html',
})
],
})

console.log('Main bundle built successfully!')

// Proxy Bundle (fsxa-proxy-api)
console.log('Building proxy bundle (fsxa-proxy-api)...')

await esbuild.build({
...browserOptions,
entryPoints: ['src/proxy.ts'],
outfile: 'proxy/dist/fsxa-proxy-api.cjs.js',
format: 'cjs',
plugins: [
AnalyzerPlugin({
outfile: 'stats/fsxa-proxy-api-cjs.html',
})
],
})

await esbuild.build({
...browserOptions,
entryPoints: ['src/proxy.ts'],
outfile: 'proxy/dist/fsxa-proxy-api.es5.js',
format: 'esm',
plugins: [
AnalyzerPlugin({
outfile: 'stats/fsxa-proxy-api-esm.html',
})
],
})

console.log('Proxy bundle built successfully!')

// Bundle-Größen ausgeben
console.log('\n📦 Bundle Sizes:')
console.log('─'.repeat(60))

const files = [
'dist/fsxa-api.cjs.js',
'dist/fsxa-api.es5.js',
'proxy/dist/fsxa-proxy-api.cjs.js',
'proxy/dist/fsxa-proxy-api.es5.js',
]

files.forEach((file) => {
if (fs.existsSync(file)) {
const stats = fs.statSync(file)
const sizeKB = (stats.size / 1024).toFixed(2)
console.log(`${file.padEnd(45)} ${sizeKB.padStart(10)} KB`)
}
})

console.log('─'.repeat(60))

console.log('\n✓ Bundle analysis reports generated:')
console.log(' - stats/fsxa-api-cjs.html')
console.log(' - stats/fsxa-api-esm.html')
console.log(' - stats/fsxa-proxy-api-cjs.html')
console.log(' - stats/fsxa-proxy-api-esm.html')
console.log('\nBuild complete!')
Loading
Loading