@rsbuild/shared
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,2 +0,2 @@ | ||
import type { BundlerChain, RspackConfig, RsbuildConfig, RsbuildContext, CreateAsyncHook, BundlerChainRule, NormalizedConfig, RsbuildPluginAPI, ModifyBundlerChainFn, ModifyBundlerChainUtils } from './types'; | ||
import type { BundlerChain, RspackConfig, RsbuildConfig, RsbuildContext, CreateAsyncHook, BundlerChainRule, NormalizedConfig, RsbuildPluginAPI, ModifyBundlerChainFn, ModifyBundlerChainUtils, BuiltinSwcLoaderOptions } from './types'; | ||
export declare function getBundlerChain(): Promise<BundlerChain>; | ||
@@ -157,2 +157,4 @@ export declare function modifyBundlerChain(context: RsbuildContext & { | ||
readonly VUE_LOADER_PLUGIN: "vue-loader-plugin"; | ||
/** PreactRefreshPlugin */ | ||
readonly PREACT_REFRESH: "preact-refresh"; | ||
/** ReactFastRefreshPlugin */ | ||
@@ -201,1 +203,5 @@ readonly REACT_FAST_REFRESH: "react-fast-refresh"; | ||
export declare function chainToConfig(chain: BundlerChain): RspackConfig; | ||
export declare const modifySwcLoaderOptions: ({ chain, modifier, }: { | ||
chain: BundlerChain; | ||
modifier: (config: BuiltinSwcLoaderOptions) => BuiltinSwcLoaderOptions; | ||
}) => void; |
@@ -37,3 +37,4 @@ "use strict"; | ||
getBundlerChain: () => getBundlerChain, | ||
modifyBundlerChain: () => modifyBundlerChain | ||
modifyBundlerChain: () => modifyBundlerChain, | ||
modifySwcLoaderOptions: () => modifySwcLoaderOptions | ||
}); | ||
@@ -216,2 +217,4 @@ module.exports = __toCommonJS(chain_exports); | ||
VUE_LOADER_PLUGIN: "vue-loader-plugin", | ||
/** PreactRefreshPlugin */ | ||
PREACT_REFRESH: "preact-refresh", | ||
/** ReactFastRefreshPlugin */ | ||
@@ -410,2 +413,16 @@ REACT_FAST_REFRESH: "react-fast-refresh", | ||
} | ||
const modifySwcLoaderOptions = ({ | ||
chain, | ||
modifier | ||
}) => { | ||
const ruleIds = [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI]; | ||
ruleIds.forEach((ruleId) => { | ||
if (chain.module.rules.has(ruleId)) { | ||
const rule = chain.module.rule(ruleId); | ||
if (rule.uses.has(CHAIN_ID.USE.SWC)) { | ||
rule.use(CHAIN_ID.USE.SWC).tap(modifier); | ||
} | ||
} | ||
}); | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -419,3 +436,4 @@ 0 && (module.exports = { | ||
getBundlerChain, | ||
modifyBundlerChain | ||
modifyBundlerChain, | ||
modifySwcLoaderOptions | ||
}); |
@@ -1,2 +0,2 @@ | ||
import { ToolsSassConfig, ToolsLessConfig, LessLoaderOptions } from './types'; | ||
import type { ToolsSassConfig, ToolsLessConfig, LessLoaderOptions } from './types'; | ||
export declare const getSassLoaderOptions: (rsbuildSassConfig: ToolsSassConfig | undefined, isUseCssSourceMap: boolean) => { | ||
@@ -3,0 +3,0 @@ options: (Omit<import("../compiled/sass-loader/interfaces").LoaderOptions, "sassOptions"> & { |
@@ -13,3 +13,3 @@ /** | ||
import type { LoaderContext } from '@rspack/core'; | ||
import { CssLoaderModules } from '../css'; | ||
import { type CssLoaderModules } from '../css'; | ||
export declare function wrapQuotes(key: string): string; | ||
@@ -16,0 +16,0 @@ export default function (this: LoaderContext<{ |
import type { NormalizedConfig, TerserPluginOptions } from './types'; | ||
import { SwcJsMinimizerRspackPluginOptions } from '@rspack/core'; | ||
import type { SwcJsMinimizerRspackPluginOptions } from '@rspack/core'; | ||
export declare function getTerserMinifyOptions(config: NormalizedConfig): Promise<TerserPluginOptions>; | ||
export declare const getSwcMinimizerOptions: (config: NormalizedConfig) => SwcJsMinimizerRspackPluginOptions; |
@@ -1,2 +0,2 @@ | ||
import { Configuration } from '@rspack/core'; | ||
import type { Configuration } from '@rspack/core'; | ||
import type { BundleAnalyzerPlugin } from '../../../compiled/webpack-bundle-analyzer'; | ||
@@ -3,0 +3,0 @@ export type ConsoleType = 'log' | 'info' | 'warn' | 'error' | 'table' | 'group'; |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import type { IncomingMessage, ServerResponse } from 'http'; | ||
@@ -12,2 +13,7 @@ import type { ServerOptions as HttpsServerOptions } from 'https'; | ||
export type ProxyOptions = Record<string, string> | Record<string, ProxyDetail> | ProxyDetail[] | ProxyDetail; | ||
export type HistoryApiFallbackContext = { | ||
match: RegExpMatchArray; | ||
parsedUrl: import('url').Url; | ||
request: Request; | ||
}; | ||
export type HistoryApiFallbackOptions = { | ||
@@ -21,3 +27,3 @@ index?: string; | ||
from: RegExp; | ||
to: string | RegExp | Function; | ||
to: string | RegExp | ((context: HistoryApiFallbackContext) => string); | ||
}>; | ||
@@ -29,3 +35,3 @@ }; | ||
protocol: string; | ||
}) => void); | ||
}) => string[] | void); | ||
export type PublicDir = false | { | ||
@@ -32,0 +38,0 @@ /** |
import type { ChainIdentifier } from '../chain'; | ||
import type { Stats, MultiStats } from './stats'; | ||
import { NodeEnv, PromiseOrNot } from './utils'; | ||
import { RsbuildTarget } from './rsbuild'; | ||
import { BundlerChain } from './bundlerConfig'; | ||
import { mergeRsbuildConfig } from '../mergeRsbuildConfig'; | ||
import type { NodeEnv, PromiseOrNot } from './utils'; | ||
import type { RsbuildTarget } from './rsbuild'; | ||
import type { BundlerChain } from './bundlerConfig'; | ||
import type { mergeRsbuildConfig } from '../mergeRsbuildConfig'; | ||
import type { Rspack, RspackConfig } from './rspack'; | ||
@@ -8,0 +8,0 @@ import type { RsbuildConfig } from './config'; |
import type { Falsy, WebpackChain } from './utils'; | ||
import type { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterStartProdServerFn, OnBeforeStartProdServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn, ModifyRsbuildConfigFn, ModifyBundlerChainFn, ModifyChainUtils } from './hooks'; | ||
import type { RsbuildContext } from './context'; | ||
import { RsbuildConfig, NormalizedConfig, ModifyRspackConfigUtils } from './config'; | ||
import type { RsbuildConfig, NormalizedConfig, ModifyRspackConfigUtils } from './config'; | ||
import type { PromiseOrNot } from './utils'; | ||
@@ -49,3 +49,3 @@ import type { RspackConfig } from './rspack'; | ||
export type RsbuildPlugins = (RsbuildPlugin | Falsy)[]; | ||
type PluginsFn<T = void> = T extends void ? () => Promise<RsbuildPlugin> : (arg: T) => Promise<RsbuildPlugin>; | ||
type PluginsFn<T = undefined> = T extends undefined ? () => Promise<RsbuildPlugin> : (arg: T) => Promise<RsbuildPlugin>; | ||
export type Plugins = { | ||
@@ -52,0 +52,0 @@ basic: PluginsFn; |
@@ -5,5 +5,5 @@ /// <reference types="node" /> | ||
import type { Socket } from 'net'; | ||
import { DevConfig, NextFunction, RequestHandler, ServerAPIs } from './config/dev'; | ||
import { ServerConfig } from './config/server'; | ||
import { Routes } from './hooks'; | ||
import type { DevConfig, NextFunction, RequestHandler, ServerAPIs } from './config/dev'; | ||
import type { ServerConfig } from './config/server'; | ||
import type { Routes } from './hooks'; | ||
import type { RspackCompiler, RspackMultiCompiler } from './rspack'; | ||
@@ -10,0 +10,0 @@ export type Middleware = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => Promise<void>; |
@@ -7,2 +7,3 @@ export declare const normalizeUrl: (url: string) => string; | ||
}; | ||
export declare const getUrlLabel: (url: string) => "Local: " | "Network: "; | ||
export declare const getAddressUrls: ({ protocol, port, host, }: { | ||
@@ -9,0 +10,0 @@ protocol?: string | undefined; |
@@ -32,2 +32,3 @@ "use strict"; | ||
getAddressUrls: () => getAddressUrls, | ||
getUrlLabel: () => getUrlLabel, | ||
normalizeUrl: () => normalizeUrl, | ||
@@ -92,2 +93,12 @@ withPublicPath: () => withPublicPath | ||
}) => `${protocol}://${host}:${port}`; | ||
const LOCAL_LABEL = "Local: "; | ||
const NETWORK_LABEL = "Network: "; | ||
const getUrlLabel = (url) => { | ||
try { | ||
const { host } = new import_url.URL(url); | ||
return isLoopbackHost(host) ? LOCAL_LABEL : NETWORK_LABEL; | ||
} catch (err) { | ||
return NETWORK_LABEL; | ||
} | ||
}; | ||
const getAddressUrls = ({ | ||
@@ -98,4 +109,2 @@ protocol = "http", | ||
}) => { | ||
const LOCAL_LABEL = "Local: "; | ||
const NETWORK_LABEL = "Network: "; | ||
if (host && host !== import_constants.DEFAULT_DEV_HOST) { | ||
@@ -130,4 +139,5 @@ return [ | ||
getAddressUrls, | ||
getUrlLabel, | ||
normalizeUrl, | ||
withPublicPath | ||
}); |
{ | ||
"name": "@rsbuild/shared", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "The internal shared modules and dependencies of Rsbuild.", | ||
@@ -54,2 +54,10 @@ "homepage": "https://rsbuild.dev", | ||
}, | ||
"./mime-types": { | ||
"types": "./compiled/mime-types/index.d.ts", | ||
"default": "./compiled/mime-types/index.js" | ||
}, | ||
"./loader-utils2": { | ||
"types": "./compiled/loader-utils2/index.d.ts", | ||
"default": "./compiled/loader-utils2/index.js" | ||
}, | ||
"./webpack-sources": { | ||
@@ -56,0 +64,0 @@ "types": "./compiled/webpack-sources/index.d.ts", |
7748474
23286