@sparknest/ui-build-vue 1.3.0 → 1.4.0

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/index.mjs +38 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparknest/ui-build-vue",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Shared Vue component-library build core for Cedar and Maple",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,10 +19,10 @@
19
19
  "src"
20
20
  ],
21
21
  "dependencies": {
22
- "@vitejs/plugin-vue": "^5.2.4",
23
- "@vitejs/plugin-vue-jsx": "^3.1.0",
24
- "less": "^4.2.0",
25
- "vite": "^5.4.21",
22
+ "@vitejs/plugin-vue": "^6.0.11",
23
+ "@vitejs/plugin-vue-jsx": "^5.1.6",
24
+ "less": "^4.4.0",
25
+ "vite": "^8.3.8",
26
26
  "vue-compat-legacy": "npm:vue@3.2.0"
27
27
  },
28
28
  "peerDependencies": {
package/src/index.mjs CHANGED
@@ -326,6 +326,39 @@ async function buildModules(config, format, outDir, extension) {
326
326
  })
327
327
  }
328
328
 
329
+ // A published library must not ship bundler-private helpers. Vite's module
330
+ // preload injection is the known offender: it emits `_virtual/preload-helper`
331
+ // and rewrites every dynamic `import()` into `__vitePreload(...)`. When a
332
+ // consumer bundles the library with rolldown (vite 8), rolldown injects its own
333
+ // helper into the same module -> `PARSE_ERROR: Identifier __vitePreload has
334
+ // already been declared`. `build.modulePreload: false` does NOT prevent this on
335
+ // vite 5 (insertPreload only checks ssr / build.lib / isWorker), so the fix has
336
+ // to happen in the library source: ship a static import (externalized) instead
337
+ // of a dynamic one.
338
+ async function assertNoBundlerHelpers(config) {
339
+ const root = resolve(config.root)
340
+ const markers = ['_virtual/preload-helper', '__vitePreload']
341
+ const offenders = []
342
+ for (const output of ['es', 'lib']) {
343
+ const dir = resolve(root, output)
344
+ if (!existsSync(dir)) continue
345
+ for (const path of await walk(dir)) {
346
+ if (!/\.[cm]?js$/.test(path)) continue
347
+ const code = await readFile(path, 'utf8')
348
+ if (markers.some((marker) => code.includes(marker))) {
349
+ offenders.push(relative(root, path))
350
+ }
351
+ }
352
+ }
353
+ if (offenders.length) {
354
+ throw new Error([
355
+ 'Library output contains bundler-private preload helpers; consumers bundling with rolldown/vite 8 cannot parse them:',
356
+ ...offenders.map((path) => ` ${path}`),
357
+ 'Replace the dynamic import() in the matching source file with a static import and mark the module external.',
358
+ ].join('\n'))
359
+ }
360
+ }
361
+
329
362
  async function buildBundle(config, format, outDir, fileName) {
330
363
  const root = resolve(config.root)
331
364
  await build({
@@ -339,7 +372,10 @@ async function buildBundle(config, format, outDir, fileName) {
339
372
  cssTarget: [...browserTargets],
340
373
  copyPublicDir: false,
341
374
  emptyOutDir: false,
342
- minify: format === 'cjs' ? false : 'esbuild',
375
+ // vite 8 (rolldown) dropped esbuild from its own dependencies; naming the
376
+ // `'esbuild'` minifier requires installing esbuild separately. `true` selects
377
+ // the bundler's default minifier (oxc on vite 8).
378
+ minify: format === 'cjs',
343
379
  outDir,
344
380
  lib: {
345
381
  entry: resolve(root, config.entry),
@@ -408,6 +444,7 @@ export async function buildLibrary(userConfig) {
408
444
 
409
445
  await buildModules(config, 'es', 'es', 'mjs')
410
446
  await buildModules(config, 'cjs', 'lib', 'js')
447
+ await assertNoBundlerHelpers(config)
411
448
  await buildBundle(config, 'es', 'es', `${config.bundleName}.esm.js`)
412
449
  await buildBundle(config, 'cjs', 'lib', `${config.bundleName}.cjs.js`)
413
450
  await buildBundle(config, 'umd', 'umd', `${config.bundleName}.js`)