vuetify-nuxt-module 0.7.2 → 0.8.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.
package/dist/module.d.mts CHANGED
@@ -241,7 +241,7 @@ interface MOptions {
241
241
  * @see https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin
242
242
  * @see https://github.com/userquin/vuetify-nuxt-module/issues/78 and https://github.com/userquin/vuetify-nuxt-module/issues/74
243
243
  */
244
- styles?: true | 'none' | 'expose' | 'sass' | {
244
+ styles?: true | 'none' | 'sass' | {
245
245
  configFile: string;
246
246
  };
247
247
  /**
package/dist/module.d.ts CHANGED
@@ -241,7 +241,7 @@ interface MOptions {
241
241
  * @see https://github.com/vuetifyjs/vuetify-loader/tree/master/packages/vite-plugin
242
242
  * @see https://github.com/userquin/vuetify-nuxt-module/issues/78 and https://github.com/userquin/vuetify-nuxt-module/issues/74
243
243
  */
244
- styles?: true | 'none' | 'expose' | 'sass' | {
244
+ styles?: true | 'none' | 'sass' | {
245
245
  configFile: string;
246
246
  };
247
247
  /**
package/dist/module.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "nuxt": "^3.6.5",
6
6
  "bridge": false
7
7
  },
8
- "version": "0.7.2"
8
+ "version": "0.8.0"
9
9
  }
package/dist/module.mjs CHANGED
@@ -6,16 +6,15 @@ import { existsSync, statSync } from 'node:fs';
6
6
  import { resolve, dirname, extname } from 'node:path';
7
7
  import process from 'node:process';
8
8
  import { createConfigLoader } from 'unconfig';
9
- import { readFile, utimes } from 'node:fs/promises';
10
- import { resolveVuetifyBase, normalizePath, writeStyles, cacheDir, generateImports } from '@vuetify/loader-shared';
9
+ import { readFile } from 'node:fs/promises';
10
+ import { resolveVuetifyBase, normalizePath, generateImports } from '@vuetify/loader-shared';
11
11
  import { isAbsolute, join, relative } from 'pathe';
12
- import { normalizePath as normalizePath$1 } from 'vite';
13
12
  import { pathToFileURL } from 'node:url';
14
13
  import { parseQuery, parseURL } from 'ufo';
15
14
  import destr from 'destr';
16
15
  import { transformAssetUrls } from 'vite-plugin-vuetify';
17
16
 
18
- const version = "0.7.2";
17
+ const version = "0.8.0";
19
18
 
20
19
  const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
21
20
  const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_CONFIGURATION.slice("virtual:".length)}`;
@@ -499,103 +498,13 @@ function isSubdir(root, test) {
499
498
  const relative$1 = relative(root, test);
500
499
  return relative$1 && !relative$1.startsWith("..") && !isAbsolute(relative$1);
501
500
  }
502
- const styleImportRegexp = /(@use |meta\.load-css\()['"](vuetify(?:\/lib)?(?:\/styles(?:\/main(?:\.sass)?)?)?)['"]/;
503
501
  function vuetifyStylesPlugin(options, logger) {
504
502
  const vuetifyBase = resolveVuetifyBase();
505
- const files = /* @__PURE__ */ new Set();
506
- let server;
507
- let context;
508
- let resolve;
509
- let promise;
510
- let needsTouch = false;
511
- const blockingModules = /* @__PURE__ */ new Set();
512
- let pendingModules;
513
- async function getPendingModules() {
514
- if (!server) {
515
- await new Promise((resolve2) => setTimeout(resolve2, 0));
516
- const modules = Array.from(context.getModuleIds()).filter((id) => {
517
- return !blockingModules.has(id) && !/\w\.(s[ac]|c)ss/.test(id);
518
- }).map((id) => context.getModuleInfo(id)).filter((module) => module.code == null);
519
- pendingModules = modules.map((module) => module.id);
520
- if (!pendingModules.length)
521
- return 0;
522
- const promises = modules.map((module) => context.load(module));
523
- await Promise.race(promises);
524
- return promises.length;
525
- } else {
526
- const modules = Array.from(server.moduleGraph.urlToModuleMap.entries()).filter(([k, v]) => v.transformResult == null && !k.startsWith("/@id/") && !/\w\.(s[ac]|c)ss/.test(k) && !blockingModules.has(v.id) && !/\/node_modules\/\.vite\/deps\/(?!vuetify[._])/.test(k));
527
- pendingModules = modules.map(([, v]) => v.id);
528
- if (!pendingModules.length)
529
- return 0;
530
- const promises = modules.map(([k, v]) => server.transformRequest(k).then(() => v));
531
- await Promise.race(promises);
532
- return promises.length;
533
- }
534
- }
535
- let timeout;
536
- async function awaitBlocking() {
537
- let pending;
538
- do {
539
- clearTimeout(timeout);
540
- timeout = setTimeout(() => {
541
- console.error("vuetify:styles fallback timeout hit", {
542
- blockingModules: Array.from(blockingModules.values()),
543
- pendingModules,
544
- // @ts-expect-error not exported?
545
- pendingRequests: server?._pendingRequests.keys()
546
- });
547
- resolve(false);
548
- }, options.stylesTimeout);
549
- pending = await Promise.any([
550
- promise,
551
- getPendingModules()
552
- ]);
553
- logger.info(pending, "pending modules", pendingModules);
554
- } while (pending);
555
- resolve(false);
556
- }
557
- async function awaitResolve(id) {
558
- if (id)
559
- blockingModules.add(id);
560
- if (!promise) {
561
- promise = new Promise((_resolve) => resolve = _resolve);
562
- awaitBlocking();
563
- await promise;
564
- clearTimeout(timeout);
565
- blockingModules.clear();
566
- logger.info("writing styles");
567
- await writeStyles(files);
568
- if (server && needsTouch) {
569
- const cacheFile = normalizePath$1(cacheDir("styles.scss"));
570
- logger.log("cacheFile", cacheFile);
571
- server.moduleGraph.getModulesByFile(cacheFile)?.forEach((module) => {
572
- module.importers.forEach((module2) => {
573
- if (module2.file) {
574
- const now = /* @__PURE__ */ new Date();
575
- logger.info(`touching ${module2.file}`);
576
- utimes(module2.file, now, now);
577
- }
578
- });
579
- });
580
- needsTouch = false;
581
- }
582
- promise = null;
583
- }
584
- return promise;
585
- }
586
503
  let configFile;
587
504
  const tempFiles = /* @__PURE__ */ new Map();
588
505
  return {
589
506
  name: "vuetify:styles:nuxt",
590
507
  enforce: "pre",
591
- configureServer(_server) {
592
- server = _server;
593
- },
594
- buildStart() {
595
- if (!server) {
596
- context = this;
597
- }
598
- },
599
508
  configResolved(config) {
600
509
  if (config.plugins.findIndex((plugin) => plugin.name === "vuetify:styles") > -1)
601
510
  throw new Error("Remove vite-plugin-vuetify from your Nuxt config file, this module registers a modified version.");
@@ -613,20 +522,6 @@ function vuetifyStylesPlugin(options, logger) {
613
522
  } else if (options.styles === "sass") {
614
523
  const target = source.replace(/\.css$/, ".sass");
615
524
  return this.resolve(target, importer, { skipSelf: true, custom });
616
- } else if (options.styles === "expose") {
617
- awaitResolve();
618
- const resolution = await this.resolve(
619
- source.replace(/\.css$/, ".sass"),
620
- importer,
621
- { skipSelf: true, custom }
622
- );
623
- if (resolution) {
624
- if (!files.has(resolution.id)) {
625
- needsTouch = true;
626
- files.add(resolution.id);
627
- }
628
- return "/@plugin-vuetify/lib/__void__";
629
- }
630
525
  } else if (typeof options.styles === "object") {
631
526
  const resolution = await this.resolve(source, importer, { skipSelf: true, custom });
632
527
  if (!resolution)
@@ -640,17 +535,6 @@ function vuetifyStylesPlugin(options, logger) {
640
535
  }
641
536
  }
642
537
  },
643
- async transform(code, id) {
644
- if (options.styles === "expose" && [".scss", ".sass"].some((v) => id.endsWith(v)) && styleImportRegexp.test(code)) {
645
- logger.info(`awaiting ${id}`);
646
- await awaitResolve(id);
647
- logger.info(`returning ${id}`);
648
- return {
649
- code: code.replace(styleImportRegexp, '$1".cache/vuetify/styles.scss"'),
650
- map: null
651
- };
652
- }
653
- },
654
538
  load(id) {
655
539
  if (/^\/@plugin-vuetify\/lib\/__void__(\?.*)?$/.test(id))
656
540
  return "";
@@ -1158,8 +1042,7 @@ export function dateConfiguration() {
1158
1042
  `;
1159
1043
  }
1160
1044
  const { adapter: _adapter, ...newDateOptions } = ctx.vuetifyOptions.date ?? {};
1161
- const imports = ctx.dateAdapter === "vuetify" ? ctx.vuetify3_4 === true ? "" : "import { VuetifyDateAdapter } from 'vuetify/labs/date/adapters/vuetify'" : ctx.dateAdapter === "custom" ? "" : `import Adapter from '@date-io/${ctx.dateAdapter}'`;
1162
- return `${imports}
1045
+ return `${buildImports()}
1163
1046
  export const enabled = true
1164
1047
  export const isDev = ${ctx.isDev}
1165
1048
  export const i18n = ${ctx.i18n}
@@ -1178,8 +1061,21 @@ export function dateConfiguration() {
1178
1061
  return "";
1179
1062
  if (ctx.dateAdapter === "vuetify")
1180
1063
  return "options.adapter = VuetifyDateAdapter";
1064
+ const locale = ctx.vuetifyOptions.locale?.locale ?? "en";
1065
+ if (ctx.dateAdapter === "date-fns")
1066
+ return `options.adapter = new Adapter({ locale: ${locale} })`;
1181
1067
  return "options.adapter = Adapter";
1182
1068
  }
1069
+ function buildImports() {
1070
+ if (ctx.dateAdapter === "custom" || ctx.dateAdapter === "vuetify" && ctx.vuetify3_4 === true)
1071
+ return "";
1072
+ if (ctx.dateAdapter === "vuetify")
1073
+ return "import { VuetifyDateAdapter } from 'vuetify/labs/date/adapters/vuetify'";
1074
+ const imports = [`import Adapter from '@date-io/${ctx.dateAdapter}'`];
1075
+ if (ctx.dateAdapter === "date-fns")
1076
+ imports.push(`import { ${ctx.vuetifyOptions.locale?.locale ?? "en"} } from 'date-fns/locale'`);
1077
+ return imports.join("\n");
1078
+ }
1183
1079
  }
1184
1080
 
1185
1081
  function vuetifySSRClientHintsPlugin(ctx) {
@@ -1220,7 +1116,7 @@ function parseId(id) {
1220
1116
  path: pathname ?? id
1221
1117
  };
1222
1118
  }
1223
- function vuetifyImportPlugin() {
1119
+ function vuetifyImportPlugin(options) {
1224
1120
  return {
1225
1121
  name: "vuetify:import:nuxt",
1226
1122
  configResolved(config) {
@@ -1230,7 +1126,7 @@ function vuetifyImportPlugin() {
1230
1126
  async transform(code, id) {
1231
1127
  const { query, path } = parseId(id);
1232
1128
  if ((!query || !("vue" in query)) && extname(path) === ".vue" && !/^import { render as _sfc_render } from ".*"$/m.test(code) || query && "vue" in query && (query.type === "template" || query.type === "script" && query.setup === "true")) {
1233
- const { code: imports, source } = generateImports(code);
1129
+ const { code: imports, source } = generateImports(code, options);
1234
1130
  return {
1235
1131
  code: source + imports,
1236
1132
  map: null
@@ -1254,7 +1150,7 @@ function configureVite(configKey, nuxt, ctx) {
1254
1150
  configKey
1255
1151
  ];
1256
1152
  }
1257
- viteInlineConfig.plugins.push(vuetifyImportPlugin());
1153
+ viteInlineConfig.plugins.push(vuetifyImportPlugin({}));
1258
1154
  viteInlineConfig.plugins.push(vuetifyStylesPlugin({ styles: ctx.moduleOptions.styles }, ctx.logger));
1259
1155
  viteInlineConfig.plugins.push(vuetifyConfigurationPlugin(ctx));
1260
1156
  viteInlineConfig.plugins.push(vuetifyIconsPlugin(ctx));
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "vuetify-nuxt-module",
3
3
  "type": "module",
4
- "version": "0.7.2",
5
- "packageManager": "pnpm@8.11.0",
4
+ "version": "0.8.0",
5
+ "packageManager": "pnpm@8.13.1",
6
6
  "description": "Zero-Config Nuxt Module for Vuetify",
7
7
  "author": "userquin <userquin@gmail.com>",
8
8
  "license": "MIT",
@@ -52,6 +52,8 @@
52
52
  "dev:build:multiple-json": "MULTIPLE_LANG_FILES=true nuxi build playground",
53
53
  "dev:generate:multiple-json": "MULTIPLE_LANG_FILES=true nuxi generate playground",
54
54
  "dev:preview": "nuxi preview playground",
55
+ "dev:prepare:date-io": "nuxt-module-build build --stub && nuxt-module-build prepare && pnpm nuxt prepare date-io-playground",
56
+ "dev:date-io": "nuxi dev date-io-playground",
55
57
  "docs:dev": "pnpm -C docs run dev",
56
58
  "docs:build": "nuxt-module-build prepare && pnpm -C docs run build",
57
59
  "docs:serve": "pnpm -C docs run serve",
@@ -63,16 +65,16 @@
63
65
  "release": "bumpp && npm publish"
64
66
  },
65
67
  "dependencies": {
66
- "@nuxt/kit": "^3.8.2",
68
+ "@nuxt/kit": "^3.9.0",
67
69
  "defu": "^6.1.3",
68
70
  "destr": "^2.0.2",
69
71
  "local-pkg": "^0.5.0",
70
72
  "pathe": "^1.1.1",
71
73
  "perfect-debounce": "^1.0.0",
72
- "ufo": "^1.3.1",
74
+ "ufo": "^1.3.2",
73
75
  "unconfig": "^0.3.11",
74
- "vite-plugin-vuetify": "^1.0.2",
75
- "vuetify": "^3.4.3"
76
+ "vite-plugin-vuetify": "^2.0.1",
77
+ "vuetify": "^3.4.8"
76
78
  },
77
79
  "devDependencies": {
78
80
  "@antfu/eslint-config": "^0.43.1",
@@ -84,14 +86,14 @@
84
86
  "@iconify-json/carbon": "^1.1.21",
85
87
  "@iconify-json/mdi": "^1.1.55",
86
88
  "@mdi/js": "^7.3.67",
87
- "@nuxt/devtools": "^0.8.5",
89
+ "@nuxt/devtools": "^1.0.6",
88
90
  "@nuxt/module-builder": "^0.5.4",
89
- "@nuxt/schema": "^3.8.2",
90
- "@nuxt/test-utils": "^3.8.1",
91
- "@nuxtjs/i18n": "npm:@nuxtjs/i18n-edge",
91
+ "@nuxt/schema": "^3.9.0",
92
+ "@nuxt/test-utils": "^3.9.0",
93
+ "@nuxtjs/i18n": "^8.0.0",
92
94
  "@parcel/watcher": "^2.3.0",
93
95
  "@types/node": "^18",
94
- "@unocss/nuxt": "^0.57.7",
96
+ "@unocss/nuxt": "^0.58.0",
95
97
  "bumpp": "^9.2.0",
96
98
  "eslint": "^8.54.0",
97
99
  "luxon": "^3.4.3",
@@ -99,10 +101,10 @@
99
101
  "publint": "^0.2.5",
100
102
  "rimraf": "^5.0.5",
101
103
  "sass": "^1.63.6",
102
- "typescript": "^5.3.2",
103
- "vite": "^4.5.0",
104
- "vitest": "^0.34.6",
105
- "vue-tsc": "^1.8.22"
104
+ "typescript": "^5.3.3",
105
+ "vite": "^5.0.10",
106
+ "vitest": "^1.1.0",
107
+ "vue-tsc": "^1.8.27"
106
108
  },
107
109
  "build": {
108
110
  "externals": [