You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@nuxt/kit

Package Overview
Dependencies
Maintainers
5
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nuxt/kit - npm Package Compare versions

Comparing version
4.0.0-alpha.4
to
4.0.0-rc.0
+1
-0
dist/index.d.mts

@@ -410,2 +410,3 @@ import * as _nuxt_schema from '@nuxt/schema';

node?: boolean;
shared?: boolean;
}): ResolvedNuxtTemplate<T>;

@@ -412,0 +413,0 @@ /**

@@ -410,2 +410,3 @@ import * as _nuxt_schema from '@nuxt/schema';

node?: boolean;
shared?: boolean;
}): ResolvedNuxtTemplate<T>;

@@ -412,0 +413,0 @@ /**

+172
-75

@@ -1069,2 +1069,7 @@ import { performance } from 'node:perf_hooks';

}
if (context?.shared) {
nuxt.hook("prepare:types", ({ sharedReferences }) => {
sharedReferences.push({ path: template.dst });
});
}
if (context?.nitro) {

@@ -1110,21 +1115,38 @@ nuxt.hook("nitro:prepare:types", ({ references }) => {

}
function resolveLayerPaths(buildDir, rootDir, srcDir) {
function resolveLayerPaths(dir, buildDir, rootDir, srcDir) {
const relativeRootDir = relativeWithDot(buildDir, rootDir);
const relativeSrcDir = relativeWithDot(buildDir, srcDir);
const relativeModulesDir = relativeWithDot(buildDir, resolve(rootDir, dir.modules || "modules"));
const relativeSharedDir = relativeWithDot(buildDir, resolve(rootDir, dir.shared || "shared"));
return {
nuxt: [
join(relativeWithDot(buildDir, srcDir), "**/*"),
join(relativeRootDir, "modules/*/runtime/**/*"),
join(relativeRootDir, "layers/*/modules/*/runtime/**/*")
join(relativeSrcDir, "**/*"),
join(relativeModulesDir, `*/runtime/**/*`),
join(relativeRootDir, `layers/*/modules/*/runtime/**/*`)
],
nitro: [
join(relativeRootDir, "modules/*/runtime/server/**/*"),
join(relativeRootDir, "layers/*/modules/*/runtime/server/**/*")
join(relativeModulesDir, `*/runtime/server/**/*`),
join(relativeRootDir, `layers/*/modules/*/runtime/server/**/*`)
],
node: [
join(relativeRootDir, "modules/**/*"),
join(relativeRootDir, "nuxt.config.*"),
join(relativeRootDir, ".config/nuxt.*"),
join(relativeRootDir, "layers/*/nuxt.config.*"),
join(relativeRootDir, "layers/*/.config/nuxt.*"),
join(relativeRootDir, "layers/*/modules/**/*")
join(relativeModulesDir, `*.*`),
join(relativeRootDir, `nuxt.config.*`),
join(relativeRootDir, `.config/nuxt.*`),
join(relativeRootDir, `layers/*/nuxt.config.*`),
join(relativeRootDir, `layers/*/.config/nuxt.*`),
join(relativeRootDir, `layers/*/modules/**/*`)
],
shared: [
join(relativeSharedDir, `**/*`),
join(relativeModulesDir, `*/shared/**/*`),
join(relativeRootDir, `layers/*/shared/**/*`)
],
sharedDeclarations: [
join(relativeSharedDir, `**/*.d.ts`),
join(relativeModulesDir, `*/shared/**/*.d.ts`),
join(relativeRootDir, `layers/*/shared/**/*.d.ts`)
],
globalDeclarations: [
join(relativeRootDir, `*.d.ts`),
join(relativeRootDir, `layers/*/*.d.ts`)
]

@@ -1138,5 +1160,7 @@ };

const nodeInclude = /* @__PURE__ */ new Set(["./nuxt.node.d.ts"]);
const legacyInclude = /* @__PURE__ */ new Set(["./nuxt.d.ts"]);
const sharedInclude = /* @__PURE__ */ new Set(["./nuxt.shared.d.ts"]);
const legacyInclude = /* @__PURE__ */ new Set([...include, ...nodeInclude]);
const exclude = /* @__PURE__ */ new Set();
const nodeExclude = /* @__PURE__ */ new Set();
const sharedExclude = /* @__PURE__ */ new Set();
const legacyExclude = /* @__PURE__ */ new Set();

