@vizejs/nuxt 0.29.0 → 0.30.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/dist/index.js +20 -7
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -284,6 +284,19 @@ function buildNuxtDevAssetBase(baseURL = "/", buildAssetsDir = "/_nuxt/") {
284
284
  const normalizedAssetsDir = normalizeUrlPrefix(buildAssetsDir);
285
285
  return normalizedBase === "/" ? normalizedAssetsDir : normalizeUrlPrefix(`${normalizedBase}${normalizedAssetsDir.replace(/^\//, "")}`);
286
286
  }
287
+ function buildNuxtCompilerOptions(rootDir, baseURL = "/", buildAssetsDir = "/_nuxt/") {
288
+ return {
289
+ devUrlBase: buildNuxtDevAssetBase(baseURL, buildAssetsDir),
290
+ root: rootDir
291
+ };
292
+ }
293
+ function isVizeVirtualVueModuleId(id) {
294
+ return id.startsWith("\0") && /\.vue\.ts(?:\?|$)/.test(id);
295
+ }
296
+ function normalizeVizeVirtualVueModuleId(id) {
297
+ const withoutPrefix = id.startsWith("\0vize-ssr:") ? id.slice(10) : id.slice(1);
298
+ return withoutPrefix.replace(/\.ts$/, "");
299
+ }
287
300
 
288
301
  //#endregion
289
302
  //#region src/index.ts
@@ -303,11 +316,11 @@ var src_default = defineNuxtModule({
303
316
  const resolver = createResolver(import.meta.url);
304
317
  nuxt.options.vite.plugins = nuxt.options.vite.plugins || [];
305
318
  if (options.compiler !== false) {
306
- const devAssetBase = buildNuxtDevAssetBase(nuxt.options.app.baseURL, nuxt.options.app.buildAssetsDir);
307
- nuxt.options.vite.plugins.push(vize({ devUrlBase: devAssetBase }));
319
+ const compilerOptions = buildNuxtCompilerOptions(nuxt.options.rootDir, nuxt.options.app.baseURL, nuxt.options.app.buildAssetsDir);
320
+ nuxt.options.vite.plugins.push(vize(compilerOptions));
308
321
  if (nuxt.options.dev) {
309
322
  nuxt.options.nitro.virtual ||= {};
310
- nuxt.options.nitro.virtual["#vizejs/nuxt/dev-stylesheet-links-config"] = `export const devAssetBase = ${JSON.stringify(devAssetBase)};`;
323
+ nuxt.options.nitro.virtual["#vizejs/nuxt/dev-stylesheet-links-config"] = `export const devAssetBase = ${JSON.stringify(compilerOptions.devUrlBase)};`;
311
324
  addServerPlugin(resolver.resolve("./runtime/server/dev-stylesheet-links"));
312
325
  }
313
326
  nuxt.hook("vite:configResolved", (config) => {
@@ -334,7 +347,7 @@ var src_default = defineNuxtModule({
334
347
  name: "vizejs:nuxt-transform-bridge",
335
348
  enforce: "post",
336
349
  async transform(code, id) {
337
- if (!id.startsWith("\0") || !id.endsWith(".vue.ts")) return;
350
+ if (!isVizeVirtualVueModuleId(id)) return;
338
351
  let result = code;
339
352
  let changed = false;
340
353
  const nextComponentResult = injectNuxtComponentImports(result, (name) => {
@@ -369,11 +382,11 @@ var src_default = defineNuxtModule({
369
382
  const origTransform = plugin.transform;
370
383
  const isExtractionOnly = plugin.name.startsWith("unocss:global");
371
384
  plugin.transform = function(code, id, ...args) {
372
- if (id.startsWith("\0") && id.endsWith(".vue.ts")) {
373
- const normalizedId = id.slice(1).replace(/\.ts$/, "");
385
+ if (isVizeVirtualVueModuleId(id)) {
386
+ const normalizedId = normalizeVizeVirtualVueModuleId(id);
374
387
  let effectiveCode = code;
375
388
  if (isExtractionOnly) try {
376
- const originalSource = fs.readFileSync(normalizedId, "utf-8");
389
+ const originalSource = fs.readFileSync(normalizedId.split("?")[0], "utf-8");
377
390
  effectiveCode = code + "\n" + originalSource;
378
391
  } catch {}
379
392
  return origTransform.call(this, effectiveCode, normalizedId, ...args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/nuxt",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Nuxt module for Vize - compiler, musea gallery, linter, and type checker",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -34,10 +34,10 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@nuxt/kit": "^4.0.0",
37
- "@vizejs/vite-plugin": "0.29.0",
38
- "@vizejs/vite-plugin-musea": "0.29.0",
39
- "@vizejs/musea-nuxt": "0.29.0",
40
- "vize": "0.29.0"
37
+ "@vizejs/vite-plugin": "0.30.0",
38
+ "@vizejs/vite-plugin-musea": "0.30.0",
39
+ "@vizejs/musea-nuxt": "0.30.0",
40
+ "vize": "0.30.0"
41
41
  },
42
42
  "devDependencies": {
43
43
  "tsdown": "^0.9.0",