mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 05:06:55 +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:
1 parent
52fe729781
commit
346e0914bc
3 files changed
+52
-5
No files matched your search
@@ -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.
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
import { existsSync, mkdirSync } from 'node:fs'
|
import { existsSync, mkdirSync } from 'node:fs'
|
||||||
|
import { globSync } from 'glob'
|
||||||
import { emptyDirSync, copySync } from 'fs-extra/esm'
|
import { emptyDirSync, copySync } from 'fs-extra/esm'
|
||||||
import libs from '../libs.json' with { type: 'json' }
|
import libs from '../libs.json' with { type: 'json' }
|
||||||
import { fileURLToPath } from 'node:url'
|
import { fileURLToPath } from 'node:url'
|
||||||
@@ -12,6 +13,7 @@ interface LibConfig {
|
|||||||
npm?: string
|
npm?: string
|
||||||
js?: string[]
|
js?: string[]
|
||||||
css?: string[]
|
css?: string[]
|
||||||
|
extra?: string[]
|
||||||
head?: boolean
|
head?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,10 +26,10 @@ const libsData = libs as Libs
|
|||||||
emptyDirSync(join(__dirname, '..', 'dist/libs'))
|
emptyDirSync(join(__dirname, '..', 'dist/libs'))
|
||||||
|
|
||||||
for (const name in libsData) {
|
for (const name in libsData) {
|
||||||
const { npm } = libsData[name]
|
const { npm, js, css, extra } = libsData[name]
|
||||||
|
|
||||||
if (npm) {
|
if (npm) {
|
||||||
const from = join(__dirname, '..', `node_modules/${npm}`)
|
const pkgDir = join(__dirname, '..', `node_modules/${npm}`)
|
||||||
const to = join(__dirname, '..', `dist/libs/${npm}`)
|
const to = join(__dirname, '..', `dist/libs/${npm}`)
|
||||||
|
|
||||||
// create dir in dist/libs
|
// create dir in dist/libs
|
||||||
@@ -35,9 +37,37 @@ for (const name in libsData) {
|
|||||||
mkdirSync(to, { recursive: true })
|
mkdirSync(to, { recursive: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
copySync(from, to, {
|
const files = [...(js || []), ...(css || [])]
|
||||||
dereference: true,
|
|
||||||
})
|
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}`)
|
console.log(`Successfully copied ${npm}`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,18 @@
|
|||||||
"npm": "hugerte",
|
"npm": "hugerte",
|
||||||
"js": [
|
"js": [
|
||||||
"hugerte.min.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": {
|
"plyr": {
|
||||||
|
|||||||
Reference in new issue
Block a user