2025-09-23 04:14:17 +08:00
|
|
|
#### Avoid break `{import,require.resolve,require.resolve.paths,import.meta.resolve}()` with long module name (#17882, #17908 by @kovsu & @fisker)
|
2025-09-11 16:18:03 +08:00
|
|
|
|
|
|
|
|
<!-- prettier-ignore -->
|
|
|
|
|
```js
|
|
|
|
|
// Input
|
2025-09-23 04:14:17 +08:00
|
|
|
const a = require("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
|
|
|
|
const b = require.resolve("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
|
|
|
|
const c = require.resolve.paths("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
|
|
|
|
|
|
|
|
|
const d = await import("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module")
|
|
|
|
|
const e = import.meta.resolve("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
2025-09-11 16:18:03 +08:00
|
|
|
|
|
|
|
|
// Prettier stable
|
2025-09-23 04:14:17 +08:00
|
|
|
const a = require("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
|
|
|
|
const b = require.resolve(
|
|
|
|
|
"./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module",
|
|
|
|
|
);
|
|
|
|
|
const c = require.resolve.paths(
|
|
|
|
|
"./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module",
|
2025-09-11 16:18:03 +08:00
|
|
|
);
|
|
|
|
|
|
2025-09-23 04:14:17 +08:00
|
|
|
const d = await import(
|
|
|
|
|
"./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module"
|
|
|
|
|
);
|
|
|
|
|
const e = import.meta.resolve(
|
|
|
|
|
"./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module",
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Prettier main
|
|
|
|
|
const a = require("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
|
|
|
|
const b =
|
|
|
|
|
require.resolve("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
|
|
|
|
const c = require.resolve
|
|
|
|
|
.paths("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
|
|
|
|
|
|
|
|
|
const d =
|
2025-09-11 16:18:03 +08:00
|
|
|
await import("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
2025-09-23 04:14:17 +08:00
|
|
|
const e = import.meta
|
|
|
|
|
.resolve("./a/long/long/long/long/long/long/long/long/long/long/long/path/to/module");
|
2025-09-11 16:18:03 +08:00
|
|
|
```
|