knip 2.41.1 → 2.41.2
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/plugins/vite/index.js +1 -1
- package/dist/util/fs.d.ts +1 -1
- package/dist/util/fs.js +9 -16
- package/dist/util/loader.js +7 -2
- package/dist/util/register.d.ts +2 -1
- package/dist/util/register.js +9 -13
- package/dist/util/require.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { findVitestDependencies } from '../vitest/index.js';
|
|
|
4
4
|
export const NAME = 'Vite';
|
|
5
5
|
export const ENABLERS = ['vite'];
|
|
6
6
|
export const isEnabled = ({ dependencies }) => hasDependency(dependencies, ENABLERS);
|
|
7
|
-
export const CONFIG_FILE_PATTERNS = ['vite.config.{js,ts}'];
|
|
7
|
+
export const CONFIG_FILE_PATTERNS = ['vite.config.{js,mjs,ts,cjs,mts,cts}'];
|
|
8
8
|
const findViteDependencies = async (configFilePath, options) => {
|
|
9
9
|
const localConfig = await load(configFilePath);
|
|
10
10
|
if (!localConfig)
|
package/dist/util/fs.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare const loadJSON: (filePath: string) => Promise<any>;
|
|
|
5
5
|
export declare const loadYAML: (filePath: string) => Promise<unknown>;
|
|
6
6
|
export declare const parseJSON: (filePath: string, contents: string) => Promise<any>;
|
|
7
7
|
export declare const parseYAML: (contents: string) => Promise<unknown>;
|
|
8
|
-
export declare function isTypeModule(
|
|
8
|
+
export declare function isTypeModule(path: string): boolean;
|
package/dist/util/fs.js
CHANGED
|
@@ -40,25 +40,18 @@ export const parseJSON = async (filePath, contents) => {
|
|
|
40
40
|
export const parseYAML = async (contents) => {
|
|
41
41
|
return yaml.load(contents);
|
|
42
42
|
};
|
|
43
|
-
export function isTypeModule(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
while (true) {
|
|
49
|
-
const packagePath = join(currentDir, 'package.json');
|
|
43
|
+
export function isTypeModule(path) {
|
|
44
|
+
while (path && path !== '.' && path !== '/') {
|
|
45
|
+
path = dirname(path);
|
|
46
|
+
try {
|
|
47
|
+
const pkg = readFileSync(join(path, 'package.json'), 'utf-8');
|
|
50
48
|
try {
|
|
51
|
-
|
|
52
|
-
return data.type === 'module';
|
|
49
|
+
return JSON.parse(pkg).type === 'module';
|
|
53
50
|
}
|
|
54
51
|
catch { }
|
|
55
|
-
|
|
56
|
-
if (parentDir === currentDir)
|
|
57
|
-
return false;
|
|
58
|
-
currentDir = parentDir;
|
|
52
|
+
break;
|
|
59
53
|
}
|
|
54
|
+
catch { }
|
|
60
55
|
}
|
|
61
|
-
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
56
|
+
return false;
|
|
64
57
|
}
|
package/dist/util/loader.js
CHANGED
|
@@ -4,7 +4,7 @@ import { loadJSON, loadYAML, loadFile, parseJSON, parseYAML } from './fs.js';
|
|
|
4
4
|
import { isTypeModule } from './fs.js';
|
|
5
5
|
import { extname } from './path.js';
|
|
6
6
|
import { timerify } from './Performance.js';
|
|
7
|
-
import {
|
|
7
|
+
import { jitiCJS, jitiESM } from './register.js';
|
|
8
8
|
export const FAKE_PATH = '__FAKE__';
|
|
9
9
|
const load = async (filePath) => {
|
|
10
10
|
if (filePath === FAKE_PATH)
|
|
@@ -26,7 +26,12 @@ const load = async (filePath) => {
|
|
|
26
26
|
const imported = await import(fileUrl.href);
|
|
27
27
|
return imported.default ?? imported;
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
if (isTypeModule(filePath)) {
|
|
30
|
+
return await jitiESM(filePath);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return await jitiCJS(filePath);
|
|
34
|
+
}
|
|
30
35
|
}
|
|
31
36
|
catch (error) {
|
|
32
37
|
throw new LoaderError(`Error loading ${filePath}`, { cause: error });
|
package/dist/util/register.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const jitiCJS: any;
|
|
2
|
+
export declare const jitiESM: any;
|
package/dist/util/register.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
jiti.register();
|
|
8
|
-
}
|
|
9
|
-
const exportFilePath = (module, filePath) => {
|
|
10
|
-
module.exports = filePath;
|
|
1
|
+
import createJITI, {} from 'jiti';
|
|
2
|
+
import { DEFAULT_EXTENSIONS } from '../constants.js';
|
|
3
|
+
const options = {
|
|
4
|
+
interopDefault: true,
|
|
5
|
+
extensions: DEFAULT_EXTENSIONS,
|
|
6
|
+
esmResolve: false,
|
|
11
7
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
8
|
+
const createLoader = (options) => createJITI(process.cwd(), options);
|
|
9
|
+
export const jitiCJS = createLoader(options);
|
|
10
|
+
export const jitiESM = createLoader({ ...options, esmResolve: true });
|
package/dist/util/require.js
CHANGED
|
@@ -5,11 +5,11 @@ import { debugLog } from './debug.js';
|
|
|
5
5
|
import { getPackageNameFromModuleSpecifier } from './modules.js';
|
|
6
6
|
import { cwd, toPosix, join } from './path.js';
|
|
7
7
|
import { timerify } from './Performance.js';
|
|
8
|
-
import {
|
|
8
|
+
import { jitiCJS } from './register.js';
|
|
9
9
|
const createRequire = (path) => nodeCreateRequire(pathToFileURL(path ?? cwd));
|
|
10
10
|
const require = createRequire();
|
|
11
11
|
export const _require = timerify(require);
|
|
12
|
-
const resolve = (specifier) => toPosix(
|
|
12
|
+
const resolve = (specifier) => toPosix(jitiCJS.resolve(specifier));
|
|
13
13
|
const tryResolve = (specifier, from) => {
|
|
14
14
|
try {
|
|
15
15
|
return resolve(specifier);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.41.
|
|
1
|
+
export declare const version = "2.41.2";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.41.
|
|
1
|
+
export const version = '2.41.2';
|
package/package.json
CHANGED