@@ -1162,3 +1186,3 @@ if (nuxt.options.typescript.includeWorkspace && nuxt.options.workspaceDir !== nuxt.options.srcDir) {

const rootGlob = join(relativeWithDot(nuxt.options.buildDir, layer.cwd), "**/*");
const paths = resolveLayerPaths(nuxt.options.buildDir, layer.cwd, layer.config.srcDir);
const paths = resolveLayerPaths(defu(layer.config.dir, nuxt.options.dir), nuxt.options.buildDir, layer.cwd, layer.config.srcDir);
for (const path of paths.nuxt) {

@@ -1181,2 +1205,14 @@ include.add(path);

}
for (const path of paths.shared) {
legacyInclude.add(path);
sharedInclude.add(path);
}
for (const path of paths.sharedDeclarations) {
include.add(path);
}
for (const path of paths.globalDeclarations) {
include.add(path);
legacyInclude.add(path);
sharedInclude.add(path);
}
}

@@ -1193,4 +1229,7 @@ }

const relative2 = relativeWithDot(nuxt.options.buildDir, path);
include.add(join(relative2, "runtime"));
include.add(join(relative2, "dist/runtime"));
if (!path.includes("node_modules")) {
include.add(join(relative2, "runtime"));
include.add(join(relative2, "dist/runtime"));
nodeInclude.add(join(relative2, "*.*"));
}
legacyInclude.add(join(relative2, "runtime"));

@@ -1202,2 +1241,3 @@ legacyInclude.add(join(relative2, "dist/runtime"));

exclude.add(join(relative2, "dist/runtime/server"));
exclude.add(join(relative2, "*.*"));
legacyExclude.add(join(relative2, "runtime/server"));

@@ -1219,37 +1259,2 @@ legacyExclude.add(join(relative2, "dist/runtime/server"));

