Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(infra): use import type #7099

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
"linter": {
"enabled": true,
"rules": {
"recommended": false
"recommended": false,
"style": {
"useImportType": "error",
"useExportType": "error"
}
},
"ignore": ["tests/**/*", "crates/**/*", "diff.bundle.js"]
},
Expand All @@ -40,4 +44,4 @@
"clientKind": "git",
"useIgnoreFile": true
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"format-ci:toml": "npx @taplo/cli format --check '.cargo/*.toml' './crates/**/Cargo.toml' './Cargo.toml'",
"format:toml": "npx @taplo/cli format '.cargo/*.toml' './crates/**/Cargo.toml' './Cargo.toml'",
"lint:js": "pnpm run lint-ci:js --write",
"lint-ci:js": "biome check",
"lint-ci:js": "biome check --diagnostic-level=warn",
"lint:rs": "node ./scripts/check_rust_dependency.cjs",
"build:binding:debug": "pnpm --filter @rspack/binding run build:debug",
"build:binding:release": "pnpm --filter @rspack/binding run build:release",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-rspack/template-vue-ts/src/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module "*.vue" {
import { DefineComponent } from "vue";
import type { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}
2 changes: 1 addition & 1 deletion packages/playground/fixtures/fileAction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import fs from "fs-extra";
import { Fixtures } from "@playwright/test";
import type { Fixtures } from "@playwright/test";
import type { RspackFixtures } from "./rspack";

type FileAction = {
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/fixtures/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test as base, expect } from "@playwright/test";
import { pathInfoFixtures } from "./pathInfo";
import { rspackFixtures, RspackOptions } from "./rspack";
import { rspackFixtures, type RspackOptions } from "./rspack";
import { fileActionFixtures } from "./fileAction";

const test = base
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/fixtures/pathInfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import fs from "fs-extra";
import { Fixtures } from "@playwright/test";
import type { Fixtures } from "@playwright/test";

type PathInfo = {
testFile: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/playground/fixtures/rspack.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import { Fixtures, PlaywrightTestArgs } from "@playwright/test";
import { Compiler, Configuration, rspack } from "@rspack/core";
import type { Fixtures, PlaywrightTestArgs } from "@playwright/test";
import { type Compiler, type Configuration, rspack } from "@rspack/core";
import { RspackDevServer } from "@rspack/dev-server";
import WebpackDevServer from "webpack-dev-server";
import type { PathInfoFixtures } from "./pathInfo";
Expand Down
16 changes: 8 additions & 8 deletions packages/rspack-cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import path from "path";
import util from "util";
import type { RspackPluginFunction, RspackPluginInstance } from "@rspack/core";
import {
Compiler,
MultiCompiler,
MultiRspackOptions,
MultiStats,
RspackOptions,
Stats,
type Compiler,
type MultiCompiler,
type MultiRspackOptions,
type MultiStats,
type RspackOptions,
type Stats,
rspack
} from "@rspack/core";
import * as rspackCore from "@rspack/core";
Expand All @@ -18,14 +18,14 @@ import { hideBin } from "yargs/helpers";
import { BuildCommand } from "./commands/build";
import { PreviewCommand } from "./commands/preview";
import { ServeCommand } from "./commands/serve";
import {
import type {
RspackBuildCLIOptions,
RspackCLIColors,
RspackCLILogger,
RspackCLIOptions
} from "./types";
import findConfig from "./utils/findConfig";
import { LoadedRspackConfig, loadRspackConfig } from "./utils/loadConfig";
import { type LoadedRspackConfig, loadRspackConfig } from "./utils/loadConfig";
import { normalizeEnv } from "./utils/options";

type Command = "serve" | "build";
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-cli/src/commands/build.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as fs from "fs";
import { MultiStats, Stats } from "@rspack/core";
import type { MultiStats, Stats } from "@rspack/core";

import type { RspackCLI } from "../cli";
import { RspackCommand } from "../types";
import type { RspackCommand } from "../types";
import {
commonOptions,
ensureEnvObject,
Expand Down
8 changes: 4 additions & 4 deletions packages/rspack-cli/src/commands/preview.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import path from "path";
import {
DevServer,
MultiRspackOptions,
RspackOptions,
type DevServer,
type MultiRspackOptions,
type RspackOptions,
rspack
} from "@rspack/core";

import type { RspackCLI } from "../cli";
import { RspackCommand, RspackPreviewCLIOptions } from "../types";
import type { RspackCommand, RspackPreviewCLIOptions } from "../types";
import { previewOptions } from "../utils/options";

const defaultRoot = "dist";
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-cli/src/commands/serve.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Compiler, DevServer } from "@rspack/core";
import type { Compiler, DevServer } from "@rspack/core";
import type { RspackDevServer as RspackDevServerType } from "@rspack/dev-server";

import type { RspackCLI } from "../cli";
import { RspackCommand } from "../types";
import type { RspackCommand } from "../types";
import {
commonOptions,
ensureEnvObject,
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-cli/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { DevServer } from "@rspack/core";
import { Colorette } from "colorette";
import type { Colorette } from "colorette";

import { RspackCLI } from "./cli";
import type { RspackCLI } from "./cli";
export type { Configuration } from "@rspack/core";

export interface IRspackCLI {
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-cli/src/utils/loadConfig.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import fs from "fs";
import path from "path";
import { MultiRspackOptions, RspackOptions } from "@rspack/core";
import type { MultiRspackOptions, RspackOptions } from "@rspack/core";
import interpret from "interpret";
import rechoir from "rechoir";

import { RspackCLIOptions } from "../types";
import type { RspackCLIOptions } from "../types";
import crossImport from "./crossImport";
import findConfig from "./findConfig";
import isEsmFile from "./isEsmFile";
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-cli/src/utils/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import yargs from "yargs";
import type yargs from "yargs";
export const commonOptions = (yargs: yargs.Argv) => {
return yargs
.options({
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-cli/src/utils/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The full syntax, remember update this when you change something in this file.
import fs from "fs";
import path from "path";
import { URLSearchParams } from "url";
import { type Compiler, RspackOptions, rspack } from "@rspack/core";
import { type Compiler, type RspackOptions, rspack } from "@rspack/core";
import inspector from "inspector";

type JSCPUProfileOptionsOutput = string;
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-dev-server/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DevServer } from "@rspack/core";
import WebpackDevServer from "webpack-dev-server";
import type WebpackDevServer from "webpack-dev-server";

export type { DevServer };

Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-dev-server/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { parse } from "url";
import type { Compiler } from "@rspack/core";
import type { RequestHandler, Response } from "express";
import mime from "mime-types";
import wdm from "webpack-dev-middleware";
import type wdm from "webpack-dev-middleware";

function etag(buf: any) {
const hash = crypto.createHash("sha256").update(buf).digest("hex");
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-dev-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import path from "node:path";
import fs from "fs";
import type { Server } from "http";
import type { Socket } from "net";
import { Compiler, MultiCompiler } from "@rspack/core";
import { type Compiler, MultiCompiler } from "@rspack/core";
import type { FSWatcher } from "chokidar";
import rdm from "webpack-dev-middleware";
import WebpackDevServer from "webpack-dev-server";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import getCurrentScriptSource from "./getCurrentScriptSource";
import { WDSMetaObj } from "./getWDSMetadata";
import type { WDSMetaObj } from "./getWDSMetadata";
export interface SocketUrlParts {
auth?: string;
hostname: string;
Expand Down
22 changes: 11 additions & 11 deletions packages/rspack-test-tools/etc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
/// <reference types="jest" />
/// <reference types="node" />

import { Compiler } from '@rspack/core';
import { Compiler as Compiler_2 } from 'webpack';
import type { Compiler } from '@rspack/core';
import type { Compiler as Compiler_2 } from 'webpack';
import type { Configuration } from 'webpack';
import EventEmitter from 'events';
import type EventEmitter from 'events';
import { IBasicGlobalContext as IBasicGlobalContext_2 } from '../type';
import { IBasicGlobalContext as IBasicGlobalContext_3 } from '../../type';
import { IBasicModuleScope as IBasicModuleScope_2 } from '../../type';
import { ITestCompilerManager as ITestCompilerManager_2 } from '../type';
import { RspackOptions } from '@rspack/core';
import { RspackOptionsNormalized } from '@rspack/core';
import { RspackPluginInstance } from '@rspack/core';
import { Stats } from '@rspack/core';
import type { RspackOptions } from '@rspack/core';
import type { RspackOptionsNormalized } from '@rspack/core';
import type { RspackPluginInstance } from '@rspack/core';
import type { Stats } from '@rspack/core';
import type { Stats as Stats_2 } from 'webpack';
import { StatsCompilation } from '@rspack/core';
import type { StatsCompilation } from '@rspack/core';
import type { StatsCompilation as StatsCompilation_2 } from 'webpack';
import { StatsError } from '@rspack/core';
import { StatsWarnings } from '@rspack/core';
import type { StatsError } from '@rspack/core';
import type { StatsWarnings } from '@rspack/core';
import { TRunnerRequirer as TRunnerRequirer_2 } from '..';
import { WebpackOptionsNormalized } from 'webpack';
import type { WebpackOptionsNormalized } from 'webpack';

// @public (undocumented)
export class BasicProcessor<T extends ECompilerType> implements ITestProcessor {
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/jest.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="jest" />

import { DiffOptions } from "jest-diff";
import type { DiffOptions } from "jest-diff";

declare interface FileMatcherOptions {
diff?: DiffOptions;
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/case/builtin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";

import { BuiltinProcessor, IBuiltinProcessorOptions } from "../processor";
import { BuiltinProcessor, type IBuiltinProcessorOptions } from "../processor";
import { BasicCaseCreator } from "../test/creator";
import { ECompilerType } from "../type";

Expand Down
5 changes: 4 additions & 1 deletion packages/rspack-test-tools/src/case/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ISimpleProcessorOptions, SimpleTaskProcessor } from "../processor";
import {
type ISimpleProcessorOptions,
SimpleTaskProcessor
} from "../processor";
import { getSimpleProcessorRunner } from "../test/simple";
import { ECompilerType } from "../type";

Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/case/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ConfigProcessor } from "../processor/config";
import { MultipleRunnerFactory } from "../runner";
import { BasicCaseCreator } from "../test/creator";
import { ECompilerType, TTestConfig } from "../type";
import { ECompilerType, type TTestConfig } from "../type";

export type TConfigCaseConfig = Omit<
TTestConfig<ECompilerType.Rspack>,
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-test-tools/src/case/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import path from "path";

import {
DefaultsConfigProcessor,
IDefaultsConfigProcessorOptions
type IDefaultsConfigProcessorOptions
} from "../processor";
import { TestContext } from "../test/context";
import { ECompilerType, ITestProcessor } from "../type";
import { ECompilerType, type ITestProcessor } from "../type";

export type TDefaultsCaseConfig = Omit<
IDefaultsConfigProcessorOptions<ECompilerType.Rspack>,
Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-test-tools/src/case/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import fs from "fs-extra";
import rimraf from "rimraf";

import createLazyTestEnv from "../helper/legacy/createLazyTestEnv";
import { DiffProcessor, IDiffProcessorOptions } from "../processor";
import { DiffProcessor, type IDiffProcessorOptions } from "../processor";
import { Tester } from "../test/tester";
import { ECompareResultType, TModuleCompareResult } from "../type";
import { ECompareResultType, type TModuleCompareResult } from "../type";

export type TDiffCaseConfig = IDiffProcessorOptions;

Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/case/error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ErrorProcessor, IErrorProcessorOptions } from "../processor";
import { ErrorProcessor, type IErrorProcessorOptions } from "../processor";
import { getSimpleProcessorRunner } from "../test/simple";
import { ECompilerType } from "../type";

Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/case/hash.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HashProcessor } from "../processor";
import { BasicCaseCreator } from "../test/creator";
import { ECompilerType, ITester, TTestConfig } from "../type";
import { ECompilerType, type ITester, type TTestConfig } from "../type";

export type THashCaseConfig = Pick<
TTestConfig<ECompilerType.Rspack>,
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/case/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import createLazyTestEnv from "../helper/legacy/createLazyTestEnv";
import {
HookCasesContext,
HookTaskProcessor,
IHookProcessorOptions
type IHookProcessorOptions
} from "../processor";
import { BasicRunnerFactory } from "../runner";
import { getSimpleProcessorRunner } from "../test/simple";
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/case/hot-step.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HotSnapshotProcessor } from "../processor/hot-step";
import { HotStepRunnerFactory } from "../runner";
import { BasicCaseCreator } from "../test/creator";
import { ECompilerType, TCompilerOptions } from "../type";
import { ECompilerType, type TCompilerOptions } from "../type";

type TTarget = TCompilerOptions<ECompilerType.Rspack>["target"];

Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/case/hot.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HotProcessor } from "../processor/hot";
import { HotRunnerFactory } from "../runner";
import { BasicCaseCreator } from "../test/creator";
import { ECompilerType, TCompilerOptions } from "../type";
import { ECompilerType, type TCompilerOptions } from "../type";

type TTarget = TCompilerOptions<ECompilerType.Rspack>["target"];

Expand Down
5 changes: 4 additions & 1 deletion packages/rspack-test-tools/src/case/stats-api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { IStatsAPIProcessorOptions, StatsAPIProcessor } from "../processor";
import {
type IStatsAPIProcessorOptions,
StatsAPIProcessor
} from "../processor";
import { getSimpleProcessorRunner } from "../test/simple";
import { ECompilerType } from "../type";

Expand Down
4 changes: 2 additions & 2 deletions packages/rspack-test-tools/src/compare/comparator.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import path from "path";
import deepmerge from "deepmerge";

import { ITestReporter, TCompareModules } from "../type";
import type { ITestReporter, TCompareModules } from "../type";
import { compareFile } from "./compare";
import { IFormatCodeOptions } from "./format-code";
import type { IFormatCodeOptions } from "./format-code";
import { replaceRuntimeModuleName } from "./replace-runtime-module-name";

export interface IDiffComparatorOptions {
Expand Down
10 changes: 5 additions & 5 deletions packages/rspack-test-tools/src/compare/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { diffLinesRaw, diffStringsUnified } from "jest-diff";
import { parseModules } from "../helper";
import {
ECompareResultType,
TCompareModules,
TCompareResult,
TFileCompareResult,
TModuleCompareResult
type TCompareModules,
type TCompareResult,
type TFileCompareResult,
type TModuleCompareResult
} from "../type";
import { IFormatCodeOptions, formatCode } from "./format-code";
import { type IFormatCodeOptions, formatCode } from "./format-code";
import { replaceRuntimeModuleName } from "./replace-runtime-module-name";

export interface ICompareOptions {
Expand Down
Loading
Loading