vuetify-nuxt-module 1.0.0-beta.3 → 1.0.0-beta.4

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.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.15.0"
6
6
  },
7
- "version": "1.0.0-beta.3",
7
+ "version": "1.0.0-beta.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { pathToFileURL, fileURLToPath } from 'node:url';
2
- import { addPluginTemplate, resolvePath, addTemplate, extendWebpackConfig, isNuxtMajorVersion, addImports, addPlugin, addVitePlugin, useLogger, defineNuxtModule, getNuxtVersion, createResolver, hasNuxtModule } from '@nuxt/kit';
1
+ import { addPluginTemplate, resolvePath, addTemplate, extendWebpackConfig, isNuxtMajorVersion, addImports, addPlugin, addVitePlugin, useLogger, defineNuxtModule, getNuxtVersion, hasNuxtModule, createResolver } from '@nuxt/kit';
2
+ import { isPackageExists, getPackageInfo } from 'local-pkg';
3
3
  import semver from 'semver';
4
4
  import { createFilter, version as version$1 } from 'vite';
5
5
  import defu from 'defu';
@@ -7,6 +7,7 @@ import { transformAssetUrls } from 'vite-plugin-vuetify';
7
7
  import { createHash } from 'node:crypto';
8
8
  import fs, { existsSync, readdirSync, rmSync, statSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
9
9
  import { isAbsolute, resolve, join, relative, dirname } from 'pathe';
10
+ import { pathToFileURL } from 'node:url';
10
11
  import { generateImports, isObject, resolveVuetifyBase, normalizePath } from '@vuetify/loader-shared';
11
12
  import destr from 'destr';
12
13
  import { parseQuery, parseURL } from 'ufo';
@@ -16,7 +17,7 @@ import { debounce } from 'perfect-debounce';
16
17
  import process from 'node:process';
17
18
  import { createConfigLoader } from 'unconfig';
18
19
 
19
- const version = "1.0.0-beta.3";
20
+ const version = "1.0.0-beta.4";
20
21
 
21
22
  const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
22
23
  const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `\0${VIRTUAL_VUETIFY_CONFIGURATION}`;
@@ -1066,25 +1067,7 @@ function isSubdir(root, test) {
1066
1067
  return relative$1 && !relative$1.startsWith("..") && !isAbsolute(relative$1);
1067
1068
  }
1068
1069
 
1069
- async function loadPackageJSON(name, parentURL = import.meta.url) {
1070
- try {
1071
- const packageJsonUrl = import.meta.resolve(`${name}/package.json`, parentURL);
1072
- const packageJsonPath = fileURLToPath(packageJsonUrl);
1073
- return JSON.parse(await readFile(packageJsonPath, "utf8"));
1074
- } catch {
1075
- return null;
1076
- }
1077
- }
1078
- function isPackageExists(name, parentURL = import.meta.url) {
1079
- try {
1080
- import.meta.resolve(name, parentURL);
1081
- return true;
1082
- } catch {
1083
- return false;
1084
- }
1085
- }
1086
-
1087
- function detectDate(packageResolveFrom) {
1070
+ function detectDate() {
1088
1071
  const result = [];
1089
1072
  for (const adapter of [
1090
1073
  "date-fns",
@@ -1096,7 +1079,7 @@ function detectDate(packageResolveFrom) {
1096
1079
  "jalaali",
1097
1080
  "hijri"
1098
1081
  ]) {
1099
- if (isPackageExists(`@date-io/${adapter}`, packageResolveFrom)) {
1082
+ if (isPackageExists(`@date-io/${adapter}`)) {
1100
1083
  result.push(adapter);
1101
1084
  }
1102
1085
  }
@@ -1149,7 +1132,7 @@ function configureVite(configKey, nuxt, ctx) {
1149
1132
  if (!ctx.moduleOptions.disableModernSassCompiler) {
1150
1133
  const enableModernSassCompiler = semver.gte(ctx.viteVersion, "5.4.0") && semver.lt(ctx.viteVersion, "7.0.0-0");
1151
1134
  if (enableModernSassCompiler) {
1152
- const sassEmbedded = isPackageExists("sass-embedded", ctx.packageResolveFrom);
1135
+ const sassEmbedded = isPackageExists("sass-embedded");
1153
1136
  if (sassEmbedded) {
1154
1137
  viteInlineConfig.css ??= {};
1155
1138
  viteInlineConfig.css.preprocessorOptions ??= {};
@@ -1233,7 +1216,7 @@ const disabledResolvedIcons = Object.freeze({
1233
1216
  local: [],
1234
1217
  svg: {}
1235
1218
  });
1236
- function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom) {
1219
+ function prepareIcons(unocssPresent, logger, vuetifyOptions) {
1237
1220
  if (vuetifyOptions.icons === false) {
1238
1221
  return disabledResolvedIcons;
1239
1222
  }
@@ -1277,7 +1260,7 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom)
1277
1260
  }
1278
1261
  resolvedIcons.imports.push(`import {${name === defaultSet ? "aliases," : ""}${name}} from 'vuetify/iconsets/${name}'`);
1279
1262
  resolvedIcons.sets.push(name);
1280
- if (isPackageExists(iconsPackageNames[name].name, packageResolveFrom)) {
1263
+ if (isPackageExists(iconsPackageNames[name].name)) {
1281
1264
  resolvedIcons.local.push(iconsPackageNames[name].css);
1282
1265
  } else {
1283
1266
  resolvedIcons.cdn.push([name, cdn ?? iconsCDN[name]]);
@@ -1296,21 +1279,18 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom)
1296
1279
  if (!faSvg) {
1297
1280
  faSvg = {};
1298
1281
  }
1299
- let faSvgExists = isPackageExists("@fortawesome/fontawesome-svg-core", packageResolveFrom);
1282
+ let faSvgExists = isPackageExists("@fortawesome/fontawesome-svg-core");
1300
1283
  if (!faSvgExists) {
1301
1284
  logger.warn("Missing @fortawesome/fontawesome-svg-core dependency, install it!");
1302
1285
  }
1303
- faSvgExists = isPackageExists("@fortawesome/vue-fontawesome", packageResolveFrom);
1286
+ faSvgExists = isPackageExists("@fortawesome/vue-fontawesome");
1304
1287
  if (faSvgExists) {
1305
1288
  if (!faSvg.libraries?.length) {
1306
1289
  faSvg.libraries = [[false, "fas", "@fortawesome/free-solid-svg-icons"]];
1307
1290
  }
1308
- for (const libraryEntry of faSvg.libraries) {
1309
- if (!libraryEntry) {
1310
- continue;
1311
- }
1312
- const library = libraryEntry[2];
1313
- if (!isPackageExists(library, packageResolveFrom)) {
1291
+ for (const p in faSvg.libraries) {
1292
+ const [_defaultExport, _name, library] = faSvg.libraries[p];
1293
+ if (!isPackageExists(library)) {
1314
1294
  faSvgExists = false;
1315
1295
  logger.warn(`Missing library ${library} dependency, install it!`);
1316
1296
  }
@@ -1322,11 +1302,7 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom)
1322
1302
  resolvedIcons.aliasesImportPresent ||= defaultSet === "fa-svg";
1323
1303
  resolvedIcons.imports.push(`import {${defaultSet === "fa-svg" ? "aliases," : ""}fa} from 'vuetify/iconsets/fa-svg'`, "import { library } from '@fortawesome/fontawesome-svg-core'", "import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'", "import { useNuxtApp } from '#imports'");
1324
1304
  resolvedIcons.svg.fa = ["useNuxtApp().vueApp.component('font-awesome-icon', FontAwesomeIcon)"];
1325
- for (const libraryEntry of faSvg.libraries ?? []) {
1326
- if (!libraryEntry) {
1327
- continue;
1328
- }
1329
- const [defaultExport, name, library] = libraryEntry;
1305
+ for (const [defaultExport, name, library] of faSvg.libraries) {
1330
1306
  resolvedIcons.imports.push(`import ${defaultExport ? name : `{${name}}`} from '${library}'`);
1331
1307
  resolvedIcons.svg.fa.push(`library.add(${name})`);
1332
1308
  }
@@ -1341,7 +1317,7 @@ function prepareIcons(unocssPresent, logger, vuetifyOptions, packageResolveFrom)
1341
1317
  if (!mdiSvg) {
1342
1318
  mdiSvg = {};
1343
1319
  }
1344
- const mdiSvgExists = isPackageExists("@mdi/js", packageResolveFrom);
1320
+ const mdiSvgExists = isPackageExists("@mdi/js");
1345
1321
  if (mdiSvgExists) {
1346
1322
  resolvedIcons.svg.mdi = true;
1347
1323
  resolvedIcons.aliasesImportPresent ||= defaultSet === "mdi-svg";
@@ -1701,7 +1677,7 @@ async function load(options, nuxt, ctx) {
1701
1677
  const dateOptions = vuetifyOptions.date;
1702
1678
  if (dateOptions) {
1703
1679
  const adapter = dateOptions.adapter;
1704
- const date = detectDate(ctx.packageResolveFrom);
1680
+ const date = detectDate();
1705
1681
  if (!adapter && date.length > 1) {
1706
1682
  throw new Error(`Multiple date adapters found: ${date.map((d) => `@date-io/${d[0]}`).join(", ")}, please specify the adapter to use in the "vuetifyOptions.date.adapter" option.`);
1707
1683
  }
@@ -1730,7 +1706,7 @@ async function load(options, nuxt, ctx) {
1730
1706
  ctx.enableRules = ctx.moduleOptions.enableRules;
1731
1707
  ctx.rulesConfiguration = ctx.moduleOptions.rulesConfiguration;
1732
1708
  ctx.vuetifyFilesToWatch = Array.from(vuetifyConfigurationFilesToWatch);
1733
- ctx.icons = prepareIcons(ctx.unocss, ctx.logger, vuetifyAppOptions, ctx.packageResolveFrom);
1709
+ ctx.icons = prepareIcons(ctx.unocss, ctx.logger, vuetifyAppOptions);
1734
1710
  ctx.ssrClientHints = prepareSSRClientHints(nuxt.options.app.baseURL ?? "/", ctx);
1735
1711
  if (ctx.icons.enabled) {
1736
1712
  if (ctx.icons.local) {
@@ -1831,16 +1807,13 @@ const module$1 = defineNuxtModule({
1831
1807
  if (isNuxtMajorVersion(2, nuxt)) {
1832
1808
  logger.error(`Cannot support nuxt version: ${getNuxtVersion(nuxt)}`);
1833
1809
  }
1834
- const resolver = createResolver(import.meta.url);
1835
- const packageResolveFrom = pathToFileURL(resolver.resolve(nuxt.options.rootDir, "package.json")).href;
1836
- const vuetifyPkg = await loadPackageJSON("vuetify", packageResolveFrom);
1810
+ const vuetifyPkg = await getPackageInfo("vuetify");
1837
1811
  const currentVersion = vuetifyPkg?.version;
1838
1812
  const vuetifyGte = (version2) => !!currentVersion && semver.gte(currentVersion, version2);
1839
1813
  const viteVersion = version$1;
1840
1814
  const ctx = {
1841
1815
  logger,
1842
- resolver,
1843
- packageResolveFrom,
1816
+ resolver: createResolver(import.meta.url),
1844
1817
  moduleOptions: void 0,
1845
1818
  vuetifyOptions: void 0,
1846
1819
  vuetifyFilesToWatch: [],
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vuetify-nuxt-module",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.3",
4
+ "version": "1.0.0-beta.4",
5
5
  "description": "Zero-Config Nuxt Module for Vuetify",
6
6
  "author": "userquin <userquin@gmail.com>",
7
7
  "license": "MIT",
@@ -54,6 +54,7 @@
54
54
  "@nuxt/kit": "^4.3.1",
55
55
  "defu": "^6.1.4",
56
56
  "destr": "^2.0.5",
57
+ "local-pkg": "^1.1.2",
57
58
  "pathe": "^2.0.3",
58
59
  "perfect-debounce": "^2.1.0",
59
60
  "semver": "^7.7.4",
@@ -102,6 +103,7 @@
102
103
  "consola",
103
104
  "destr",
104
105
  "esbuild",
106
+ "local-pkg",
105
107
  "pathe",
106
108
  "perfect-debounce",
107
109
  "rollup",