bimba-cli 0.7.11 → 0.7.12
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/serve.js +22 -2
package/package.json
CHANGED
package/serve.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serve as bunServe } from 'bun'
|
|
2
2
|
import * as compiler from 'imba/compiler'
|
|
3
|
-
import { watch, existsSync, statSync } from 'fs'
|
|
3
|
+
import { mkdirSync, watch, existsSync, statSync, writeFileSync } from 'fs'
|
|
4
4
|
import path from 'path'
|
|
5
5
|
import { theme } from './utils.js'
|
|
6
6
|
import { printerr } from './plugin.js'
|
|
@@ -385,6 +385,25 @@ function vendorSpecifierFromPath(pathname) {
|
|
|
385
385
|
return specifier || null
|
|
386
386
|
}
|
|
387
387
|
|
|
388
|
+
function vendorEntrypoint(entrypoint) {
|
|
389
|
+
if (path.isAbsolute(entrypoint)) return entrypoint
|
|
390
|
+
|
|
391
|
+
const dir = path.join(process.cwd(), 'node_modules', '.cache', 'bimba', 'vendor-entry')
|
|
392
|
+
mkdirSync(dir, { recursive: true })
|
|
393
|
+
|
|
394
|
+
const name = encodeURIComponent(entrypoint).replace(/%/g, '_')
|
|
395
|
+
const file = path.join(dir, name + '.js')
|
|
396
|
+
const specifier = JSON.stringify(entrypoint)
|
|
397
|
+
const code = [
|
|
398
|
+
`export * from ${specifier};`,
|
|
399
|
+
`import * as mod from ${specifier};`,
|
|
400
|
+
`export default (mod.default ?? mod);`,
|
|
401
|
+
'',
|
|
402
|
+
].join('\n')
|
|
403
|
+
writeFileSync(file, code)
|
|
404
|
+
return file
|
|
405
|
+
}
|
|
406
|
+
|
|
388
407
|
async function bundleVendor(entrypoint) {
|
|
389
408
|
try {
|
|
390
409
|
const stat = path.isAbsolute(entrypoint) && existsSync(entrypoint) ? statSync(entrypoint) : null
|
|
@@ -392,8 +411,9 @@ async function bundleVendor(entrypoint) {
|
|
|
392
411
|
const cached = _vendorCache.get(entrypoint)
|
|
393
412
|
if (cached && cached.mtime === mtime) return cached
|
|
394
413
|
|
|
414
|
+
const buildEntrypoint = vendorEntrypoint(entrypoint)
|
|
395
415
|
const result = await Bun.build({
|
|
396
|
-
entrypoints: [
|
|
416
|
+
entrypoints: [buildEntrypoint],
|
|
397
417
|
target: 'browser',
|
|
398
418
|
format: 'esm',
|
|
399
419
|
write: false,
|