const useDecorators = Boolean(nuxt.options.experimental?.decorators);
const nodeReferences = [];
const nodeTsConfig = defu(nuxt.options.typescript?.nodeTsConfig, {
compilerOptions: {
/* Base options: */
esModuleInterop: true,
skipLibCheck: true,
target: "ESNext",
allowJs: true,
resolveJsonModule: true,
moduleDetection: "force",
isolatedModules: true,
verbatimModuleSyntax: true,
/* Strictness */
strict: nuxt.options.typescript?.strict ?? true,
noUncheckedIndexedAccess: true,
forceConsistentCasingInFileNames: true,
noImplicitOverride: true,
/* If NOT transpiling with TypeScript: */
module: hasTypescriptVersionWithModulePreserve ? "preserve" : "ESNext",
noEmit: true,
/* remove auto-scanning for types */
types: [],
/* add paths object for filling-in later */
paths: {},
/* Possibly consider removing the following in future */
moduleResolution: hasTypescriptVersionWithModulePreserve ? void 0 : "Bundler",
useDefineForClassFields: true,
/* implied by target: es2022+ */
noImplicitThis: true,
/* enabled with `strict` */
allowSyntheticDefaultImports: true
},
include: [...nodeInclude],
exclude: [...nodeExclude]
});
const tsConfig = defu(nuxt.options.typescript?.tsConfig, {

@@ -1305,2 +1310,66 @@ compilerOptions: {

});
const nodeTsConfig = defu(nuxt.options.typescript?.nodeTsConfig, {
compilerOptions: {
/* Base options: */
esModuleInterop: tsConfig.compilerOptions?.esModuleInterop,
skipLibCheck: tsConfig.compilerOptions?.skipLibCheck,
target: tsConfig.compilerOptions?.target,
allowJs: tsConfig.compilerOptions?.allowJs,
resolveJsonModule: tsConfig.compilerOptions?.resolveJsonModule,
moduleDetection: tsConfig.compilerOptions?.moduleDetection,
isolatedModules: tsConfig.compilerOptions?.isolatedModules,
verbatimModuleSyntax: tsConfig.compilerOptions?.verbatimModuleSyntax,
/* Strictness */
strict: tsConfig.compilerOptions?.strict,
noUncheckedIndexedAccess: tsConfig.compilerOptions?.noUncheckedIndexedAccess,
forceConsistentCasingInFileNames: tsConfig.compilerOptions?.forceConsistentCasingInFileNames,
noImplicitOverride: tsConfig.compilerOptions?.noImplicitOverride,
/* If NOT transpiling with TypeScript: */
module: tsConfig.compilerOptions?.module,
noEmit: true,
/* remove auto-scanning for types */
types: [],
/* add paths object for filling-in later */
paths: {},
/* Possibly consider removing the following in future */
moduleResolution: tsConfig.compilerOptions?.moduleResolution,
useDefineForClassFields: tsConfig.compilerOptions?.useDefineForClassFields,
noImplicitThis: tsConfig.compilerOptions?.noImplicitThis,
allowSyntheticDefaultImports: tsConfig.compilerOptions?.allowSyntheticDefaultImports
},
include: [...nodeInclude],
exclude: [...nodeExclude]
});
const sharedTsConfig = defu(nuxt.options.typescript?.sharedTsConfig, {
compilerOptions: {
/* Base options: */
esModuleInterop: tsConfig.compilerOptions?.esModuleInterop,
skipLibCheck: tsConfig.compilerOptions?.skipLibCheck,
target: tsConfig.compilerOptions?.target,
allowJs: tsConfig.compilerOptions?.allowJs,
resolveJsonModule: tsConfig.compilerOptions?.resolveJsonModule,
moduleDetection: tsConfig.compilerOptions?.moduleDetection,
isolatedModules: tsConfig.compilerOptions?.isolatedModules,
verbatimModuleSyntax: tsConfig.compilerOptions?.verbatimModuleSyntax,
/* Strictness */
strict: tsConfig.compilerOptions?.strict,
noUncheckedIndexedAccess: tsConfig.compilerOptions?.noUncheckedIndexedAccess,
forceConsistentCasingInFileNames: tsConfig.compilerOptions?.forceConsistentCasingInFileNames,
noImplicitOverride: tsConfig.compilerOptions?.noImplicitOverride,
/* If NOT transpiling with TypeScript: */
module: tsConfig.compilerOptions?.module,
noEmit: true,
/* remove auto-scanning for types */
types: [],
/* add paths object for filling-in later */
paths: {},
/* Possibly consider removing the following in future */
moduleResolution: tsConfig.compilerOptions?.moduleResolution,
useDefineForClassFields: tsConfig.compilerOptions?.useDefineForClassFields,
noImplicitThis: tsConfig.compilerOptions?.noImplicitThis,
allowSyntheticDefaultImports: tsConfig.compilerOptions?.allowSyntheticDefaultImports
},
include: [...sharedInclude],
exclude: [...sharedExclude]
});
const aliases = nuxt.options.alias;

@@ -1342,2 +1411,4 @@ const basePath = tsConfig.compilerOptions.baseUrl ? resolve(nuxt.options.buildDir, tsConfig.compilerOptions.baseUrl) : nuxt.options.buildDir;

const references = [];
const nodeReferences = [];
const sharedReferences = [];
await Promise.all([...nuxt.options.modules, ...nuxt.options._modules].map(async (id) => {

@@ -1350,26 +1421,39 @@ if (typeof id !== "string") {

if (pkg) {
references.push({ types: pkg.name ?? id });
nodeReferences.push({ types: pkg.name ?? id });
return;
}
}
references.push({ types: id });
nodeReferences.push({ types: id });
}));
const declarations = [];
await nuxt.callHook("prepare:types", { references, declarations, tsConfig, nodeTsConfig, nodeReferences });
for (const alias in tsConfig.compilerOptions.paths) {
const paths = tsConfig.compilerOptions.paths[alias];
tsConfig.compilerOptions.paths[alias] = await Promise.all(paths.map(async (path) => {
if (!isAbsolute(path)) {
return path;
}
const stats = await promises.stat(path).catch(
() => null
/* file does not exist */
);
return relativeWithDot(nuxt.options.buildDir, stats?.isFile() ? path.replace(EXTENSION_RE, "") : path);
}));
await nuxt.callHook("prepare:types", { references, declarations, tsConfig, nodeTsConfig, nodeReferences, sharedTsConfig, sharedReferences });
const legacyTsConfig = defu({}, {
...tsConfig,
include: [...tsConfig.include, ...legacyInclude],
exclude: [...legacyExclude]
});
async function resolveConfig(tsConfig2) {
for (const alias in tsConfig2.compilerOptions.paths) {
const paths = tsConfig2.compilerOptions.paths[alias];
tsConfig2.compilerOptions.paths[alias] = [...new Set(await Promise.all(paths.map(async (path) => {
if (!isAbsolute(path)) {
return path;
}
const stats = await promises.stat(path).catch(
() => null
/* file does not exist */
);
return relativeWithDot(nuxt.options.buildDir, stats?.isFile() ? path.replace(EXTENSION_RE, "") : path);
})))];
}
sortTsPaths(tsConfig2.compilerOptions.paths);
tsConfig2.include = [...new Set(tsConfig2.include.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
tsConfig2.exclude = [...new Set(tsConfig2.exclude.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
}
sortTsPaths(tsConfig.compilerOptions.paths);
tsConfig.include = [...new Set(tsConfig.include.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
tsConfig.exclude = [...new Set(tsConfig.exclude.map((p) => isAbsolute(p) ? relativeWithDot(nuxt.options.buildDir, p) : p))];
await Promise.all([
resolveConfig(tsConfig),
resolveConfig(nodeTsConfig),
resolveConfig(sharedTsConfig),
resolveConfig(legacyTsConfig)
]);
const declaration = [

@@ -1398,8 +1482,17 @@ ...references.map((ref) => {

].join("\n");
const legacyTsConfig = defu({}, tsConfig, {
include: [...legacyInclude],
exclude: [...legacyExclude]
});
const sharedDeclaration = [
...sharedReferences.map((ref) => {
if ("path" in ref && isAbsolute(ref.path)) {
ref.path = relative(nuxt.options.buildDir, ref.path);
}
return `/// <reference ${renderAttrs(ref)} />`;
}),
"",
"export {}",
""
].join("\n");
return {
declaration,
sharedTsConfig,
sharedDeclaration,
nodeTsConfig,

@@ -1412,8 +1505,10 @@ nodeDeclaration,

async function writeTypes(nuxt) {
const { tsConfig, nodeTsConfig, nodeDeclaration, declaration, legacyTsConfig } = await _generateTypes(nuxt);
const { tsConfig, nodeTsConfig, nodeDeclaration, declaration, legacyTsConfig, sharedDeclaration, sharedTsConfig } = await _generateTypes(nuxt);
const appTsConfigPath = resolve(nuxt.options.buildDir, "tsconfig.app.json");
const legacyTsConfigPath = resolve(nuxt.options.buildDir, "tsconfig.json");
const nodeTsConfigPath = resolve(nuxt.options.buildDir, "tsconfig.node.json");
const sharedTsConfigPath = resolve(nuxt.options.buildDir, "tsconfig.shared.json");
const declarationPath = resolve(nuxt.options.buildDir, "nuxt.d.ts");
const nodeDeclarationPath = resolve(nuxt.options.buildDir, "nuxt.node.d.ts");
const sharedDeclarationPath = resolve(nuxt.options.buildDir, "nuxt.shared.d.ts");
await promises.mkdir(nuxt.options.buildDir, { recursive: true });

@@ -1424,4 +1519,6 @@ await Promise.all([

promises.writeFile(nodeTsConfigPath, JSON.stringify(nodeTsConfig, null, 2)),
promises.writeFile(sharedTsConfigPath, JSON.stringify(sharedTsConfig, null, 2)),
promises.writeFile(declarationPath, declaration),
promises.writeFile(nodeDeclarationPath, nodeDeclaration)
promises.writeFile(nodeDeclarationPath, nodeDeclaration),
promises.writeFile(sharedDeclarationPath, sharedDeclaration)
]);

@@ -1428,0 +1525,0 @@ }

{
"name": "@nuxt/kit",
"version": "4.0.0-alpha.4",
"version": "4.0.0-rc.0",
"repository": {

@@ -38,3 +38,3 @@ "type": "git",

"pathe": "^2.0.3",
"pkg-types": "^2.1.0",
"pkg-types": "^2.2.0",
"scule": "^1.3.0",

@@ -46,7 +46,7 @@ "semver": "^7.7.2",

"unctx": "^2.4.1",
"unimport": "^5.0.1",
"unimport": "^5.1.0",
"untyped": "^2.0.0"
},
"devDependencies": {
"@rspack/core": "1.3.15",
"@rspack/core": "1.4.4",
"@types/semver": "7.7.0",

@@ -56,6 +56,6 @@ "hookable": "5.5.3",

"unbuild": "3.5.0",
"vite": "7.0.0",
"vite": "7.0.2",
"vitest": "3.2.4",
"webpack": "5.99.9",
"@nuxt/schema": "4.0.0-alpha.4"
"@nuxt/schema": "4.0.0-rc.0"
},

@@ -62,0 +62,0 @@ "engines": {