nitropack-nightly 2.11.0-20250224-142059.8ccbde5f → 2.11.0-20250225-133725.2ab3e582

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.
@@ -13,7 +13,7 @@ import defu$1, { defu } from 'defu';
13
13
  import { withLeadingSlash, withoutTrailingSlash, withTrailingSlash, withBase, parseURL, joinURL, withoutBase } from 'ufo';
14
14
  import { colors } from 'consola/utils';
15
15
  import escapeRE from 'escape-string-regexp';
16
- import { resolveModuleExportNames, resolvePath, parseNodeModulePath, lookupNodeModuleSubpath } from 'mlly';
16
+ import { resolveModuleExportNames, parseNodeModulePath, lookupNodeModuleSubpath } from 'mlly';
17
17
  import { resolveNitroPath, isDirectory, writeFile, prettyPath } from 'nitropack/kit';
18
18
  export { defineNitroPreset } from 'nitropack/kit';
19
19
  import { findWorkspaceDir } from 'pkg-types';
@@ -32,6 +32,7 @@ import { debounce } from 'perfect-debounce';
32
32
  import * as rollup from 'rollup';
33
33
  import { upperFirst } from 'scule';
34
34
  import { genTypeImport } from 'knitwork';
35
+ import { resolveModulePath } from 'exsolve';
35
36
  import { resolveAlias } from 'pathe/utils';
36
37
  import { generateTypes, resolveSchema } from 'untyped';
37
38
  import { version } from 'nitropack/meta';
