Skip to content
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
4 changes: 2 additions & 2 deletions e2e/cases/plugin-api/plugin-on-exit-hook/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ test('should run onExit hook before process exit', async () => {
expect(fs.readFileSync(distFile, 'utf-8')).toEqual('0');
clearTimeout(timeoutId);
resolve();
} catch (err) {
} catch (error) {
clearTimeout(timeoutId);
reject(err);
reject(error as Error);
}
},
);
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/client/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ declare const RSPACK_INTERCEPT_MODULE_EXECUTION: ((options: {

const getErrorField = (
error: unknown,
field: keyof Error,
field: 'message' | 'name' | 'stack',
): string | undefined => {
if (error instanceof Error) {
const value = error[field];
return value === undefined ? undefined : String(value);
return error[field];
Comment thread
chenjiahan marked this conversation as resolved.
}
};

Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/plugins/rspackProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { rspack } from '@rspack/core';
import { color } from '../helpers';
import type { RsbuildPlugin } from '../types';

enum TracePreset {
OVERVIEW = 'OVERVIEW', // contains overview trace events
ALL = 'ALL', // contains all trace events
}
const TRACE_PRESET = {
OVERVIEW: 'OVERVIEW', // contains overview trace events
ALL: 'ALL', // contains all trace events
} as const;

type TraceLayer = 'perfetto' | 'logger';

Expand All @@ -22,10 +22,10 @@ function resolveLayer(value: string): string {
const overviewTraceFilter = 'info';
const allTraceFilter = 'trace';

if (value === TracePreset.OVERVIEW) {
if (value === TRACE_PRESET.OVERVIEW) {
return overviewTraceFilter;
}
if (value === TracePreset.ALL) {
if (value === TRACE_PRESET.ALL) {
return allTraceFilter;
}

Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/server/runner/cjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ export class CommonJsRunner extends BasicRunner {
protected createGlobalContext(): BasicGlobalContext {
return {
console: console,
setTimeout: ((...args: Parameters<typeof setTimeout>) => {
const timeout = setTimeout(...args);
setTimeout: ((
callback: (...args: unknown[]) => void,
delay?: number,
...args: unknown[]
) => {
const timeout = setTimeout(callback, delay, ...args);
timeout.unref();
return timeout;
}) as typeof setTimeout,
Expand Down Expand Up @@ -107,6 +111,7 @@ export class CommonJsRunner extends BasicRunner {
const args = Object.keys(currentModuleScope);
const argValues = args.map((arg) => currentModuleScope[arg]);
this.preExecute(file.content, file);
// rslint-disable-next-line @typescript-eslint/no-implied-eval -- Evaluate import() in the main context instead of the VM context.
const dynamicImport = new Function(
'specifier',
'return import(specifier)',
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/server/runner/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type RunnerRequirer = (
file?: BasicRunnerFile;
esmMode?: EsmMode;
},
) => unknown | Promise<unknown>;
) => unknown;

export type BasicRunnerFile = {
path: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export type ToolsBundlerChainConfig = OneOrMany<

export type ToolsPostCSSContext = {
addPlugins: (
plugins: LoosePostCSSPlugin | LoosePostCSSPlugin[],
plugins: OneOrMany<LoosePostCSSPlugin>,
options?: {
/**
* Controls where the plugin is placed relative to the existing PostCSS plugins.
Expand Down
6 changes: 0 additions & 6 deletions rstack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ define.lint(async ({ globalIgnores, js, ts }) => {
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
Expand Down