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