1
0
mirror of https://github.com/tabler/tabler.git synced 2026-08-05 19:03:18 +04:00

Copy only runtime files into dist/libs instead of whole npm packages (#2781)

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Bartosz-Do
2026-08-05 00:29:33 +02:00
committed by GitHub
parent 52fe729781
commit 346e0914bc
3 changed files with 52 additions and 5 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@tabler/core": patch
---
Fixed oversized `dist/libs` by copying only the runtime files each library declares in `libs.json`, plus the assets HugeRTE loads at runtime and every upstream license file.
+35 -5
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env node
import { existsSync, mkdirSync } from 'node:fs'
import { globSync } from 'glob'
import { emptyDirSync, copySync } from 'fs-extra/esm'
import libs from '../libs.json' with { type: 'json' }
import { fileURLToPath } from 'node:url'
@@ -12,6 +13,7 @@ interface LibConfig {
npm?: string
js?: string[]
css?: string[]
extra?: string[]
head?: boolean
}
@@ -24,10 +26,10 @@ const libsData = libs as Libs
emptyDirSync(join(__dirname, '..', 'dist/libs'))
for (const name in libsData) {
const { npm } = libsData[name]
const { npm, js, css, extra } = libsData[name]
if (npm) {
const from = join(__dirname, '..', `node_modules/${npm}`)
const pkgDir = join(__dirname, '..', `node_modules/${npm}`)
const to = join(__dirname, '..', `dist/libs/${npm}`)
// create dir in dist/libs
@@ -35,9 +37,37 @@ for (const name in libsData) {
mkdirSync(to, { recursive: true })
}
copySync(from, to, {
dereference: true,
})
const files = [...(js || []), ...(css || [])]
for (const pattern of extra || []) {
const matches = globSync(pattern, { cwd: pkgDir, nodir: true, posix: true })
if (matches.length === 0) {
throw new Error(`copy-libs: ${name} — "${pattern}" matched no files in ${npm}`)
}
files.push(...matches)
}
if (files) {
for (const file of files) {
copySync(join(pkgDir, file), join(to, file), {
dereference: true,
})
}
}
// Ship each upstream license alongside its files — we redistribute the
// built bundles, and MIT/BSD/Apache all require the notice to travel with them.
const licenses = globSync('{license,licence,copying}*', { cwd: pkgDir, nodir: true, nocase: true })
if (licenses.length === 0) {
console.warn(`Warning: no license file found for ${npm}`)
}
for (const file of licenses) {
copySync(join(pkgDir, file), join(to, file), {
dereference: true,
})
}
console.log(`Successfully copied ${npm}`)
}
+12
View File
@@ -98,6 +98,18 @@
"npm": "hugerte",
"js": [
"hugerte.min.js"
],
"extra": [
"themes/silver/theme.min.js",
"models/dom/model.min.js",
"icons/default/icons.min.js",
"plugins/*/plugin.min.js",
"plugins/help/js/i18n/keynav/*.js",
"plugins/emoticons/js/*.min.js",
"skins/ui/oxide/*.min.css",
"skins/ui/oxide-dark/*.min.css",
"skins/content/default/content.min.css",
"skins/content/dark/content.min.css"
]
},
"plyr": {