@stacksjs/iconify-generator 0.2.21 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +32 -13
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -292,24 +292,43 @@ export function generatePackageJson(
|
|
|
292
292
|
* Generate build.ts file for a collection
|
|
293
293
|
*/
|
|
294
294
|
export function generateBuildFile(prefix: string): string {
|
|
295
|
-
return `import {
|
|
295
|
+
return `import { existsSync, readdirSync, statSync } from 'node:fs'
|
|
296
|
+
import { dirname, join } from 'node:path'
|
|
296
297
|
import { fileURLToPath } from 'node:url'
|
|
297
298
|
import dts from 'bun-plugin-dtsx'
|
|
298
299
|
|
|
299
300
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
301
|
+
const srcDir = join(__dirname, 'src')
|
|
302
|
+
const distDir = join(__dirname, 'dist')
|
|
303
|
+
const distEntry = join(distDir, 'index.js')
|
|
304
|
+
|
|
305
|
+
// Skip rebuild when dist is already up to date. Makes prepublishOnly a
|
|
306
|
+
// no-op when CI pre-built the package in parallel earlier in the
|
|
307
|
+
// pipeline — and a no-op for local re-runs that didn't touch src/.
|
|
308
|
+
function isDistFresh() {
|
|
309
|
+
if (!existsSync(distEntry)) return false
|
|
310
|
+
const distMtime = statSync(distEntry).mtimeMs
|
|
311
|
+
for (const name of readdirSync(srcDir)) {
|
|
312
|
+
if (statSync(join(srcDir, name)).mtimeMs > distMtime) return false
|
|
313
|
+
}
|
|
314
|
+
return true
|
|
315
|
+
}
|
|
300
316
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
317
|
+
if (isDistFresh()) {
|
|
318
|
+
console.log('✓ @stacksjs/iconify-${prefix} dist is fresh, skipping rebuild')
|
|
319
|
+
} else {
|
|
320
|
+
await Bun.build({
|
|
321
|
+
entrypoints: [join(srcDir, 'index.ts')],
|
|
322
|
+
outdir: distDir,
|
|
323
|
+
target: 'bun',
|
|
324
|
+
format: 'esm',
|
|
325
|
+
plugins: [dts()],
|
|
326
|
+
minify: false,
|
|
327
|
+
sourcemap: 'external',
|
|
328
|
+
splitting: true,
|
|
329
|
+
})
|
|
330
|
+
console.log('✓ Built @stacksjs/iconify-${prefix}')
|
|
331
|
+
}
|
|
313
332
|
`
|
|
314
333
|
}
|
|
315
334
|
|