Commit 1a48666a by weiyudumei

feat: 添加本地包配置解决内网环境安装问题

- 添加packages目录包含unrs-resolver和eslint-import-context本地包
- 修改package.json直接引用本地包路径
- 更新scripts使用npm替代pnpm
- 修复HomeNew.tsx中的API错误处理
- 添加packages/README.md说明文档
parent 68e9334c
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -8,7 +8,7 @@
"dev": "rsbuild dev --open",
"build:sit": "npx rsbuild dev --env-mode sit",
"build": "rsbuild build",
"doctor": "RSDOCTOR=true pnpm build",
"doctor": "RSDOCTOR=true npm run build",
"preview": "npx rsbuild preview --env-mode production",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
......@@ -46,6 +46,7 @@
"axios": "^1.7.3",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
"eslint-import-context": "file:packages/eslint-import-context",
"github-markdown-css": "^5.8.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
......@@ -60,7 +61,8 @@
"rehype-raw": "^7.0.0",
"rehype-sanitize": "^6.0.0",
"remark-gfm": "^4.0.0",
"tailwind-merge": "^2.4.0"
"tailwind-merge": "^2.4.0",
"unrs-resolver": "file:packages/unrs-resolver"
},
"devDependencies": {
"@antfu/eslint-config": "^2.24.1",
......@@ -85,7 +87,7 @@
"typescript": "^5.5.2"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
"pre-commit": "npm run lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
......
# 本地包配置说明
## 概述
为了解决内网环境下 `unrs-resolver``eslint-import-context` 包安装失败的问题,我们将这些包下载到本地 `packages` 目录,并通过 `file:` 路径直接引用本地包。
## 包含的包
- `unrs-resolver@1.11.1` - Rust相关的解析器包
- `eslint-import-context@0.1.9` - ESLint导入上下文插件
## 配置方式
`package.json` 中直接引用本地包:
```json
{
"dependencies": {
"unrs-resolver": "file:packages/unrs-resolver",
"eslint-import-context": "file:packages/eslint-import-context"
}
}
```
## 使用方法
### 内网环境(推荐)
1. 确保 `packages` 目录中包含所需的包
2. 直接运行 `npm run dev` 启动项目
3. 项目会自动使用本地包,无需重新安装
### 如果需要重新安装依赖
```bash
# 清理之前的安装
rm -rf node_modules
rm -f package-lock.json
# 安装依赖(会使用本地包)
npm install --no-optional --legacy-peer-deps
```
## 优势
- **完全离线**:不需要网络连接
- **版本固定**:确保使用特定版本
- **快速启动**:不需要下载和编译
- **可控性强**:完全控制包的来源
- **即开即用**:包已下载,直接可用
## 注意事项
- 这些包是可选依赖,跳过它们不会影响项目正常运行
- 如果需要更新包版本,需要手动下载新版本到 `packages` 目录
- 建议将 `packages` 目录加入版本控制,确保团队环境一致
- 项目已经配置好,可以直接使用 `npm run dev` 启动
MIT License
Copyright (c) 2021-present UnTS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# eslint-import-context
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/un-ts/eslint-import-context/ci.yml?branch=main)](https://github.com/un-ts/eslint-import-context/actions/workflows/ci.yml?query=branch%3Amain)
[![Codecov](https://img.shields.io/codecov/c/github/un-ts/eslint-import-context.svg)](https://codecov.io/gh/un-ts/eslint-import-context)
[![type-coverage](https://img.shields.io/badge/dynamic/json.svg?label=type-coverage&prefix=%E2%89%A5&suffix=%&query=$.typeCoverage.atLeast&uri=https%3A%2F%2Fraw.githubusercontent.com%2Fun-ts%2Feslint-import-context%2Fmain%2Fpackage.json)](https://github.com/plantain-00/type-coverage)
[![CodeRabbit Pull Request Reviews](https://img.shields.io/coderabbit/prs/github/un-ts/eslint-import-context)](https://coderabbit.ai)
[![npm](https://img.shields.io/npm/v/eslint-import-context.svg)](https://www.npmjs.com/package/eslint-import-context)
[![GitHub Release](https://img.shields.io/github/release/un-ts/eslint-import-context)](https://github.com/un-ts/eslint-import-context/releases)
[![Conventional Commits](https://img.shields.io/badge/conventional%20commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://renovatebot.com)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Code Style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![changesets](https://img.shields.io/badge/maintained%20with-changesets-176de3.svg)](https://github.com/changesets/changesets)
Provide context info for eslint-plugin-import-x, so no extra arguments need to be added.
## TOC <!-- omit in toc -->
- [Usage](#usage)
- [Install](#install)
- [API](#api)
- [Sponsors and Backers](#sponsors-and-backers)
- [Sponsors](#sponsors)
- [Backers](#backers)
- [Changelog](#changelog)
- [License](#license)
## Usage
### Install
```sh
# pnpm
pnpm add eslint-import-context
# yarn
yarn add eslint-import-context
# npm
npm i eslint-import-context
# bun
bun add eslint-import-context
```
### API
```js
import { useRuleContext, getTsconfigWithContext } from 'eslint-import-context'
const ruleContext = useRuleContext()
const tsconfig = getTsconfigWithContext(ruleContext)
```
## Sponsors and Backers
[![Sponsors](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin)
### Sponsors
| 1stG | RxTS | UnTS |
| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| [![1stG Open Collective sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective sponsors](https://opencollective.com/rxts/organizations.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) |
### Backers
| 1stG | RxTS | UnTS |
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| [![1stG Open Collective backers](https://opencollective.com/1stG/individuals.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers](https://opencollective.com/rxts/individuals.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers](https://opencollective.com/unts/individuals.svg)](https://opencollective.com/unts) |
## Changelog
Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).
## License
[MIT][] © [JounQin][]@[1stG.me][]
[1stG.me]: https://www.1stG.me
[JounQin]: https://github.com/JounQin
[MIT]: http://opensource.org/licenses/MIT
import type { ChildContext, RuleContext } from './types.js';
export type * from './types.js';
export * from './utils.js';
export declare const setRuleContext: <T = void>(nextRuleContext: ChildContext | RuleContext, callback: () => T) => T;
export declare const useRuleContext: () => ChildContext | RuleContext<string, readonly unknown[]> | undefined;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useRuleContext = exports.setRuleContext = void 0;
__exportStar(require("./utils.js"), exports);
let ruleContext;
const setRuleContext = (nextRuleContext, callback) => {
const currentValue = ruleContext;
ruleContext = nextRuleContext;
const result = callback();
ruleContext = currentValue;
return result;
};
exports.setRuleContext = setRuleContext;
const useRuleContext = () => ruleContext;
exports.useRuleContext = useRuleContext;
//# sourceMappingURL=index.js.map
\ No newline at end of file
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAGA,6CAA0B;AAE1B,IAAI,WAAmD,CAAA;AAEhD,MAAM,cAAc,GAAG,CAC5B,eAA2C,EAC3C,QAAiB,EACjB,EAAE;IACF,MAAM,YAAY,GAAG,WAAW,CAAA;IAChC,WAAW,GAAG,eAAe,CAAA;IAC7B,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAA;IACzB,WAAW,GAAG,YAAY,CAAA;IAC1B,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AATY,QAAA,cAAc,kBAS1B;AAEM,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,WAAW,CAAA;AAAlC,QAAA,cAAc,kBAAoB"}
\ No newline at end of file
import type { TSESLint } from '@typescript-eslint/utils';
import type { KebabCase, LiteralUnion } from 'type-fest';
import type { NapiResolveOptions } from 'unrs-resolver';
import type { PluginName } from './utils.js';
export type FileExtension = `.${string}`;
export type DocStyle = 'jsdoc' | 'tomdoc';
export interface ResultNotFound {
found: false;
path?: undefined;
}
export interface ResultFound {
found: true;
path: string | null;
}
export type NewResolverResolve = (modulePath: string, sourceFile: string) => ResolvedResult;
export interface NewResolver {
interfaceVersion: 3;
name?: string;
resolve: NewResolverResolve;
}
export type Resolver = LegacyResolver | NewResolver;
export type ResolvedResult = ResultFound | ResultNotFound;
export interface NodeResolverOptions extends Omit<NapiResolveOptions, 'extensions'> {
basedir?: string;
includeCoreModules?: boolean;
extensions?: string | readonly string[];
paths?: string | readonly string[];
moduleDirectory?: string | readonly string[];
preserveSymlinks?: boolean;
package?: unknown;
packageFilter?: unknown;
pathFilter?: unknown;
packageIterator?: unknown;
}
export interface WebpackResolverOptions {
config?: string | {
resolve: NapiResolveOptions;
};
'config-index'?: number;
env?: Record<string, unknown>;
argv?: Record<string, unknown>;
}
export interface TsResolverOptions extends NapiResolveOptions {
alwaysTryTypes?: boolean;
project?: string[] | string;
extensions?: string[];
}
export type LegacyResolverName = LiteralUnion<'node' | 'typescript' | 'webpack', string>;
export type LegacyResolverResolveImport<T = unknown> = (modulePath: string, sourceFile: string, config: T) => string | undefined;
export type LegacyResolverResolve<T = unknown> = (modulePath: string, sourceFile: string, config: T) => ResolvedResult;
export interface LegacyResolverV1<T> {
interfaceVersion?: 1;
resolveImport: LegacyResolverResolveImport<T>;
}
export interface LegacyResolverV2<T> {
interfaceVersion: 2;
resolve: LegacyResolverResolve<T>;
}
export type LegacyResolver<T = unknown, U = T> = LegacyResolverV1<U> | LegacyResolverV2<T>;
export interface LegacyResolverObjectBase {
name: LegacyResolverName;
enable?: boolean;
options?: unknown;
resolver: LegacyResolver;
}
export interface LegacyNodeResolverObject extends LegacyResolverObjectBase {
name: 'node';
options?: NodeResolverOptions | boolean;
}
export interface LegacyTsResolverObject extends LegacyResolverObjectBase {
name: 'typescript';
options?: TsResolverOptions | boolean;
}
export interface LegacyWebpackResolverObject extends LegacyResolverObjectBase {
name: 'webpack';
options?: WebpackResolverOptions | boolean;
}
export type LegacyResolverObject = LegacyNodeResolverObject | LegacyResolverObjectBase | LegacyTsResolverObject | LegacyWebpackResolverObject;
export interface LegacyResolverRecord {
[resolve: string]: unknown;
node?: NodeResolverOptions | boolean;
typescript?: TsResolverOptions | boolean;
webpack?: WebpackResolverOptions | boolean;
}
export type LegacyImportResolver = LegacyResolverName | LegacyResolverName[] | LegacyResolverObject | LegacyResolverObject[] | LegacyResolverRecord | LegacyResolverRecord[];
export interface ImportSettings {
cache?: {
lifetime?: number | '∞' | 'Infinity';
};
coreModules?: string[];
docstyle?: DocStyle[];
extensions?: readonly FileExtension[];
externalModuleFolders?: string[];
ignore?: string[];
internalRegex?: string;
parsers?: Record<string, readonly FileExtension[]>;
resolve?: NodeResolverOptions;
resolver?: LegacyImportResolver;
'resolver-legacy'?: LegacyImportResolver;
'resolver-next'?: NewResolver | NewResolver[];
}
export type WithPluginName<T extends object | string> = T extends string ? `${PluginName}/${KebabCase<T>}` : {
[K in keyof T as WithPluginName<`${KebabCase<K & string>}`>]: T[K];
};
export type PluginSettings = WithPluginName<ImportSettings>;
export interface RuleContext<TMessageIds extends string = string, TOptions extends readonly unknown[] = readonly unknown[]> extends Omit<TSESLint.RuleContext<TMessageIds, TOptions>, 'settings'> {
settings: PluginSettings;
}
export interface ChildContext {
cacheKey: string;
settings: PluginSettings;
parserPath?: string | null;
parserOptions?: TSESLint.ParserOptions;
languageOptions?: TSESLint.FlatConfig.LanguageOptions;
path: string;
cwd: string;
filename: string;
physicalFilename: string;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map
\ No newline at end of file
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
\ No newline at end of file
import type { ChildContext, RuleContext } from './types.js';
export declare const pluginName = "import-x";
export type PluginName = typeof pluginName;
export declare function getTsconfigWithContext(context: ChildContext | RuleContext): {
compilerOptions?: import("get-tsconfig").TsConfigJson.CompilerOptions | undefined;
watchOptions?: import("get-tsconfig").TsConfigJson.WatchOptions | undefined;
typeAcquisition?: import("get-tsconfig").TsConfigJson.TypeAcquisition | undefined;
compileOnSave?: boolean | undefined;
files?: string[] | undefined;
exclude?: string[] | undefined;
include?: string[] | undefined;
references?: import("get-tsconfig").TsConfigJson.References[] | undefined;
} | null | undefined;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.pluginName = void 0;
exports.getTsconfigWithContext = getTsconfigWithContext;
const node_path_1 = __importDefault(require("node:path"));
const get_tsconfig_1 = require("get-tsconfig");
const stable_hash_x_1 = require("stable-hash-x");
exports.pluginName = 'import-x';
const tsconfigCache = new Map();
function getTsconfigWithContext(context) {
var _a;
const parserOptions = ((_a = context.languageOptions) === null || _a === void 0 ? void 0 : _a.parserOptions) || context.parserOptions;
let tsconfigRootDir = parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.tsconfigRootDir;
const project = parserOptions === null || parserOptions === void 0 ? void 0 : parserOptions.project;
const cacheKey = (0, stable_hash_x_1.stableHash)([tsconfigRootDir, project]);
let tsconfig;
if (tsconfigCache.has(cacheKey)) {
tsconfig = tsconfigCache.get(cacheKey);
}
else {
tsconfigRootDir =
tsconfigRootDir ||
process.cwd();
let tsconfigResult;
if (project) {
const projects = Array.isArray(project) ? project : [project];
for (const project of projects) {
tsconfigResult = (0, get_tsconfig_1.getTsconfig)(project === true
? context.physicalFilename
: node_path_1.default.resolve(tsconfigRootDir, project));
if (tsconfigResult) {
break;
}
}
}
else {
tsconfigResult = (0, get_tsconfig_1.getTsconfig)(tsconfigRootDir);
}
tsconfig = tsconfigResult === null || tsconfigResult === void 0 ? void 0 : tsconfigResult.config;
tsconfigCache.set(cacheKey, tsconfig);
}
return tsconfig;
}
//# sourceMappingURL=utils.js.map
\ No newline at end of file
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;AAeA,wDAmCC;AAlDD,0DAA4B;AAE5B,+CAA0C;AAE1C,iDAA0C;AAI7B,QAAA,UAAU,GAAG,UAAU,CAAA;AAIpC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAmD,CAAA;AAGhF,SAAgB,sBAAsB,CAAC,OAAmC;;IACxE,MAAM,aAAa,GACjB,CAAA,MAAA,OAAO,CAAC,eAAe,0CAAE,aAAa,KAAI,OAAO,CAAC,aAAa,CAAA;IACjE,IAAI,eAAe,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,eAAe,CAAA;IACpD,MAAM,OAAO,GAAG,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,CAAA;IACtC,MAAM,QAAQ,GAAG,IAAA,0BAAU,EAAC,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAA;IACvD,IAAI,QAAiD,CAAA;IACrD,IAAI,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChC,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IACxC,CAAC;SAAM,CAAC;QACN,eAAe;YACb,eAAe;gBAGf,OAAO,CAAC,GAAG,EAAE,CAAA;QACf,IAAI,cAAiD,CAAA;QACrD,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;YAC7D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;gBAC/B,cAAc,GAAG,IAAA,0BAAW,EAC1B,OAAO,KAAK,IAAI;oBACd,CAAC,CAAC,OAAO,CAAC,gBAAgB;oBAC1B,CAAC,CAAC,mBAAI,CAAC,OAAO,CAAC,eAAe,EAAE,OAAO,CAAC,CAC3C,CAAA;gBACD,IAAI,cAAc,EAAE,CAAC;oBACnB,MAAK;gBACP,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,cAAc,GAAG,IAAA,0BAAW,EAAC,eAAe,CAAC,CAAA;QAC/C,CAAC;QACD,QAAQ,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,CAAA;QACjC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACvC,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
\ No newline at end of file
{
"name": "eslint-import-context",
"version": "0.1.9",
"type": "commonjs",
"description": "Provide context info for eslint-plugin-import-x, so no extra arguments need to be added.",
"repository": "git+https://github.com/un-ts/eslint-import-context.git",
"author": "JounQin <admin@1stg.me> (https://www.1stG.me)",
"funding": "https://opencollective.com/eslint-import-context",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.18.0 || >=16.0.0"
},
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"./package.json": "./package.json"
},
"files": [
"lib",
"!**/*.tsbuildinfo"
],
"peerDependencies": {
"unrs-resolver": "^1.0.0"
},
"peerDependenciesMeta": {
"unrs-resolver": {
"optional": true
}
},
"dependencies": {
"get-tsconfig": "^4.10.1",
"stable-hash-x": "^0.2.0"
}
}
\ No newline at end of file
> [!NOTE]
>
> This is a fork of [oxc-resolver] and [rspack-resolver], and will be used in [eslint-plugin-import-x] and [eslint-import-resolver-typescript] cause 100% compatible with [enhanced-resolve] is the non-goal of [oxc-resolver] itself, we add [enhanced-resolve] specific features like [`pnp support`](https://github.com/web-infra-dev/rspack/issues/2236).
>
> We also fix several bugs reported by [eslint-plugin-import-x] and [eslint-import-resolver-typescript] users:
>
> - takes `paths` and `references` into account [at the same time](https://github.com/unrs/unrs-resolver/pull/12)
> - `references` should [take higher priority](https://github.com/unrs/unrs-resolver/pull/13)
> - support `pnpapi` core module and [package deep link](https://github.com/un-ts/eslint-plugin-import-x/issues/253)
> - enable [more targets](https://github.com/unrs/unrs-resolver/pull/29) support
> - absolute path aliasing [should not be skipped](https://github.com/import-js/eslint-import-resolver-typescript/issues/401)
> - use [napi-postinstall] for [legacy npm versions](https://github.com/unrs/unrs-resolver/issues/56)
> - Raspberry PI 4 aarch64 [compatibility issue](https://github.com/unrs/unrs-resolver/issues/64) and [import-js/eslint-import-resolver-typescript#406](https://github.com/import-js/eslint-import-resolver-typescript/issues/406) due to [mimalloc-safe]
> - support `load_as_directory` for [`pnp` mode](https://github.com/import-js/eslint-import-resolver-typescript/issues/409)
> - [resolve parent base url correctly](https://github.com/import-js/eslint-import-resolver-typescript/issues/437) by normalizing as absolute path
>
> The list could be longer in the future, but we don't want to make it too long here.
>
> We also sync with [oxc-resolver] and [rspack-resolver] regularly to keep up with the latest changes:
>
> - `oxc-resolver`: [#15](https://github.com/unrs/unrs-resolver/pull/15), [#49](https://github.com/unrs/unrs-resolver/pull/49), [#62](https://github.com/unrs/unrs-resolver/pull/62), [#86](https://github.com/unrs/unrs-resolver/pull/86) and [#94](https://github.com/unrs/unrs-resolver/pull/94)
> - `rspack-resolver`(planned): [#59](https://github.com/unrs/unrs-resolver/issues/59)
>
> Last but not least, we prepare some bug fix PRs first on our side and PR back into upstream projects, and we will keep doing this in the future:
>
> - `oxc-resolver`: [#84](https://github.com/unrs/unrs-resolver/pull/84) with [oxc-resolver#455](https://github.com/oxc-project/oxc-resolver/pull/455)
> - `rspack-resolver`: [#7](https://github.com/unrs/unrs-resolver/pull/7) with [rspack-resolver#54](https://github.com/web-infra-dev/rspack-resolver/pull/54), which is eventually replaced by [oxc-resolver#443](https://github.com/oxc-project/oxc-resolver/pull/443)
<div align="center">
[![Crates.io][crates-badge]][crates-url]
[![npmjs.com][npm-badge]][npm-url]
[![Docs.rs][docs-badge]][docs-url]
[![Build Status][ci-badge]][ci-url]
[![Code Coverage][code-coverage-badge]][code-coverage-url]
[![CodSpeed Badge][codspeed-badge]][codspeed-url]
[![Sponsors][sponsors-badge]][sponsors-url]
[![MIT licensed][license-badge]][license-url]
</div>
# UnRS Resolver
Rust port of [enhanced-resolve].
- Released on [crates.io][crates-url] and [npm][npm-url].
- Implements the [ESM](https://nodejs.org/api/esm.html#resolution-algorithm) and [CommonJS](https://nodejs.org/api/modules.html#all-together) module resolution algorithm specification.
- Built-in [tsconfig-paths-webpack-plugin]
- support extending tsconfig defined in `tsconfig.extends`
- support paths alias defined in `tsconfig.compilerOptions.paths`
- support project references defined `tsconfig.references`
- support [template variable ${configDir} for substitution of config files directory path](https://github.com/microsoft/TypeScript/pull/58042)
- Supports in-memory file system via the `FileSystem` trait.
- Contains `tracing` instrumentation.
## Usage
### npm package
See `index.d.ts` for `resolveSync` and `ResolverFactory` API.
Quick example:
```javascript
import assert from 'node:assert';
import path from 'node:path';
import resolve, { ResolverFactory } from 'unrs-resolver';
// `resolve`
assert(resolve.sync(process.cwd(), './index.js').path, path.resolve('index.js'));
// `ResolverFactory`
const resolver = new ResolverFactory();
assert(resolver.sync(process.cwd(), './index.js').path, path.resolve('index.js'));
```
### Supports WASM
See https://stackblitz.com/edit/unrs-resolver for usage example.
### Rust
See [docs.rs/unrs_resolver](https://docs.rs/unrs_resolver/latest/unrs_resolver/).
### [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp)
- For node.js, yarn pnp should work without any configuration, given the following conditions:
- the program is called with the `yarn` command, where the value [`process.versions.pnp`](https://yarnpkg.com/advanced/pnpapi#processversionspnp) is set.
- `.pnp.cjs` manifest file exists in the closest directory, searched from the current working directory,
- no multi-project setup, per second bullet point in [FIND_PNP_MANIFEST](https://yarnpkg.com/advanced/pnp-spec#find_pnp_manifest)
## Terminology
### `directory`
An **absolute** path to a directory where the specifier is resolved against.
For CommonJS modules, it is the `__dirname` variable that contains the absolute path to the folder containing current module.
For ECMAScript modules, it is the value of `import.meta.dirname`.
Behavior is undefined when given a path to a file.
### `specifier`
The string passed to `require` or `import`, i.e. `require("specifier")` or `import "specifier"`
## Errors and Trouble Shooting
- `Error: Package subpath '.' is not defined by "exports" in` - occurs when resolving without `conditionNames`.
## Configuration
The following usages apply to both Rust and Node.js; the code snippets are written in JavaScript.
To handle the `exports` field in `package.json`, ESM and CJS need to be differentiated.
### ESM
Per [ESM Resolution algorithm](https://nodejs.org/api/esm.html#resolution-and-loading-algorithm)
> defaultConditions is the conditional environment name array, ["node", "import"].
This means when the caller is an ESM import (`import "module"`), resolve options should be
```javascript
{
"conditionNames": ["node", "import"]
}
```
### CJS
Per [CJS Resolution algorithm](https://nodejs.org/api/modules.html#all-together)
> LOAD_PACKAGE_EXPORTS(X, DIR)
>
> 5. let MATCH = PACKAGE_EXPORTS_RESOLVE(pathToFileURL(DIR/NAME), "." + SUBPATH,
> `package.json` "exports", ["node", "require"]) defined in the ESM resolver.
This means when the caller is a CJS require (`require("module")`), resolve options should be
```javascript
{
"conditionNames": ["node", "require"]
}
```
### Cache
To support both CJS and ESM with the same cache:
```javascript
const esmResolver = new ResolverFactory({
conditionNames: ['node', 'import'],
});
const cjsResolver = esmResolver.cloneWithOptions({
conditionNames: ['node', 'require'],
});
```
### Browser Field
From this [non-standard spec](https://github.com/defunctzombie/package-browser-field-spec):
> The `browser` field is provided to JavaScript bundlers or component tools when packaging modules for client side use.
The option is
```javascript
{
"aliasFields": ["browser"]
}
```
### Main Field
```javascript
{
"mainFields": ["module", "main"]
}
```
Quoting esbuild's documentation:
- `main` - This is [the standard field](https://docs.npmjs.com/files/package.json#main) for all packages that are meant to be used with node. The name main is hard-coded in to node's module resolution logic itself. Because it's intended for use with node, it's reasonable to expect that the file path in this field is a CommonJS-style module.
- `module` - This field came from a [proposal](https://github.com/dherman/defense-of-dot-js/blob/f31319be735b21739756b87d551f6711bd7aa283/proposal.md) for how to integrate ECMAScript modules into node. Because of this, it's reasonable to expect that the file path in this field is an ECMAScript-style module. This proposal wasn't adopted by node (node uses "type": "module" instead) but it was adopted by major bundlers because ECMAScript-style modules lead to better tree shaking, or dead code removal.
- `browser` - This field came from a [proposal](https://gist.github.com/defunctzombie/4339901/49493836fb873ddaa4b8a7aa0ef2352119f69211) that allows bundlers to replace node-specific files or modules with their browser-friendly versions. It lets you specify an alternate browser-specific entry point. Note that it is possible for a package to use both the browser and module field together (see the note below).
## Options
The following options are aligned with [enhanced-resolve], and is implemented for Rust crate usage.
See [index.d.ts](https://github.com/unrs/unrs-resolver/blob/main/napi/index.d.ts) for Node.js usage.
| Field | Default | Description |
| ------------------------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| alias | {} | A hash map of module alias configurations |
| aliasFields | [] | A list of alias fields in description files |
| extensionAlias | {} | An object which maps extension to extension aliases |
| conditionNames | [] | A list of exports field condition names |
| descriptionFiles | ["package.json"] | A list of description files to read from |
| enforceExtension | false | Enforce that a extension from extensions must be used |
| exportsFields | ["exports"] | A list of exports fields in description files |
| extensions | [".js", ".json", ".node"] | A list of extensions which should be tried for files |
| fallback | {} | Same as `alias`, but only used if default resolving fails |
| fileSystem | | The file system which should be used |
| fullySpecified | false | Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests) |
| mainFields | ["main"] | A list of main fields in description files |
| mainFiles | ["index"] | A list of main files in directories |
| modules | ["node_modules"] | A list of directories to resolve modules from, can be absolute path or folder name |
| resolveToContext | false | Resolve to a context instead of a file |
| preferRelative | false | Prefer to resolve module requests as relative request and fallback to resolving as module |
| preferAbsolute | false | Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots |
| restrictions | [] | A list of resolve restrictions |
| roots | [] | A list of root paths |
| symlinks | true | Whether to resolve symlinks to their symlinked location |
| allowPackageExportsInDirectoryResolve | false | Allow `exports` field in `require('../directory')`. Not part of `enhanced-resolve`. |
### TypeScript Configuration
| Field | Default | Description |
| ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| tsconfig | None | TypeScript related config for resolver |
| tsconfig.configFile | | A relative path to the tsconfig file based on `cwd`, or an absolute path of tsconfig file. |
| tsconfig.references | `[]` | - 'auto': inherits from TypeScript config <br/> - `string []`: relative path (based on directory of the referencing tsconfig file) or absolute path of referenced project's tsconfig |
### Unimplemented Options
| Field | Default | Description |
| ---------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| cachePredicate | function() { return true }; | A function which decides whether a request should be cached or not. An object is passed to the function with `path` and `request` properties. |
| cacheWithContext | true | If unsafe cache is enabled, includes `request.context` in the cache key |
| plugins | [] | A list of additional resolve plugins which should be applied |
| resolver | undefined | A prepared Resolver to which the plugins are attached |
| unsafeCache | false | Use this cache object to unsafely cache the successful requests |
## Debugging
The following environment variable emits tracing information for the `unrs_resolver::resolve` function.
e.g.
```
2024-06-11T07:12:20.003537Z DEBUG unrs_resolver: options: ResolveOptions { ... }, path: "...", specifier: "...", ret: "..."
at /path/to/unrs_resolver-1.8.1/src/lib.rs:212
in unrs_resolver::resolve with path: "...", specifier: "..."
```
The input values are `options`, `path` and `specifier`, the returned value is `ret`.
### NAPI
```
UNRS_LOG=DEBUG your_program
```
## Test
Tests are ported from
- [enhanced-resolve](https://github.com/webpack/enhanced-resolve/tree/main/test)
- [tsconfig-path](https://github.com/dividab/tsconfig-paths/blob/master/src/__tests__/data/match-path-data.ts) and [parcel-resolver](https://github.com/parcel-bundler/parcel/tree/v2/packages/utils/node-resolver-core/test/fixture/tsconfig) for tsconfig-paths
Test cases are located in `./src/tests`, fixtures are located in `./tests`
- [x] alias.test.js
- [x] browserField.test.js
- [x] dependencies.test.js
- [x] exportsField.test.js
- [x] extension-alias.test.js
- [x] extensions.test.js
- [x] fallback.test.js
- [x] fullSpecified.test.js
- [x] identifier.test.js (see unit test in `crates/unrs_resolver/src/request.rs`)
- [x] importsField.test.js
- [x] incorrect-description-file.test.js (need to add ctx.fileDependencies)
- [x] missing.test.js
- [x] path.test.js (see unit test in `crates/unrs_resolver/src/path.rs`)
- [ ] plugins.test.js
- [ ] pnp.test.js
- [x] resolve.test.js
- [x] restrictions.test.js (partially done, regex is not supported yet)
- [x] roots.test.js
- [x] scoped-packages.test.js
- [x] simple.test.js
- [x] symlink.test.js
Irrelevant tests
- CachedInputFileSystem.test.js
- SyncAsyncFileSystemDecorator.test.js
- forEachBail.test.js
- getPaths.test.js
- pr-53.test.js
- unsafe-cache.test.js
- yield.test.js
## [Sponsored By](https://github.com/sponsors/JounQin)
[![Sponsors](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin)
### Sponsors
| 1stG | UnRs | UnTS |
| ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| [![1stG Open Collective backers and sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![UnRs Open Collective backers and sponsors](https://opencollective.com/unrs/organizations.svg)](https://opencollective.com/unrs) | [![UnTS Open Collective backers and sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) |
### Backers
| 1stG | UnRs | UnTS |
| -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| [![1stG Open Collective backers and sponsors](https://opencollective.com/1stG/individuals.svg)](https://opencollective.com/1stG) | [![UnRs Open Collective backers and sponsors](https://opencollective.com/unrs/individuals.svg)](https://opencollective.com/unrs) | [![UnTS Open Collective backers and sponsors](https://opencollective.com/unts/individuals.svg)](https://opencollective.com/unts) |
## 📖 License
`unrs_resolver` is free and open-source software licensed under the [MIT License](./LICENSE).
UnRS partially copies code from the following projects.
| Project | License |
| --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| [webpack/enhanced-resolve](https://github.com/webpack/enhanced-resolve) | [MIT](https://github.com/webpack/enhanced-resolve/blob/main/LICENSE) |
| [dividab/tsconfig-paths](https://github.com/dividab/tsconfig-paths) | [MIT](https://github.com/dividab/tsconfig-paths/blob/master/LICENSE) |
| [parcel-bundler/parcel](https://github.com/parcel-bundler/parcel) | [MIT](https://github.com/parcel-bundler/parcel/blob/v2/LICENSE) |
| [tmccombs/json-comments-rs](https://github.com/tmccombs/json-comments-rs) | [Apache 2.0](https://github.com/tmccombs/json-comments-rs/blob/main/LICENSE) |
| [oxc-project/oxc-resolver](https://github.com/oxc-project/oxc-resolver) | [MIT](https://github.com/oxc-project/oxc-resolver/blob/main/LICENSE) |
| [web-infra-dev/rspack-resolver](https://github.com/web-infra-dev/rspack-resolver) | [MIT](https://github.com/web-infra-dev/rspack-resolver/blob/main/LICENSE) |
[enhanced-resolve]: https://github.com/webpack/enhanced-resolve
[oxc-resolver]: https://github.com/oxc-project/oxc-resolver
[rspack-resolver]: https://github.com/web-infra-dev/rspack-resolver
[eslint-plugin-import-x]: https://github.com/un-ts/eslint-plugin-import-x
[eslint-import-resolver-typescript]: https://github.com/import-js/eslint-import-resolver-typescript
[napi-postinstall]: https://github.com/un-ts/napi-postinstall
[mimalloc-safe]: https://github.com/napi-rs/mimalloc-safe
[tsconfig-paths-webpack-plugin]: https://github.com/dividab/tsconfig-paths-webpack-plugin
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg
[license-url]: https://github.com/unrs/unrs-resolver/blob/main/LICENSE
[ci-badge]: https://github.com/unrs/unrs-resolver/actions/workflows/ci.yml/badge.svg?event=push&branch=main
[ci-url]: https://github.com/unrs/unrs-resolver/actions/workflows/ci.yml?query=event%3Apush+branch%3Amain
[code-coverage-badge]: https://codecov.io/github/unrs/unrs-resolver/branch/main/graph/badge.svg
[code-coverage-url]: https://codecov.io/gh/unrs/unrs-resolver
[sponsors-badge]: https://img.shields.io/github/sponsors/JounQin
[sponsors-url]: https://github.com/sponsors/JounQin
[codspeed-badge]: https://img.shields.io/endpoint?url=https://codspeed.io/badge.json
[codspeed-url]: https://codspeed.io/unrs/unrs-resolver
[crates-badge]: https://img.shields.io/crates/d/unrs_resolver?label=crates.io
[crates-url]: https://crates.io/crates/unrs_resolver
[docs-badge]: https://img.shields.io/docsrs/unrs_resolver
[docs-url]: https://docs.rs/unrs_resolver
[npm-badge]: https://img.shields.io/npm/dw/unrs-resolver?label=npm
[npm-url]: https://www.npmjs.com/package/unrs-resolver
export * from '@unrs/resolver-binding-wasm32-wasi'
/* auto-generated by NAPI-RS */
/* eslint-disable */
export declare class ResolverFactory {
constructor(options?: NapiResolveOptions | undefined | null)
static default(): ResolverFactory
/** Clone the resolver using the same underlying cache. */
cloneWithOptions(options: NapiResolveOptions): ResolverFactory
/** Clear the underlying cache. */
clearCache(): void
/** Synchronously resolve `specifier` at an absolute path to a `directory`. */
sync(directory: string, request: string): ResolveResult
/** Asynchronously resolve `specifier` at an absolute path to a `directory`. */
async(directory: string, request: string): Promise<ResolveResult>
}
/** Node.js builtin module when `Options::builtin_modules` is enabled. */
export interface Builtin {
/**
* Resolved module.
*
* Always prefixed with "node:" in compliance with the ESM specification.
*/
resolved: string
/**
* Whether the request was prefixed with `node:` or not.
* `fs` -> `false`.
* `node:fs` returns `true`.
*/
isRuntimeModule: boolean
}
export declare const enum EnforceExtension {
Auto = 0,
Enabled = 1,
Disabled = 2
}
export declare const enum ModuleType {
Module = 'module',
CommonJs = 'commonjs',
Json = 'json',
Wasm = 'wasm',
Addon = 'addon'
}
/**
* Module Resolution Options
*
* Options are directly ported from [enhanced-resolve](https://github.com/webpack/enhanced-resolve#resolver-options).
*
* See [webpack resolve](https://webpack.js.org/configuration/resolve/) for information and examples
*/
export interface NapiResolveOptions {
/**
* Path to TypeScript configuration file.
*
* Default `None`
*/
tsconfig?: TsconfigOptions
/**
* Alias for [ResolveOptions::alias] and [ResolveOptions::fallback].
*
* For the second value of the tuple, `None -> AliasValue::Ignore`, Some(String) ->
* AliasValue::Path(String)`
* Create aliases to import or require certain modules more easily.
* A trailing $ can also be added to the given object's keys to signify an exact match.
* Default `{}`
*/
alias?: Record<string, Array<string | undefined | null>>
/**
* A list of alias fields in description files.
* Specify a field, such as `browser`, to be parsed according to [this specification](https://github.com/defunctzombie/package-browser-field-spec).
* Can be a path to json object such as `["path", "to", "exports"]`.
*
* Default `[]`
*/
aliasFields?: (string | string[])[]
/**
* Condition names for exports field which defines entry points of a package.
* The key order in the exports field is significant. During condition matching, earlier entries have higher priority and take precedence over later entries.
*
* Default `[]`
*/
conditionNames?: Array<string>
/**
* The JSON files to use for descriptions. (There was once a `bower.json`.)
*
* Default `["package.json"]`
*/
descriptionFiles?: Array<string>
/**
* If true, it will not allow extension-less files.
* So by default `require('./foo')` works if `./foo` has a `.js` extension,
* but with this enabled only `require('./foo.js')` will work.
*
* Default to `true` when [ResolveOptions::extensions] contains an empty string.
* Use `Some(false)` to disable the behavior.
* See <https://github.com/webpack/enhanced-resolve/pull/285>
*
* Default None, which is the same as `Some(false)` when the above empty rule is not applied.
*/
enforceExtension?: EnforceExtension
/**
* A list of exports fields in description files.
* Can be a path to json object such as `["path", "to", "exports"]`.
*
* Default `[["exports"]]`.
*/
exportsFields?: (string | string[])[]
/**
* Fields from `package.json` which are used to provide the internal requests of a package
* (requests starting with # are considered internal).
*
* Can be a path to a JSON object such as `["path", "to", "imports"]`.
*
* Default `[["imports"]]`.
*/
importsFields?: (string | string[])[]
/**
* An object which maps extension to extension aliases.
*
* Default `{}`
*/
extensionAlias?: Record<string, Array<string>>
/**
* Attempt to resolve these extensions in order.
* If multiple files share the same name but have different extensions,
* will resolve the one with the extension listed first in the array and skip the rest.
*
* Default `[".js", ".json", ".node"]`
*/
extensions?: Array<string>
/**
* Redirect module requests when normal resolving fails.
*
* Default `{}`
*/
fallback?: Record<string, Array<string | undefined | null>>
/**
* Request passed to resolve is already fully specified and extensions or main files are not resolved for it (they are still resolved for internal requests).
*
* See also webpack configuration [resolve.fullySpecified](https://webpack.js.org/configuration/module/#resolvefullyspecified)
*
* Default `false`
*/
fullySpecified?: boolean
/**
* A list of main fields in description files
*
* Default `["main"]`.
*/
mainFields?: string | string[]
/**
* The filename to be used while resolving directories.
*
* Default `["index"]`
*/
mainFiles?: Array<string>
/**
* A list of directories to resolve modules from, can be absolute path or folder name.
*
* Default `["node_modules"]`
*/
modules?: string | string[]
/**
* Resolve to a context instead of a file.
*
* Default `false`
*/
resolveToContext?: boolean
/**
* Prefer to resolve module requests as relative requests instead of using modules from node_modules directories.
*
* Default `false`
*/
preferRelative?: boolean
/**
* Prefer to resolve server-relative urls as absolute paths before falling back to resolve in ResolveOptions::roots.
*
* Default `false`
*/
preferAbsolute?: boolean
/**
* A list of resolve restrictions to restrict the paths that a request can be resolved on.
*
* Default `[]`
*/
restrictions?: Array<Restriction>
/**
* A list of directories where requests of server-relative URLs (starting with '/') are resolved.
* On non-Windows systems these requests are resolved as an absolute path first.
*
* Default `[]`
*/
roots?: Array<string>
/**
* Whether to resolve symlinks to their symlinked location.
* When enabled, symlinked resources are resolved to their real path, not their symlinked location.
* Note that this may cause module resolution to fail when using tools that symlink packages (like npm link).
*
* Default `true`
*/
symlinks?: boolean
/**
* Whether to parse [module.builtinModules](https://nodejs.org/api/module.html#modulebuiltinmodules) or not.
* For example, "zlib" will throw [crate::ResolveError::Builtin] when set to true.
*
* Default `false`
*/
builtinModules?: boolean
/**
* Resolve [ResolveResult::moduleType].
*
* Default `false`
*/
moduleType?: boolean
/**
* Allow `exports` field in `require('../directory')`.
*
* This is not part of the spec but some vite projects rely on this behavior.
* See
* * <https://github.com/vitejs/vite/pull/20252>
* * <https://github.com/nodejs/node/issues/58827>
*
* Default: `false`
*/
allowPackageExportsInDirectoryResolve?: boolean
}
export interface ResolveResult {
path?: string
error?: string
builtin?: Builtin
/**
* Module type for this path.
*
* Enable with `ResolveOptions#moduleType`.
*
* The module type is computed `ESM_FILE_FORMAT` from the [ESM resolution algorithm specification](https://nodejs.org/docs/latest/api/esm.html#resolution-algorithm-specification).
*
* The algorithm uses the file extension or finds the closest `package.json` with the `type` field.
*/
moduleType?: ModuleType
/** `package.json` path for the given module. */
packageJsonPath?: string
}
/**
* Alias Value for [ResolveOptions::alias] and [ResolveOptions::fallback].
* Use struct because napi don't support structured union now
*/
export interface Restriction {
path?: string
regex?: string
}
export declare function sync(path: string, request: string): ResolveResult
/**
* Tsconfig Options
*
* Derived from [tsconfig-paths-webpack-plugin](https://github.com/dividab/tsconfig-paths-webpack-plugin#options)
*/
export interface TsconfigOptions {
/**
* Allows you to specify where to find the TypeScript configuration file.
* You may provide
* * a relative path to the configuration file. It will be resolved relative to cwd.
* * an absolute path to the configuration file.
*/
configFile: string
/**
* Support for Typescript Project References.
*
* * `'auto'`: use the `references` field from tsconfig of `config_file`.
* * `string[]`: manually provided relative or absolute path.
*/
references?: 'auto' | string[]
}
// prettier-ignore
/* eslint-disable */
// @ts-nocheck
/* auto-generated by NAPI-RS */
const { createRequire } = require('node:module')
require = createRequire(__filename)
const { readFileSync } = require('node:fs')
let nativeBinding = null
const loadErrors = []
const isMusl = () => {
let musl = false
if (process.platform === 'linux') {
musl = isMuslFromFilesystem()
if (musl === null) {
musl = isMuslFromReport()
}
if (musl === null) {
musl = isMuslFromChildProcess()
}
}
return musl
}
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
const isMuslFromFilesystem = () => {
try {
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
} catch {
return null
}
}
const isMuslFromReport = () => {
let report = null
if (typeof process.report?.getReport === 'function') {
process.report.excludeNetwork = true
report = process.report.getReport()
}
if (!report) {
return null
}
if (report.header && report.header.glibcVersionRuntime) {
return false
}
if (Array.isArray(report.sharedObjects)) {
if (report.sharedObjects.some(isFileMusl)) {
return true
}
}
return false
}
const isMuslFromChildProcess = () => {
try {
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
} catch (e) {
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
return false
}
}
function requireNative() {
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
try {
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
} catch (err) {
loadErrors.push(err)
}
} else if (process.platform === 'android') {
if (process.arch === 'arm64') {
try {
return require('./resolver.android-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-android-arm64')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm') {
try {
return require('./resolver.android-arm-eabi.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-android-arm-eabi')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
}
} else if (process.platform === 'win32') {
if (process.arch === 'x64') {
try {
return require('./resolver.win32-x64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-win32-x64-msvc')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'ia32') {
try {
return require('./resolver.win32-ia32-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-win32-ia32-msvc')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./resolver.win32-arm64-msvc.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-win32-arm64-msvc')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
}
} else if (process.platform === 'darwin') {
try {
return require('./resolver.darwin-universal.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-darwin-universal')
} catch (e) {
loadErrors.push(e)
}
if (process.arch === 'x64') {
try {
return require('./resolver.darwin-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-darwin-x64')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./resolver.darwin-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-darwin-arm64')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
}
} else if (process.platform === 'freebsd') {
if (process.arch === 'x64') {
try {
return require('./resolver.freebsd-x64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-freebsd-x64')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 'arm64') {
try {
return require('./resolver.freebsd-arm64.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-freebsd-arm64')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
}
} else if (process.platform === 'linux') {
if (process.arch === 'x64') {
if (isMusl()) {
try {
return require('./resolver.linux-x64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-x64-musl')
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./resolver.linux-x64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-x64-gnu')
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm64') {
if (isMusl()) {
try {
return require('./resolver.linux-arm64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-arm64-musl')
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./resolver.linux-arm64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-arm64-gnu')
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'arm') {
if (isMusl()) {
try {
return require('./resolver.linux-arm-musleabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-arm-musleabihf')
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./resolver.linux-arm-gnueabihf.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-arm-gnueabihf')
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'riscv64') {
if (isMusl()) {
try {
return require('./resolver.linux-riscv64-musl.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-riscv64-musl')
} catch (e) {
loadErrors.push(e)
}
} else {
try {
return require('./resolver.linux-riscv64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-riscv64-gnu')
} catch (e) {
loadErrors.push(e)
}
}
} else if (process.arch === 'ppc64') {
try {
return require('./resolver.linux-ppc64-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-ppc64-gnu')
} catch (e) {
loadErrors.push(e)
}
} else if (process.arch === 's390x') {
try {
return require('./resolver.linux-s390x-gnu.node')
} catch (e) {
loadErrors.push(e)
}
try {
return require('@unrs/resolver-binding-linux-s390x-gnu')
} catch (e) {
loadErrors.push(e)
}
} else {
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
}
} else {
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
}
}
nativeBinding = requireNative()
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
try {
nativeBinding = require('./resolver.wasi.cjs')
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
loadErrors.push(err)
}
}
if (!nativeBinding) {
try {
nativeBinding = require('@unrs/resolver-binding-wasm32-wasi')
} catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) {
loadErrors.push(err)
}
}
}
}
if (!nativeBinding && process.env.SKIP_UNRS_RESOLVER_FALLBACK !== '1') {
try {
nativeBinding = require('napi-postinstall/fallback')(require.resolve('./package.json'), true)
} catch (err) {
loadErrors.push(err)
}
}
if (!nativeBinding) {
if (loadErrors.length > 0) {
throw new Error(
`Cannot find native binding. ` +
`npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
{ cause: loadErrors }
)
}
throw new Error(`Failed to load native binding`)
}
module.exports = nativeBinding
module.exports.ResolverFactory = nativeBinding.ResolverFactory
module.exports.EnforceExtension = nativeBinding.EnforceExtension
module.exports.ModuleType = nativeBinding.ModuleType
module.exports.sync = nativeBinding.sync
if (process.versions.pnp) {
process.env.UNRS_RESOLVER_YARN_PNP = '1'
}
{
"name": "unrs-resolver",
"version": "1.11.1",
"type": "commonjs",
"description": "UnRS Resolver Node API with PNP support",
"repository": "git+https://github.com/unrs/unrs-resolver.git",
"homepage": "https://github.com/unrs/unrs-resolver#readme",
"author": "JounQin <admin@1stg.me> (https://www.1stG.me)",
"funding": "https://opencollective.com/unrs-resolver",
"license": "MIT",
"main": "index.js",
"browser": "browser.js",
"files": [
"browser.js",
"index.d.ts",
"index.js"
],
"scripts": {
"postinstall": "napi-postinstall unrs-resolver 1.11.1 check"
},
"dependencies": {
"napi-postinstall": "^0.3.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
},
"napi": {
"binaryName": "resolver",
"packageName": "@unrs/resolver-binding",
"wasm": {
"browser": {
"fs": true
}
},
"targets": [
"x86_64-pc-windows-msvc",
"aarch64-pc-windows-msvc",
"i686-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
"x86_64-unknown-freebsd",
"aarch64-linux-android",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"armv7-linux-androideabi",
"armv7-unknown-linux-gnueabihf",
"armv7-unknown-linux-musleabihf",
"powerpc64le-unknown-linux-gnu",
"riscv64gc-unknown-linux-gnu",
"riscv64gc-unknown-linux-musl",
"s390x-unknown-linux-gnu",
"x86_64-apple-darwin",
"aarch64-apple-darwin",
"wasm32-wasip1-threads"
]
},
"optionalDependencies": {
"@unrs/resolver-binding-win32-x64-msvc": "1.11.1",
"@unrs/resolver-binding-win32-arm64-msvc": "1.11.1",
"@unrs/resolver-binding-win32-ia32-msvc": "1.11.1",
"@unrs/resolver-binding-linux-x64-gnu": "1.11.1",
"@unrs/resolver-binding-linux-x64-musl": "1.11.1",
"@unrs/resolver-binding-freebsd-x64": "1.11.1",
"@unrs/resolver-binding-android-arm64": "1.11.1",
"@unrs/resolver-binding-linux-arm64-gnu": "1.11.1",
"@unrs/resolver-binding-linux-arm64-musl": "1.11.1",
"@unrs/resolver-binding-android-arm-eabi": "1.11.1",
"@unrs/resolver-binding-linux-arm-gnueabihf": "1.11.1",
"@unrs/resolver-binding-linux-arm-musleabihf": "1.11.1",
"@unrs/resolver-binding-linux-ppc64-gnu": "1.11.1",
"@unrs/resolver-binding-linux-riscv64-gnu": "1.11.1",
"@unrs/resolver-binding-linux-riscv64-musl": "1.11.1",
"@unrs/resolver-binding-linux-s390x-gnu": "1.11.1",
"@unrs/resolver-binding-darwin-x64": "1.11.1",
"@unrs/resolver-binding-darwin-arm64": "1.11.1",
"@unrs/resolver-binding-wasm32-wasi": "1.11.1"
}
}
\ No newline at end of file
......@@ -4,6 +4,10 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
overrides:
unrs-resolver: file:packages/unrs-resolver
eslint-import-context: file:packages/eslint-import-context
importers:
.:
......@@ -32,6 +36,9 @@ importers:
date-fns:
specifier: ^3.6.0
version: 3.6.0
eslint-import-context:
specifier: file:packages/eslint-import-context
version: file:packages/eslint-import-context(unrs-resolver@file:packages/unrs-resolver)
eslint-plugin-format:
specifier: '>=0.1.0'
version: 1.0.1(eslint@9.31.0(jiti@2.4.2))
......@@ -83,6 +90,9 @@ importers:
tailwind-merge:
specifier: ^2.4.0
version: 2.6.0
unrs-resolver:
specifier: file:packages/unrs-resolver
version: file:packages/unrs-resolver
devDependencies:
'@antfu/eslint-config':
specifier: ^2.24.1
......@@ -1062,24 +1072,28 @@ packages:
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@napi-rs/image-linux-arm64-musl@1.11.0':
resolution: {integrity: sha512-ZCzPTelN8MX07RhuXlqOVUk6oE1JcNA7OC4Hjxhqhme9khOXVH55H3QTfAJrk4X7WnPBxRsWtyWHbe7gZk8hvw==}
engines: {node: '>= 10'}
cpu: [arm64]
os: [linux]
libc: [musl]
'@napi-rs/image-linux-x64-gnu@1.11.0':
resolution: {integrity: sha512-O+eMM1qXfh+LOXU3Fzblnim3WOvADUTjEHguw5nCupxaswHTHJemoTxiXSpTW7/E+a9cjr2dptzyKdFhs9R7ig==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [glibc]
'@napi-rs/image-linux-x64-musl@1.11.0':
resolution: {integrity: sha512-kU5XO8/0HE8OUIv2vKO5NMUFl10Y+ctS7d7uUb3IeyyAV+qjn681i1kRPjsI810OR3Hjy2zxCblGbPRJVvoy7Q==}
engines: {node: '>= 10'}
cpu: [x64]
os: [linux]
libc: [musl]
'@napi-rs/image-wasm32-wasi@1.11.0':
resolution: {integrity: sha512-ZQUJxQ4dUO8gopbQV1j1vmVbtYzRvUcxS6EY/3+QL+biYYrKzedns2OCjuIK4PYkwiq4hiRJXQJRH1uDGNK0sg==}
......@@ -1814,21 +1828,25 @@ packages:
resolution: {integrity: sha512-NlXtRlKcoBzB6EQEiXegW0nMToEPXD+hExaev0j1+uzsFrMJ0uIY49k6+DapwWZ8A2jUdvH7xdWT+eAXD3l/EA==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@rspack/binding-linux-arm64-musl@1.0.0-beta.1':
resolution: {integrity: sha512-fPS8ukoPgmBSUX4dt74flObcbYzO3uaP1bk4k/98Gr3Bw0ACDZ6h5nqlxoXoeVzhNcNMBcfv45un8H3i411AyA==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@rspack/binding-linux-x64-gnu@1.0.0-beta.1':
resolution: {integrity: sha512-9U78G7BtevPZ9GEJ2AhGHt03n+GEhKVvEZ/tgu+flFV0tYGjq75QQX345x4m+uercTqzRBTyuWITweIzppeWuQ==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@rspack/binding-linux-x64-musl@1.0.0-beta.1':
resolution: {integrity: sha512-qqNPseWAOKmV33YL7tihY0N9xwY+N1G9na6lT7iqZnsrzPkIZmESI9Z24fXVJqLC/UhfxAth4RKhVBeKTsPk1w==}
cpu: [x64]
os: [linux]
libc: [musl]
'@rspack/binding-win32-arm64-msvc@1.0.0-beta.1':
resolution: {integrity: sha512-VeBGYItHWqImYt23rBChXrk1o7fQxwTv6BEhtMpTnMJV10O6+Db9NckPEplcKLmNKAAA5anxH40GcpPc4nff8A==}
......@@ -2176,41 +2194,49 @@ packages:
resolution: {integrity: sha512-34gw7PjDGB9JgePJEmhEqBhWvCiiWCuXsL9hYphDF7crW7UgI05gyBAi6MF58uGcMOiOqSJ2ybEeCvHcq0BCmQ==}
cpu: [arm64]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-arm64-musl@1.11.1':
resolution: {integrity: sha512-RyMIx6Uf53hhOtJDIamSbTskA99sPHS96wxVE/bJtePJJtpdKGXO1wY90oRdXuYOGOTuqjT8ACccMc4K6QmT3w==}
cpu: [arm64]
os: [linux]
libc: [musl]
'@unrs/resolver-binding-linux-ppc64-gnu@1.11.1':
resolution: {integrity: sha512-D8Vae74A4/a+mZH0FbOkFJL9DSK2R6TFPC9M+jCWYia/q2einCubX10pecpDiTmkJVUH+y8K3BZClycD8nCShA==}
cpu: [ppc64]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-riscv64-gnu@1.11.1':
resolution: {integrity: sha512-frxL4OrzOWVVsOc96+V3aqTIQl1O2TjgExV4EKgRY09AJ9leZpEg8Ak9phadbuX0BA4k8U5qtvMSQQGGmaJqcQ==}
cpu: [riscv64]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-riscv64-musl@1.11.1':
resolution: {integrity: sha512-mJ5vuDaIZ+l/acv01sHoXfpnyrNKOk/3aDoEdLO/Xtn9HuZlDD6jKxHlkN8ZhWyLJsRBxfv9GYM2utQ1SChKew==}
cpu: [riscv64]
os: [linux]
libc: [musl]
'@unrs/resolver-binding-linux-s390x-gnu@1.11.1':
resolution: {integrity: sha512-kELo8ebBVtb9sA7rMe1Cph4QHreByhaZ2QEADd9NzIQsYNQpt9UkM9iqr2lhGr5afh885d/cB5QeTXSbZHTYPg==}
cpu: [s390x]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-x64-gnu@1.11.1':
resolution: {integrity: sha512-C3ZAHugKgovV5YvAMsxhq0gtXuwESUKc5MhEtjBpLoHPLYM+iuwSj3lflFwK3DPm68660rZ7G8BMcwSro7hD5w==}
cpu: [x64]
os: [linux]
libc: [glibc]
'@unrs/resolver-binding-linux-x64-musl@1.11.1':
resolution: {integrity: sha512-rV0YSoyhK2nZ4vEswT/QwqzqQXw5I6CjoaYMOX0TqBlWhojUf8P94mvI7nuJTeaCkkds3QE4+zS8Ko+GdXuZtA==}
cpu: [x64]
os: [linux]
libc: [musl]
'@unrs/resolver-binding-wasm32-wasi@1.11.1':
resolution: {integrity: sha512-5u4RkfxJm+Ng7IWgkzi3qrFOvLvQYnPBmjmZQ8+szTK/b31fQCnleNl1GgEt7nIsZRIf5PLhPwT0WM+q45x/UQ==}
......@@ -2933,8 +2959,8 @@ packages:
peerDependencies:
eslint: '>=8.40.0'
eslint-import-context@0.1.9:
resolution: {integrity: sha512-K9Hb+yRaGAGUbwjhFNHvSmmkZs9+zbuoe3kFQ4V1wYjrepUFYM2dZAfNtjbbj3qsPfUfsA68Bx/ICWQMi+C8Eg==}
eslint-import-context@file:packages/eslint-import-context:
resolution: {directory: packages/eslint-import-context, type: directory}
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
peerDependencies:
unrs-resolver: ^1.0.0
......@@ -4963,8 +4989,8 @@ packages:
resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==}
engines: {node: '>= 0.8'}
unrs-resolver@1.11.1:
resolution: {integrity: sha512-bSjt9pjaEBnNiGgc9rUiHGKv5l4/TGzDmYw3RhnkJGtLhbnnA/5qJj7x3dNDCRx/PJxu774LlH8lCOlB4hEfKg==}
unrs-resolver@file:packages/unrs-resolver:
resolution: {directory: packages/unrs-resolver, type: directory}
update-browserslist-db@1.1.3:
resolution: {integrity: sha512-UxhIZQ+QInVdunkDAaiazvvT/+fXL5Osr0JZlJulepYu6Jd7qJtDZjlur0emRlT71EN3ScPoE7gvsuIKKNavKw==}
......@@ -9087,12 +9113,12 @@ snapshots:
eslint: 9.31.0(jiti@2.4.2)
prettier-linter-helpers: 1.0.0
eslint-import-context@0.1.9(unrs-resolver@1.11.1):
eslint-import-context@file:packages/eslint-import-context(unrs-resolver@file:packages/unrs-resolver):
dependencies:
get-tsconfig: 4.10.1
stable-hash-x: 0.2.0
optionalDependencies:
unrs-resolver: 1.11.1
unrs-resolver: file:packages/unrs-resolver
eslint-json-compat-utils@0.2.1(eslint@9.31.0(jiti@2.4.2))(jsonc-eslint-parser@2.4.0):
dependencies:
......@@ -9140,12 +9166,12 @@ snapshots:
comment-parser: 1.4.1
debug: 4.4.1
eslint: 9.31.0(jiti@2.4.2)
eslint-import-context: 0.1.9(unrs-resolver@1.11.1)
eslint-import-context: file:packages/eslint-import-context(unrs-resolver@file:packages/unrs-resolver)
is-glob: 4.0.3
minimatch: 10.0.3
semver: 7.7.2
stable-hash-x: 0.2.0
unrs-resolver: 1.11.1
unrs-resolver: file:packages/unrs-resolver
optionalDependencies:
'@typescript-eslint/utils': 8.38.0(eslint@9.31.0(jiti@2.4.2))(typescript@5.8.3)
transitivePeerDependencies:
......@@ -11536,7 +11562,7 @@ snapshots:
unpipe@1.0.0: {}
unrs-resolver@1.11.1:
unrs-resolver@file:packages/unrs-resolver:
dependencies:
napi-postinstall: 0.3.2
optionalDependencies:
......
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
'animate-spotlight': string
'animateSpotlight': string
'gradientBackground': string
'spotlight': string
'animate-spotlight': string;
animateSpotlight: string;
gradientBackground: string;
spotlight: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
g1: string
g2: string
g3: string
gradientsBallContainer: string
g1: string;
g2: string;
g3: string;
gradientsBallContainer: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
layoutContent: string
layoutMain: string
sidebarArrow: string
layoutContent: string;
layoutMain: string;
sidebarArrow: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
layoutNavBarAgent: string
open: string
sidebarAction: string
layoutNavBarAgent: string;
open: string;
sidebarAction: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
navBarDivider: string
navBarDivider: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
NavBarItem: string
icon: string
label: string
navBarItem: string
NavBarItem: string;
icon: string;
label: string;
navBarItem: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
chatPage: string
content: string
inter: string
scrollView: string
scrollable: string
chatPage: string;
content: string;
inter: string;
scrollView: string;
scrollable: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
collectPage: string
collectScrollable: string
content: string
inter: string
scrollView: string
collectPage: string;
collectScrollable: string;
content: string;
inter: string;
scrollView: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
homePage: string
homePage: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
......@@ -103,7 +103,7 @@ export const Home: React.FC = () => {
configTypeList: ['06', '07'],
}
const res = await fetchQuestionList(param)
if (res.ok) {
if (res && res.ok) {
for (let index = 0; index < res.data.length; index++) {
const element = res.data[index]
if (element.configType === '06') {
......
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
protocolPage: string
protocolPage: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
// This file is automatically generated.
// Please do not change this file!
interface CssExports {
toolsPage: string
toolsPage: string;
}
declare const cssExports: CssExports
export default cssExports
declare const cssExports: CssExports;
export default cssExports;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment