@nuxt/kit-nightly 4.2.0-29331654.df559ad9 → 4.2.0-29331790.6ef632b8

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.
Files changed (2) hide show
  1. package/dist/index.mjs +61 -42
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -7,10 +7,10 @@ import { getContext, createContext } from 'unctx';
7
7
  import satisfies from 'semver/functions/satisfies.js';
8
8
  import { readPackageJSON, resolvePackageJSON } from 'pkg-types';
9
9
  import { existsSync, readFileSync, promises, lstatSync } from 'node:fs';
10
- import { pathToFileURL, fileURLToPath } from 'node:url';
10
+ import { fileURLToPath, pathToFileURL } from 'node:url';
11
11
  import { resolve, relative, join, dirname, normalize, isAbsolute, basename, parse } from 'pathe';
12
12
  import { createJiti } from 'jiti';
13
- import { interopDefault, parseNodeModulePath, resolveModuleExportNames } from 'mlly';
13
+ import { parseNodeModulePath, interopDefault, resolveModuleExportNames } from 'mlly';
14
14
  import { resolveModulePath, resolveModuleURL } from 'exsolve';
15
15
  import { isRelative, withTrailingSlash as withTrailingSlash$2 } from 'ufo';
16
16
  import { read, update } from 'rc9';
@@ -221,53 +221,27 @@ ${issues.toString()}`;
221
221
  return normalizedModule;
222
222
  }
223
223
 
224
- function directoryToURL(dir) {
225
- return pathToFileURL(dir + "/");
226
- }
227
- function tryResolveModule(id, url = import.meta.url) {
228
- return Promise.resolve(resolveModulePath(id, {
229
- from: url,
230
- suffixes: ["", "index"],
231
- try: true
232
- }));
233
- }
234
- function resolveModule(id, options) {
235
- return resolveModulePath(id, {
236
- // eslint-disable-next-line @typescript-eslint/no-deprecated
237
- from: options?.url ?? options?.paths ?? [import.meta.url],
238
- extensions: options?.extensions ?? [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]
239
- });
240
- }
241
- async function importModule(id, opts) {
242
- const resolvedPath = resolveModule(id, opts);
243
- return await import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
244
- }
245
- function tryImportModule(id, opts) {
246
- try {
247
- return importModule(id, opts).catch(() => void 0);
248
- } catch {
224
+ const distURL = import.meta.url.replace(/\/dist\/.*$/, "/");
225
+ function getUserCaller() {
226
+ if (!import.meta.dev) {
227
+ return null;
228
+ }
229
+ const { source, line, column } = captureStackTrace().find((entry) => !entry.source.startsWith(distURL)) ?? {};
230
+ if (!source) {
231
+ return null;
249
232
  }
233
+ return {
234
+ source: source.replace(/^file:\/\//, ""),
235
+ line,
236
+ column
237
+ };
250
238
  }
251
239
  const warnings = /* @__PURE__ */ new Set();
252
- function requireModule(id, opts) {
253
- const { source, line, column } = captureStackTrace().find((entry) => entry.source !== import.meta.url) ?? {};
254
- const explanation = source ? ` (used at \`${fileURLToPath(source)}:${line}:${column}\`)` : "";
255
- const warning = `[@nuxt/kit] \`requireModule\` is deprecated${explanation}. Please use \`importModule\` instead.`;
240
+ function warn(warning) {
256
241
  if (!warnings.has(warning)) {
257
242
  console.warn(warning);
258
243
  warnings.add(warning);
259
244
  }
260
- const resolvedPath = resolveModule(id, opts);
261
- const jiti = createJiti(import.meta.url, {
262
- interopDefault: opts?.interopDefault !== false
263
- });
264
- return jiti(pathToFileURL(resolvedPath).href);
265
- }
266
- function tryRequireModule(id, opts) {
267
- try {
268
- return requireModule(id, opts);
269
- } catch {
270
- }
271
245
  }
272
246
 
273
247
  const layerMap = /* @__PURE__ */ new WeakMap();
@@ -541,6 +515,51 @@ async function resolveFiles(path, pattern, opts = {}) {
541
515
  return files.sort();
542
516
  }
543
517
 
518
+ function directoryToURL(dir) {
519
+ return pathToFileURL(dir + "/");
520
+ }
521
+ function tryResolveModule(id, url = import.meta.url) {
522
+ return Promise.resolve(resolveModulePath(id, {
523
+ from: url,
524
+ suffixes: ["", "index"],
525
+ try: true
526
+ }));
527
+ }
528
+ function resolveModule(id, options) {
529
+ return resolveModulePath(id, {
530
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
531
+ from: options?.url ?? options?.paths ?? [import.meta.url],
532
+ extensions: options?.extensions ?? [".js", ".mjs", ".cjs", ".ts", ".mts", ".cts"]
533
+ });
534
+ }
535
+ async function importModule(id, opts) {
536
+ const resolvedPath = resolveModule(id, opts);
537
+ return await import(pathToFileURL(resolvedPath).href).then((r) => opts?.interopDefault !== false ? interopDefault(r) : r);
538
+ }
539
+ function tryImportModule(id, opts) {
540
+ try {
541
+ return importModule(id, opts).catch(() => void 0);
542
+ } catch {
543
+ }
544
+ }
545
+ function requireModule(id, opts) {
546
+ const caller = getUserCaller();
547
+ const explanation = caller ? ` (used at \`${resolveAlias(caller.source)}:${caller.line}:${caller.column}\`)` : "";
548
+ const warning = `[@nuxt/kit] \`requireModule\` is deprecated${explanation}. Please use \`importModule\` instead.`;
549
+ warn(warning);
550
+ const resolvedPath = resolveModule(id, opts);
551
+ const jiti = createJiti(import.meta.url, {
552
+ interopDefault: opts?.interopDefault !== false
553
+ });
554
+ return jiti(pathToFileURL(resolvedPath).href);
555
+ }
556
+ function tryRequireModule(id, opts) {
557
+ try {
558
+ return requireModule(id, opts);
559
+ } catch {
560
+ }
561
+ }
562
+
544
563
  const NODE_MODULES_RE = /[/\\]node_modules[/\\]/;
545
564
  async function installModules(modulesToInstall, resolvedModulePaths, nuxt = useNuxt()) {
546
565
  const localLayerModuleDirs = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxt/kit-nightly",
3
- "version": "4.2.0-29331654.df559ad9",
3
+ "version": "4.2.0-29331790.6ef632b8",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/nuxt/nuxt.git",
@@ -47,7 +47,7 @@
47
47
  "untyped": "^2.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@nuxt/schema": "npm:@nuxt/schema-nightly@4.2.0-29331654.df559ad9",
50
+ "@nuxt/schema": "npm:@nuxt/schema-nightly@4.2.0-29331790.6ef632b8",
51
51
  "@rspack/core": "1.5.8",
52
52
  "@types/semver": "7.7.1",
53
53
  "hookable": "5.5.3",