@@ -522,7 +523,8 @@ async function resolvePathOptions(options) {
522
523
  options.nodeModulesDirs.push(resolve(pkgDir, ".."));
523
524
  options.nodeModulesDirs = [
524
525
  ...new Set(
525
- options.nodeModulesDirs.map((dir) => resolve(options.rootDir, dir))
526
+ // Adding trailing slash to optimize resolve performance (path is explicitly a dir)
527
+ options.nodeModulesDirs.map((dir) => resolve(options.rootDir, dir) + "/")
526
528
  )
527
529
  ];
528
530
  options.plugins = options.plugins.map((p) => resolveNitroPath(p, options));
@@ -1189,9 +1191,12 @@ async function writeTypes(nitro) {
1189
1191
  }
1190
1192
  let path = resolveAlias(i.from, nitro.options.alias);
1191
1193
  if (!isAbsolute(path)) {
1192
- const resolvedPath = await resolvePath(i.from, {
1193
- url: nitro.options.nodeModulesDirs
1194
- }).catch(() => null);
1194
+ const resolvedPath = resolveModulePath(i.from, {
1195
+ try: true,
1196
+ from: nitro.options.nodeModulesDirs,
1197
+ suffixes: ["/index"],
1198
+ extensions: [".mjs", ".cjs", ".js", ".mts", ".cts", ".ts"]
1199
+ });
1195
1200
  if (resolvedPath) {
1196
1201
  const { dir, name } = parseNodeModulePath(resolvedPath);
1197
1202
  if (!dir || !name) {
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250224-142059.8ccbde5f";
1
+ const version = "2.11.0-20250225-133725.2ab3e582";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250224-142059.8ccbde5f";
1
+ const version = "2.11.0-20250225-133725.2ab3e582";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250224-142059.8ccbde5f";
1
+ const version = "2.11.0-20250225-133725.2ab3e582";
2
2
 
3
3
  export { version };
@@ -1,6 +1,6 @@
1
1
  import { defineNitroPreset } from "nitropack/kit";
2
2
  import { normalize } from "pathe";
3
- import { resolvePathSync } from "mlly";
3
+ import { resolveModulePath } from "exsolve";
4
4
  const node = defineNitroPreset(
5
5
  {
6
6
  entry: "./runtime/node-listener"
@@ -33,8 +33,9 @@ const nodeCluster = defineNitroPreset(
33
33
  "rollup:before"(_nitro, rollupConfig) {
34
34
  const manualChunks = rollupConfig.output?.manualChunks;
35
35
  if (manualChunks && typeof manualChunks === "function") {
36
- const serverEntry = resolvePathSync("./runtime/node-server", {
37
- url: import.meta.url
36
+ const serverEntry = resolveModulePath("./runtime/node-server", {
37
+ from: import.meta.url,
38
+ extensions: [".mjs", ".ts"]
38
39
  });
39
40
  rollupConfig.output.manualChunks = (id, meta) => {
40
41
  if (id.includes("node-server") && normalize(id) === serverEntry) {
@@ -1,5 +1,5 @@
1
1
  import { builtinModules, createRequire } from 'node:module';
2
- import { pathToFileURL } from 'node:url';
2
+ import { pathToFileURL, fileURLToPath } from 'node:url';
3
3
  import alias from '@rollup/plugin-alias';
4
4
  import commonjs from '@rollup/plugin-commonjs';
5
5
  import inject from '@rollup/plugin-inject';
@@ -7,6 +7,7 @@ import json from '@rollup/plugin-json';
7
7
  import { nodeResolve } from '@rollup/plugin-node-resolve';
8
8
  import { defu } from 'defu';
9
9
  import { parseNodeModulePath as parseNodeModulePath$1, isValidNodeImport, normalizeid, lookupNodeModuleSubpath, resolvePath, sanitizeFilePath } from 'mlly';
10
+ import { resolveModuleURL, resolveModulePath } from 'exsolve';
10
11
  import { runtimeDir, runtimeDependencies } from 'nitropack/runtime/meta';
11
12
  import { hash } from 'ohash';
12
13
  import { resolve, dirname, extname, relative, join, normalize, isAbsolute } from 'pathe';
@@ -359,21 +360,18 @@ function printWarnings(id, result, plugin) {
359
360
 
360
361
  function externals$1(opts) {
361
362
  const trackedExternals = /* @__PURE__ */ new Set();
362
- const _resolveCache = /* @__PURE__ */ new Map();
363
- const _resolve = async (id) => {
363
+ const tryResolve = (id) => {
364
364
  if (id.startsWith("\0")) {
365
365
  return id;
366
366
  }
367
- let resolved = _resolveCache.get(id);
368
- if (resolved) {
369
- return resolved;
370
- }
371
- resolved = await resolvePath(id, {
367
+ const res = resolveModuleURL(id, {
368
+ try: true,
372
369
  conditions: opts.exportConditions,
373
- url: opts.moduleDirectories
370
+ from: opts.moduleDirectories,
371
+ suffixes: ["/index"],
372
+ extensions: [".mjs", ".cjs", ".js", ".mts", ".cts", ".ts", ".json"]
374
373
  });
375
- _resolveCache.set(id, resolved);
376
- return resolved;
374
+ return res?.startsWith("file://") ? fileURLToPath(res) : res;
377
375
  };
378
376
  const inlineMatchers = (opts.inline || []).map((p) => normalizeMatcher(p)).sort((a, b) => (b.score || 0) - (a.score || 0));
379
377
  const externalMatchers = (opts.external || []).map((p) => normalizeMatcher(p)).sort((a, b) => (b.score || 0) - (a.score || 0));
@@ -407,7 +405,7 @@ function externals$1(opts) {
407
405
  return null;
408
406
  }
409
407
  if (!isAbsolute(resolved.id) || !existsSync(resolved.id) || await isDirectory(resolved.id)) {
410
- resolved.id = await _resolve(resolved.id).catch(() => resolved.id);
408
+ resolved.id = tryResolve(resolved.id) || resolved.id;
411
409
  }
412
410
  if (!await isValidNodeImport(resolved.id).catch(() => false)) {
413
411
  return null;
@@ -425,17 +423,19 @@ function externals$1(opts) {
425
423
  }
426
424
  if (pkgName !== originalId) {
427
425
  if (!isAbsolute(originalId)) {
428
- const fullPath = await _resolve(originalId);
429
- trackedExternals.add(fullPath);
430
- return {
431
- id: originalId,
432
- external: true
433
- };
426
+ const fullPath = tryResolve(originalId);
427
+ if (fullPath) {
428
+ trackedExternals.add(fullPath);
429
+ return {
430
+ id: originalId,
431
+ external: true
432
+ };
433
+ }
434
434
  }
435
- const packageEntry = await _resolve(pkgName).catch(() => null);
435
+ const packageEntry = tryResolve(pkgName);
436
436
  if (packageEntry !== id) {
437
437
  const guessedSubpath = await lookupNodeModuleSubpath(id).catch(() => null);
438
- const resolvedGuess = guessedSubpath && await _resolve(join(pkgName, guessedSubpath)).catch(() => null);
438
+ const resolvedGuess = guessedSubpath && tryResolve(join(pkgName, guessedSubpath));
439
439
  if (resolvedGuess === id) {
440
440
  trackedExternals.add(resolvedGuess);
441
441
  return {
@@ -2007,8 +2007,11 @@ export const plugins = [
2007
2007
  }
2008
2008
  const resolved = await this.resolve(id, from, resolveOpts);
2009
2009
  if (!resolved) {
2010
- const _resolved = await resolvePath(id, {
2011
- url: nitro.options.nodeModulesDirs,
2010
+ const _resolved = resolveModulePath(id, {
2011
+ try: true,
2012
+ from: nitro.options.nodeModulesDirs,
2013
+ suffixes: ["/index"],
2014
+ extensions: [".mjs", ".cjs", ".js", ".mts", ".cts", ".ts", ".json"],
2012
2015
  conditions: [
2013
2016
  "default",
2014
2017
  nitro.options.dev ? "development" : "production",
@@ -2016,7 +2019,7 @@ export const plugins = [
2016
2019
  "import",
2017
2020
  "require"
2018
2021
  ]
2019
- }).catch(() => null);
2022
+ });
2020
2023
  if (_resolved) {
2021
2024
  return { id: _resolved, external: false };
2022
2025
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitropack-nightly",
3
- "version": "2.11.0-20250224-142059.8ccbde5f",
3
+ "version": "2.11.0-20250225-133725.2ab3e582",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "repository": "nitrojs/nitro",
6
6
  "license": "MIT",
@@ -124,6 +124,7 @@
124
124
  "esbuild": "^0.25.0",
125
125
  "escape-string-regexp": "^5.0.0",
126
126
  "etag": "^1.8.1",
127
+ "exsolve": "^0.3.1",
127
128
  "fs-extra": "^11.3.0",
128
129
  "globby": "^14.1.0",
129
130
  "gzip-size": "^7.0.0",