From 856ac99d88d6d6b9122b1eab2194e87fefe12cb4 Mon Sep 17 00:00:00 2001 From: Hana Date: Wed, 18 Dec 2024 14:34:24 +0800 Subject: [PATCH] refactor: merge binding crates into `rspack_binding_values` --- .github/CODEOWNERS | 1 - .github/workflows/ci.yml | 4 +- Cargo.lock | 29 +- Cargo.toml | 1 - crates/node_binding/Cargo.toml | 4 +- crates/node_binding/binding.d.ts | 1020 ++++++++++++++++- crates/node_binding/src/lib.rs | 4 +- crates/rspack_binding_options/Cargo.toml | 83 -- crates/rspack_binding_options/LICENSE | 22 - crates/rspack_binding_options/src/lib.rs | 7 - crates/rspack_binding_values/Cargo.toml | 92 +- crates/rspack_binding_values/src/lib.rs | 7 + .../src/plugins/buildtime_plugins.rs | 0 .../src/plugins/context_replacement.rs | 0 .../src/plugins/js_loader/context.rs | 2 +- .../src/plugins/js_loader/mod.rs | 0 .../src/plugins/js_loader/resolver.rs | 0 .../src/plugins/js_loader/scheduler.rs | 0 .../src/plugins/mod.rs | 0 .../src/raw_options}/mod.rs | 3 +- .../src/raw_options}/raw_builtins/mod.rs | 2 +- .../raw_options}/raw_builtins/raw_banner.rs | 2 +- .../raw_builtins/raw_bundle_info.rs | 0 .../src/raw_options}/raw_builtins/raw_copy.rs | 0 .../raw_builtins/raw_css_extract.rs | 2 +- .../src/raw_options}/raw_builtins/raw_dll.rs | 2 +- .../src/raw_options}/raw_builtins/raw_html.rs | 0 .../src/raw_options}/raw_builtins/raw_ids.rs | 0 .../raw_options}/raw_builtins/raw_ignore.rs | 0 .../raw_builtins/raw_lazy_compilation.rs | 2 +- .../raw_lightning_css_minimizer.rs | 2 +- .../raw_builtins/raw_limit_chunk_count.rs | 0 .../src/raw_options}/raw_builtins/raw_mf.rs | 2 +- .../raw_options}/raw_builtins/raw_progress.rs | 0 .../raw_builtins/raw_runtime_chunk.rs | 0 .../raw_builtins/raw_size_limits.rs | 0 .../raw_builtins/raw_swc_js_minimizer.rs | 2 +- .../src/raw_options}/raw_cache.rs | 0 .../src/raw_options}/raw_devtool.rs | 2 +- .../src/raw_options}/raw_dynamic_entry.rs | 2 +- .../src/raw_options}/raw_experiments/mod.rs | 0 .../raw_experiments/raw_cache/mod.rs | 0 .../raw_experiments/raw_cache/raw_snapshot.rs | 0 .../raw_experiments/raw_cache/raw_storage.rs | 0 .../raw_experiments/raw_incremental.rs | 0 .../raw_experiments/raw_rspack_future.rs | 0 .../src/raw_options}/raw_external.rs | 3 +- .../src/raw_options}/raw_mode.rs | 0 .../src/raw_options}/raw_module/mod.rs | 2 +- .../src/raw_options}/raw_node.rs | 0 .../src/raw_options}/raw_optimization.rs | 0 .../src/raw_options}/raw_output.rs | 4 +- .../src/raw_options}/raw_snapshot.rs | 0 .../src/raw_options}/raw_split_chunks/mod.rs | 0 .../raw_split_chunk_cache_group_test.rs | 2 +- .../raw_split_chunk_chunks.rs | 2 +- .../raw_split_chunks/raw_split_chunk_name.rs | 2 +- .../raw_split_chunks/raw_split_chunk_size.rs | 0 .../src/raw_options}/raw_stats.rs | 0 crates/rspack_tracing/src/lib.rs | 2 +- .../cases/loaders/cjs-loader-type/index.js | 2 +- 61 files changed, 1133 insertions(+), 185 deletions(-) delete mode 100644 crates/rspack_binding_options/Cargo.toml delete mode 100644 crates/rspack_binding_options/LICENSE delete mode 100644 crates/rspack_binding_options/src/lib.rs rename crates/{rspack_binding_options => rspack_binding_values}/src/plugins/buildtime_plugins.rs (100%) rename crates/{rspack_binding_options => rspack_binding_values}/src/plugins/context_replacement.rs (100%) rename crates/{rspack_binding_options => rspack_binding_values}/src/plugins/js_loader/context.rs (98%) rename crates/{rspack_binding_options => rspack_binding_values}/src/plugins/js_loader/mod.rs (100%) rename crates/{rspack_binding_options => rspack_binding_values}/src/plugins/js_loader/resolver.rs (100%) rename crates/{rspack_binding_options => rspack_binding_values}/src/plugins/js_loader/scheduler.rs (100%) rename crates/{rspack_binding_options => rspack_binding_values}/src/plugins/mod.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/mod.rs (98%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/mod.rs (99%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_banner.rs (96%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_bundle_info.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_copy.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_css_extract.rs (96%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_dll.rs (98%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_html.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_ids.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_ignore.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_lazy_compilation.rs (98%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_lightning_css_minimizer.rs (98%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_limit_chunk_count.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_mf.rs (99%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_progress.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_runtime_chunk.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_size_limits.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_builtins/raw_swc_js_minimizer.rs (97%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_cache.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_devtool.rs (98%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_dynamic_entry.rs (96%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_experiments/mod.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_experiments/raw_cache/mod.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_experiments/raw_cache/raw_snapshot.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_experiments/raw_cache/raw_storage.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_experiments/raw_incremental.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_experiments/raw_rspack_future.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_external.rs (99%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_mode.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_module/mod.rs (99%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_node.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_optimization.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_output.rs (98%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_snapshot.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_split_chunks/mod.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_split_chunks/raw_split_chunk_cache_group_test.rs (96%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_split_chunks/raw_split_chunk_chunks.rs (95%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_split_chunks/raw_split_chunk_name.rs (96%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_split_chunks/raw_split_chunk_size.rs (100%) rename crates/{rspack_binding_options/src/options => rspack_binding_values/src/raw_options}/raw_stats.rs (100%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 27cb3dd6eab..670dbc46baf 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -28,7 +28,6 @@ pnpm-lock.yaml /crates/node_binding /crates/rspack_ast_viewer /crates/rspack_base64 -/crates/rspack_binding_options /crates/rspack_core /crates/rspack_core/src/compiler/make @jerrykingxyz /crates/rspack_error diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 753cda6ad7b..0b59b261336 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -319,7 +319,7 @@ jobs: - name: Run test # reason for excluding https://github.com/napi-rs/napi-rs/issues/2200 - run: cargo test --workspace --exclude rspack_binding_options --exclude rspack_node -- --nocapture + run: cargo test --workspace --exclude rspack_node -- --nocapture rust_test_miri: name: Rust test miri @@ -350,7 +350,7 @@ jobs: env: MIRIFLAGS: -Zmiri-tree-borrows -Zmiri-disable-isolation # reason for excluding https://github.com/napi-rs/napi-rs/issues/2200 - run: cargo miri test --workspace --exclude rspack_binding_options --exclude rspack_node -- --nocapture + run: cargo miri test --workspace --exclude rspack_node -- --nocapture run_rust_benchmark: name: Run rust benchmark diff --git a/Cargo.lock b/Cargo.lock index 6197967da4d..2ff53cffb1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3701,17 +3701,18 @@ dependencies = [ ] [[package]] -name = "rspack_binding_options" +name = "rspack_binding_values" version = "0.2.0" dependencies = [ "async-trait", "cow-utils", "derive_more", + "futures", "glob", + "heck 0.5.0", "napi", "napi-derive", "pollster", - "rspack_binding_values", "rspack_cacheable", "rspack_collections", "rspack_core", @@ -3766,6 +3767,7 @@ dependencies = [ "rspack_plugin_web_worker_template", "rspack_plugin_worker", "rspack_regex", + "rspack_util", "rustc-hash 2.1.0", "serde", "serde_json", @@ -3774,28 +3776,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "rspack_binding_values" -version = "0.2.0" -dependencies = [ - "cow-utils", - "futures", - "heck 0.5.0", - "napi", - "napi-derive", - "rspack_collections", - "rspack_core", - "rspack_error", - "rspack_napi", - "rspack_plugin_html", - "rspack_plugin_runtime", - "rspack_regex", - "rspack_util", - "rustc-hash 2.1.0", - "serde", - "serde_json", -] - [[package]] name = "rspack_cacheable" version = "0.2.0" @@ -4160,7 +4140,6 @@ dependencies = [ "napi-derive", "ropey", "rspack_allocator", - "rspack_binding_options", "rspack_binding_values", "rspack_collections", "rspack_core", diff --git a/Cargo.toml b/Cargo.toml index 85747ead490..9d269bbdeef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,7 +110,6 @@ rspack_allocator = { version = "0.2.0", path = "crates/rsp rspack_ast = { version = "0.2.0", path = "crates/rspack_ast" } rspack_base64 = { version = "0.2.0", path = "crates/rspack_base64" } rspack_binding = { version = "0.2.0", path = "crates/rspack_binding" } -rspack_binding_options = { version = "0.2.0", path = "crates/rspack_binding_options" } rspack_binding_values = { version = "0.2.0", path = "crates/rspack_binding_values" } rspack_builtin = { version = "0.2.0", path = "crates/rspack_builtin" } rspack_cacheable = { version = "0.2.0", path = "crates/rspack_cacheable" } diff --git a/crates/node_binding/Cargo.toml b/crates/node_binding/Cargo.toml index b37bc27bacb..90e99cf6e95 100644 --- a/crates/node_binding/Cargo.toml +++ b/crates/node_binding/Cargo.toml @@ -10,13 +10,11 @@ version = "0.2.0" crate-type = ["cdylib"] [features] -default = [] -plugin = ["rspack_binding_options/plugin"] +plugin = ["rspack_binding_values/plugin"] [dependencies] ropey = { workspace = true } rspack_allocator = { workspace = true } -rspack_binding_options = { workspace = true } rspack_binding_values = { workspace = true } rspack_collections = { workspace = true } rspack_core = { workspace = true } diff --git a/crates/node_binding/binding.d.ts b/crates/node_binding/binding.d.ts index 36af31a5e85..79f3298470a 100644 --- a/crates/node_binding/binding.d.ts +++ b/crates/node_binding/binding.d.ts @@ -258,9 +258,15 @@ export declare class JsStats { getLogging(acceptedTypes: number): Array } +export declare class RawExternalItemFnCtx { + +} + export declare class RawExternalItemFnCtx { data(): RawExternalItemFnCtxData getResolver(): JsResolver + data(): RawExternalItemFnCtxData + getResolver(): JsResolver } export declare class Rspack { @@ -278,6 +284,92 @@ export interface BuiltinPlugin { canInherentFromParent?: boolean } +export interface BuiltinPlugin { + name: BuiltinPluginName + options: unknown + canInherentFromParent?: boolean +} + +export declare enum BuiltinPluginName { + DefinePlugin = 'DefinePlugin', + ProvidePlugin = 'ProvidePlugin', + BannerPlugin = 'BannerPlugin', + IgnorePlugin = 'IgnorePlugin', + ProgressPlugin = 'ProgressPlugin', + EntryPlugin = 'EntryPlugin', + DynamicEntryPlugin = 'DynamicEntryPlugin', + ExternalsPlugin = 'ExternalsPlugin', + NodeTargetPlugin = 'NodeTargetPlugin', + ElectronTargetPlugin = 'ElectronTargetPlugin', + EnableChunkLoadingPlugin = 'EnableChunkLoadingPlugin', + EnableLibraryPlugin = 'EnableLibraryPlugin', + EnableWasmLoadingPlugin = 'EnableWasmLoadingPlugin', + FetchCompileAsyncWasmPlugin = 'FetchCompileAsyncWasmPlugin', + ChunkPrefetchPreloadPlugin = 'ChunkPrefetchPreloadPlugin', + CommonJsChunkFormatPlugin = 'CommonJsChunkFormatPlugin', + ArrayPushCallbackChunkFormatPlugin = 'ArrayPushCallbackChunkFormatPlugin', + ModuleChunkFormatPlugin = 'ModuleChunkFormatPlugin', + HotModuleReplacementPlugin = 'HotModuleReplacementPlugin', + LimitChunkCountPlugin = 'LimitChunkCountPlugin', + WorkerPlugin = 'WorkerPlugin', + WebWorkerTemplatePlugin = 'WebWorkerTemplatePlugin', + MergeDuplicateChunksPlugin = 'MergeDuplicateChunksPlugin', + SplitChunksPlugin = 'SplitChunksPlugin', + RemoveDuplicateModulesPlugin = 'RemoveDuplicateModulesPlugin', + ShareRuntimePlugin = 'ShareRuntimePlugin', + ContainerPlugin = 'ContainerPlugin', + ContainerReferencePlugin = 'ContainerReferencePlugin', + ProvideSharedPlugin = 'ProvideSharedPlugin', + ConsumeSharedPlugin = 'ConsumeSharedPlugin', + ModuleFederationRuntimePlugin = 'ModuleFederationRuntimePlugin', + NamedModuleIdsPlugin = 'NamedModuleIdsPlugin', + NaturalModuleIdsPlugin = 'NaturalModuleIdsPlugin', + DeterministicModuleIdsPlugin = 'DeterministicModuleIdsPlugin', + NaturalChunkIdsPlugin = 'NaturalChunkIdsPlugin', + NamedChunkIdsPlugin = 'NamedChunkIdsPlugin', + DeterministicChunkIdsPlugin = 'DeterministicChunkIdsPlugin', + OccurrenceChunkIdsPlugin = 'OccurrenceChunkIdsPlugin', + RealContentHashPlugin = 'RealContentHashPlugin', + RemoveEmptyChunksPlugin = 'RemoveEmptyChunksPlugin', + EnsureChunkConditionsPlugin = 'EnsureChunkConditionsPlugin', + WarnCaseSensitiveModulesPlugin = 'WarnCaseSensitiveModulesPlugin', + DataUriPlugin = 'DataUriPlugin', + FileUriPlugin = 'FileUriPlugin', + RuntimePlugin = 'RuntimePlugin', + JsonModulesPlugin = 'JsonModulesPlugin', + InferAsyncModulesPlugin = 'InferAsyncModulesPlugin', + JavascriptModulesPlugin = 'JavascriptModulesPlugin', + AsyncWebAssemblyModulesPlugin = 'AsyncWebAssemblyModulesPlugin', + AssetModulesPlugin = 'AssetModulesPlugin', + SourceMapDevToolPlugin = 'SourceMapDevToolPlugin', + EvalSourceMapDevToolPlugin = 'EvalSourceMapDevToolPlugin', + EvalDevToolModulePlugin = 'EvalDevToolModulePlugin', + SideEffectsFlagPlugin = 'SideEffectsFlagPlugin', + FlagDependencyExportsPlugin = 'FlagDependencyExportsPlugin', + FlagDependencyUsagePlugin = 'FlagDependencyUsagePlugin', + MangleExportsPlugin = 'MangleExportsPlugin', + ModuleConcatenationPlugin = 'ModuleConcatenationPlugin', + CssModulesPlugin = 'CssModulesPlugin', + APIPlugin = 'APIPlugin', + RuntimeChunkPlugin = 'RuntimeChunkPlugin', + SizeLimitsPlugin = 'SizeLimitsPlugin', + NoEmitOnErrorsPlugin = 'NoEmitOnErrorsPlugin', + ContextReplacementPlugin = 'ContextReplacementPlugin', + DllEntryPlugin = 'DllEntryPlugin', + DllReferenceAgencyPlugin = 'DllReferenceAgencyPlugin', + LibManifestPlugin = 'LibManifestPlugin', + FlagAllModulesAsUsedPlugin = 'FlagAllModulesAsUsedPlugin', + HttpExternalsRspackPlugin = 'HttpExternalsRspackPlugin', + CopyRspackPlugin = 'CopyRspackPlugin', + HtmlRspackPlugin = 'HtmlRspackPlugin', + SwcJsMinimizerRspackPlugin = 'SwcJsMinimizerRspackPlugin', + LightningCssMinimizerRspackPlugin = 'LightningCssMinimizerRspackPlugin', + BundlerInfoRspackPlugin = 'BundlerInfoRspackPlugin', + CssExtractRspackPlugin = 'CssExtractRspackPlugin', + JsLoaderRspackPlugin = 'JsLoaderRspackPlugin', + LazyCompilationPlugin = 'LazyCompilationPlugin' +} + export declare enum BuiltinPluginName { DefinePlugin = 'DefinePlugin', ProvidePlugin = 'ProvidePlugin', @@ -364,6 +456,10 @@ export interface ContextInfo { issuer: string } +export interface ContextInfo { + issuer: string +} + export declare function formatDiagnostic(diagnostic: JsDiagnostic): ExternalObject<'Diagnostic'> export interface JsAddingRuntimeModule { @@ -480,6 +576,12 @@ export interface JsBannerContentFnCtx { filename: string } +export interface JsBannerContentFnCtx { + hash: string + chunk: JsChunk + filename: string +} + export interface JsBeforeAssetTagGenerationData { assets: JsHtmlPluginAssets outputName: string @@ -521,6 +623,10 @@ export interface JsCacheGroupTestCtx { module: JsModule } +export interface JsCacheGroupTestCtx { + module: JsModule +} + export interface JsChunkAssetArgs { chunk: JsChunk filename: string @@ -537,6 +643,12 @@ export interface JsChunkOptionNameCtx { cacheGroupKey: string } +export interface JsChunkOptionNameCtx { + module: JsModule + chunks: JsChunk[] + cacheGroupKey: string +} + /** * File clean options * @@ -727,6 +839,36 @@ export interface JsLoaderContext { __internal__error?: JsRspackError } +export interface JsLoaderContext { + resourceData: Readonly + /** Will be deprecated. Use module.module_identifier instead */ + _moduleIdentifier: Readonly + _module: JsModule + hot: Readonly + /** Content maybe empty in pitching stage */ + content: null | Buffer + additionalData?: any + __internal__parseMeta: Record + sourceMap?: Buffer + cacheable: boolean + fileDependencies: Array + contextDependencies: Array + missingDependencies: Array + buildDependencies: Array + loaderItems: Array + loaderIndex: number + loaderState: Readonly + __internal__error?: JsRspackError +} + +export interface JsLoaderItem { + request: string + type: string + data: any + normalExecuted: boolean + pitchExecuted: boolean +} + export interface JsLoaderItem { request: string type: string @@ -740,6 +882,11 @@ export declare enum JsLoaderState { Normal = 'Normal' } +export declare enum JsLoaderState { + Pitching = 'Pitching', + Normal = 'Normal' +} + export interface JsModuleDescriptor { identifier: string name: string @@ -1118,11 +1265,29 @@ export interface RawAssetGeneratorDataUrlFnCtx { module: JsModule } +export interface RawAssetGeneratorDataUrlFnCtx { + filename: string + module: JsModule +} + export interface RawAssetGeneratorDataUrlOptions { encoding?: "base64" | "false" | undefined mimetype?: string } +export interface RawAssetGeneratorDataUrlOptions { + encoding?: "base64" | "false" | undefined + mimetype?: string +} + +export interface RawAssetGeneratorOptions { + emit?: boolean + filename?: JsFilename + outputPath?: JsFilename + publicPath?: "auto" | JsFilename + dataUrl?: RawAssetGeneratorDataUrlOptions | ((source: Buffer, context: RawAssetGeneratorDataUrlFnCtx) => string) +} + export interface RawAssetGeneratorOptions { emit?: boolean filename?: JsFilename @@ -1135,6 +1300,15 @@ export interface RawAssetInlineGeneratorOptions { dataUrl?: RawAssetGeneratorDataUrlOptions | ((source: Buffer, context: RawAssetGeneratorDataUrlFnCtx) => string) } +export interface RawAssetInlineGeneratorOptions { + dataUrl?: RawAssetGeneratorDataUrlOptions | ((source: Buffer, context: RawAssetGeneratorDataUrlFnCtx) => string) +} + +export interface RawAssetParserDataUrl { + type: "options" + options?: RawAssetParserDataUrlOptions +} + export interface RawAssetParserDataUrl { type: "options" options?: RawAssetParserDataUrlOptions @@ -1144,6 +1318,14 @@ export interface RawAssetParserDataUrlOptions { maxSize?: number } +export interface RawAssetParserDataUrlOptions { + maxSize?: number +} + +export interface RawAssetParserOptions { + dataUrlCondition?: RawAssetParserDataUrl +} + export interface RawAssetParserOptions { dataUrlCondition?: RawAssetParserDataUrl } @@ -1155,6 +1337,24 @@ export interface RawAssetResourceGeneratorOptions { publicPath?: "auto" | JsFilename } +export interface RawAssetResourceGeneratorOptions { + emit?: boolean + filename?: JsFilename + outputPath?: JsFilename + publicPath?: "auto" | JsFilename +} + +export interface RawBannerPluginOptions { + banner: string | ((...args: any[]) => any) + entryOnly?: boolean + footer?: boolean + raw?: boolean + stage?: number + test?: string | RegExp | (string | RegExp)[] + include?: string | RegExp | (string | RegExp)[] + exclude?: string | RegExp | (string | RegExp)[] +} + export interface RawBannerPluginOptions { banner: string | ((...args: any[]) => any) entryOnly?: boolean @@ -1172,6 +1372,36 @@ export interface RawBundlerInfoPluginOptions { force: boolean | string[] } +export interface RawBundlerInfoPluginOptions { + version: string + bundler: string + force: boolean | string[] +} + +export interface RawCacheGroupOptions { + key: string + priority?: number + test?: RegExp | string | Function + filename?: string + idHint?: string + /** What kind of chunks should be selected. */ + chunks?: RegExp | 'async' | 'initial' | 'all' + type?: RegExp | string + layer?: RegExp | string + automaticNameDelimiter?: string + minChunks?: number + minSize?: number | RawSplitChunkSizes + maxSize?: number | RawSplitChunkSizes + maxAsyncSize?: number | RawSplitChunkSizes + maxInitialSize?: number | RawSplitChunkSizes + maxAsyncRequests?: number + maxInitialRequests?: number + name?: string | false | Function + reuseExistingChunk?: boolean + enforce?: boolean + usedExports?: boolean +} + export interface RawCacheGroupOptions { key: string priority?: number @@ -1208,6 +1438,31 @@ export interface RawCacheOptions { version: string } +export interface RawCacheOptions { + type: string + maxGenerations: number + maxAge: number + profile: boolean + buildDependencies: Array + cacheDirectory: string + cacheLocation: string + name: string + version: string +} + +export interface RawConsumeOptions { + key: string + import?: string + importResolved?: string + shareKey: string + shareScope: string + requiredVersion?: string | false | undefined + packageName?: string + strictVersion: boolean + singleton: boolean + eager: boolean +} + export interface RawConsumeOptions { key: string import?: string @@ -1226,7 +1481,22 @@ export interface RawConsumeSharedPluginOptions { enhanced: boolean } -export interface RawContainerPluginOptions { +export interface RawConsumeSharedPluginOptions { + consumes: Array + enhanced: boolean +} + +export interface RawContainerPluginOptions { + name: string + shareScope: string + library: JsLibraryOptions + runtime?: false | string + filename?: string + exposes: Array + enhanced: boolean +} + +export interface RawContainerPluginOptions { name: string shareScope: string library: JsLibraryOptions @@ -1243,6 +1513,21 @@ export interface RawContainerReferencePluginOptions { enhanced: boolean } +export interface RawContainerReferencePluginOptions { + remoteType: string + remotes: Array + shareScope?: string + enhanced: boolean +} + +export interface RawContextReplacementPluginOptions { + resourceRegExp: RegExp + newContentResource?: string + newContentRecursive?: boolean + newContentRegExp?: RegExp + newContentCreateContextMap?: Record +} + export interface RawContextReplacementPluginOptions { resourceRegExp: RegExp newContentResource?: string @@ -1257,6 +1542,25 @@ export interface RawCopyGlobOptions { ignore?: Array } +export interface RawCopyGlobOptions { + caseSensitiveMatch?: boolean + dot?: boolean + ignore?: Array +} + +export interface RawCopyPattern { + from: string + to?: string | ((pathData: { context: string; absoluteFilename?: string }) => string | Promise) + context?: string + toType?: string + noErrorOnMissing: boolean + force: boolean + priority: number + globOptions: RawCopyGlobOptions + info?: RawInfo + transform?: (input: Buffer, absoluteFilename: string) => string | Buffer | Promise | Promise +} + export interface RawCopyPattern { from: string to?: string | ((pathData: { context: string; absoluteFilename?: string }) => string | Promise) @@ -1274,6 +1578,16 @@ export interface RawCopyRspackPluginOptions { patterns: Array } +export interface RawCopyRspackPluginOptions { + patterns: Array +} + +export interface RawCrossOriginLoading { + type: "bool" | "string" + stringPayload?: string + boolPayload?: boolean +} + export interface RawCrossOriginLoading { type: "bool" | "string" stringPayload?: string @@ -1287,6 +1601,17 @@ export interface RawCssAutoGeneratorOptions { esModule?: boolean } +export interface RawCssAutoGeneratorOptions { + exportsConvention?: "as-is" | "camel-case" | "camel-case-only" | "dashes" | "dashes-only" + exportsOnly?: boolean + localIdentName?: string + esModule?: boolean +} + +export interface RawCssAutoParserOptions { + namedExports?: boolean +} + export interface RawCssAutoParserOptions { namedExports?: boolean } @@ -1302,6 +1627,22 @@ export interface RawCssExtractPluginOption { pathinfo: boolean } +export interface RawCssExtractPluginOption { + filename: JsFilename + chunkFilename: JsFilename + ignoreOrder: boolean + insert?: string + attributes: Record + linkType?: string + runtime: boolean + pathinfo: boolean +} + +export interface RawCssGeneratorOptions { + exportsOnly?: boolean + esModule?: boolean +} + export interface RawCssGeneratorOptions { exportsOnly?: boolean esModule?: boolean @@ -1314,10 +1655,25 @@ export interface RawCssModuleGeneratorOptions { esModule?: boolean } +export interface RawCssModuleGeneratorOptions { + exportsConvention?: "as-is" | "camel-case" | "camel-case-only" | "dashes" | "dashes-only" + exportsOnly?: boolean + localIdentName?: string + esModule?: boolean +} + export interface RawCssModuleParserOptions { namedExports?: boolean } +export interface RawCssModuleParserOptions { + namedExports?: boolean +} + +export interface RawCssParserOptions { + namedExports?: boolean +} + export interface RawCssParserOptions { namedExports?: boolean } @@ -1332,12 +1688,30 @@ export interface RawDllEntryPluginOptions { name: string } +export interface RawDllEntryPluginOptions { + context: string + entries: Array + name: string +} + export interface RawDllManifest { content: Record name?: string type?: string } +export interface RawDllManifest { + content: Record + name?: string + type?: string +} + +export interface RawDllManifestContentItem { + buildMeta?: JsBuildMeta + exports?: string[] | true + id?: string +} + export interface RawDllManifestContentItem { buildMeta?: JsBuildMeta exports?: string[] | true @@ -1355,6 +1729,21 @@ export interface RawDllReferenceAgencyPluginOptions { manifest?: RawDllManifest } +export interface RawDllReferenceAgencyPluginOptions { + context?: string + name?: string + extensions: Array + scope?: string + sourceType?: string + type: string + content?: Record + manifest?: RawDllManifest +} + +export interface RawDraft { + customMedia: boolean +} + export interface RawDraft { customMedia: boolean } @@ -1364,6 +1753,16 @@ export interface RawDynamicEntryPluginOptions { entry: () => Promise } +export interface RawDynamicEntryPluginOptions { + context: string + entry: () => Promise +} + +export interface RawEntryDynamicResult { + import: Array + options: JsEntryOptions +} + export interface RawEntryDynamicResult { import: Array options: JsEntryOptions @@ -1375,12 +1774,28 @@ export interface RawEnvironment { nodePrefixForCoreModules?: boolean } +export interface RawEnvironment { + const?: boolean + arrowFunction?: boolean + nodePrefixForCoreModules?: boolean +} + export interface RawEvalDevToolModulePluginOptions { namespace?: string moduleFilenameTemplate?: string | ((info: RawModuleFilenameTemplateFnCtx) => string) sourceUrlComment?: string } +export interface RawEvalDevToolModulePluginOptions { + namespace?: string + moduleFilenameTemplate?: string | ((info: RawModuleFilenameTemplateFnCtx) => string) + sourceUrlComment?: string +} + +export interface RawExperimentCacheOptionsCommon { + type: "disable"|"memory" +} + export interface RawExperimentCacheOptionsCommon { type: "disable"|"memory" } @@ -1393,6 +1808,22 @@ export interface RawExperimentCacheOptionsPersistent { storage: RawStorageOptions } +export interface RawExperimentCacheOptionsPersistent { + type: "persistent" + buildDependencies: Array + version: string + snapshot: RawExperimentSnapshotOptions + storage: RawStorageOptions +} + +export interface RawExperiments { + layers: boolean + topLevelAwait: boolean + incremental?: RawIncremental + rspackFuture: RawRspackFuture + cache: RawExperimentCacheOptionsPersistent | RawExperimentCacheOptionsCommon +} + export interface RawExperiments { layers: boolean topLevelAwait: boolean @@ -1407,6 +1838,18 @@ export interface RawExperimentSnapshotOptions { managedPaths: Array } +export interface RawExperimentSnapshotOptions { + immutablePaths: Array + unmanagedPaths: Array + managedPaths: Array +} + +export interface RawExposeOptions { + key: string + name?: string + import: Array +} + export interface RawExposeOptions { key: string name?: string @@ -1420,6 +1863,18 @@ export interface RawExternalItemFnCtxData { contextInfo: ContextInfo } +export interface RawExternalItemFnCtxData { + request: string + context: string + dependencyType: string + contextInfo: ContextInfo +} + +export interface RawExternalItemFnResult { + externalType?: string + result?: string | boolean | string[] | Record +} + export interface RawExternalItemFnResult { externalType?: string result?: string | boolean | string[] | Record @@ -1430,6 +1885,20 @@ export interface RawExternalsPluginOptions { externals: (string | RegExp | Record> | ((...args: any[]) => any))[] } +export interface RawExternalsPluginOptions { + type: string + externals: (string | RegExp | Record> | ((...args: any[]) => any))[] +} + +export interface RawExternalsPresets { + node: boolean + web: boolean + electron: boolean + electronMain: boolean + electronPreload: boolean + electronRenderer: boolean +} + export interface RawExternalsPresets { node: boolean web: boolean @@ -1444,6 +1913,11 @@ export interface RawExtractComments { condition?: string } +export interface RawExtractComments { + banner?: string | boolean + condition?: string +} + export interface RawFallbackCacheGroupOptions { chunks?: RegExp | 'async' | 'initial' | 'all' minSize?: number | RawSplitChunkSizes @@ -1453,6 +1927,19 @@ export interface RawFallbackCacheGroupOptions { automaticNameDelimiter?: string } +export interface RawFallbackCacheGroupOptions { + chunks?: RegExp | 'async' | 'initial' | 'all' + minSize?: number | RawSplitChunkSizes + maxSize?: number | RawSplitChunkSizes + maxAsyncSize?: number | RawSplitChunkSizes + maxInitialSize?: number | RawSplitChunkSizes + automaticNameDelimiter?: string +} + +export interface RawFlagAllModulesAsUsedPluginOptions { + explanation: string +} + export interface RawFlagAllModulesAsUsedPluginOptions { explanation: string } @@ -1464,6 +1951,13 @@ export interface RawFuncUseCtx { issuer?: string } +export interface RawFuncUseCtx { + resource?: string + realResource?: string + resourceQuery?: string + issuer?: string +} + export interface RawGeneratorOptions { type: "asset" | "asset/inline" | "asset/resource" | "css" | "css/auto" | "css/module" asset?: RawAssetGeneratorOptions @@ -1474,6 +1968,21 @@ export interface RawGeneratorOptions { cssModule?: RawCssModuleGeneratorOptions } +export interface RawGeneratorOptions { + type: "asset" | "asset/inline" | "asset/resource" | "css" | "css/auto" | "css/module" + asset?: RawAssetGeneratorOptions + assetInline?: RawAssetInlineGeneratorOptions + assetResource?: RawAssetResourceGeneratorOptions + css?: RawCssGeneratorOptions + cssAuto?: RawCssAutoGeneratorOptions + cssModule?: RawCssModuleGeneratorOptions +} + +export interface RawHtmlRspackPluginBaseOptions { + href?: string + target?: "_self" | "_blank" | "_parent" | "_top" +} + export interface RawHtmlRspackPluginBaseOptions { href?: string target?: "_self" | "_blank" | "_parent" | "_top" @@ -1506,6 +2015,38 @@ export interface RawHtmlRspackPluginOptions { base?: RawHtmlRspackPluginBaseOptions } +export interface RawHtmlRspackPluginOptions { + /** emitted file name in output path */ + filename?: string[] + /** template html file */ + template?: string + templateFn?: (data: string) => Promise + templateContent?: string + templateParameters?: boolean | Record | ((params: string) => Promise) + /** "head", "body" or "false" */ + inject: "head" | "body" | "false" + /** path or `auto` */ + publicPath?: string + /** `blocking`, `defer`, `module` or `systemjs-module` */ + scriptLoading: "blocking" | "defer" | "module" | "systemjs-module" + /** entry_chunk_name (only entry chunks are supported) */ + chunks?: Array + excludeChunks?: Array + chunksSortMode: "auto" | "manual" + sri?: "sha256" | "sha384" | "sha512" + minify?: boolean + title?: string + favicon?: string + meta?: Record> + hash?: boolean + base?: RawHtmlRspackPluginBaseOptions +} + +export interface RawHttpExternalsRspackPluginOptions { + css: boolean + webAsync: boolean +} + export interface RawHttpExternalsRspackPluginOptions { css: boolean webAsync: boolean @@ -1517,6 +2058,29 @@ export interface RawIgnorePluginOptions { checkResource?: (resource: string, context: string) => boolean } +export interface RawIgnorePluginOptions { + resourceRegExp?: RegExp + contextRegExp?: RegExp + checkResource?: (resource: string, context: string) => boolean +} + +export interface RawIncremental { + make: boolean + inferAsyncModules: boolean + providedExports: boolean + dependenciesDiagnostics: boolean + buildChunkGraph: boolean + moduleIds: boolean + chunkIds: boolean + modulesHashes: boolean + modulesCodegen: boolean + modulesRuntimeRequirements: boolean + chunksRuntimeRequirements: boolean + chunksHashes: boolean + chunksRender: boolean + emitAssets: boolean +} + export interface RawIncremental { make: boolean inferAsyncModules: boolean @@ -1545,6 +2109,55 @@ export interface RawInfo { version?: string } +export interface RawInfo { + immutable?: boolean + minimized?: boolean + chunkHash?: Array + contentHash?: Array + development?: boolean + hotModuleReplacement?: boolean + related?: RawRelated + version?: string +} + +export interface RawJavascriptParserOptions { + dynamicImportMode?: string + dynamicImportPreload?: string + dynamicImportPrefetch?: string + dynamicImportFetchPriority?: string + url?: string + exprContextCritical?: boolean + wrappedContextCritical?: boolean + wrappedContextRegExp?: RegExp + exportsPresence?: string + importExportsPresence?: string + reexportExportsPresence?: string + strictExportPresence?: boolean + worker?: Array + overrideStrict?: string + importMeta?: boolean + /** + * This option is experimental in Rspack only and subject to change or be removed anytime. + * @experimental + */ + requireAsExpression?: boolean + /** + * This option is experimental in Rspack only and subject to change or be removed anytime. + * @experimental + */ + requireDynamic?: boolean + /** + * This option is experimental in Rspack only and subject to change or be removed anytime. + * @experimental + */ + requireResolve?: boolean + /** + * This option is experimental in Rspack only and subject to change or be removed anytime. + * @experimental + */ + importDynamic?: boolean +} + export interface RawJavascriptParserOptions { dynamicImportMode?: string dynamicImportPreload?: string @@ -1591,6 +2204,14 @@ export interface RawLazyCompilationOption { cacheable: boolean } +export interface RawLazyCompilationOption { + module: ((err: Error | null, arg: RawModuleArg) => RawModuleInfo) + test?: RawLazyCompilationTest + entries: boolean + imports: boolean + cacheable: boolean +} + export interface RawLibManifestPluginOptions { context?: string entryOnly?: boolean @@ -1600,6 +2221,27 @@ export interface RawLibManifestPluginOptions { type?: string } +export interface RawLibManifestPluginOptions { + context?: string + entryOnly?: boolean + name?: JsFilename + path: JsFilename + format?: boolean + type?: string +} + +export interface RawLightningCssBrowsers { + android?: number + chrome?: number + edge?: number + firefox?: number + ie?: number + ios_saf?: number + opera?: number + safari?: number + samsung?: number +} + export interface RawLightningCssBrowsers { android?: number chrome?: number @@ -1624,6 +2266,26 @@ export interface RawLightningCssMinimizerOptions { unusedSymbols: Array } +export interface RawLightningCssMinimizerOptions { + errorRecovery: boolean + targets?: Array + include?: number + exclude?: number + draft?: RawDraft + drafts?: RawDraft + nonStandard?: RawNonStandard + pseudoClasses?: RawLightningCssPseudoClasses + unusedSymbols: Array +} + +export interface RawLightningCssMinimizerRspackPluginOptions { + test?: string | RegExp | (string | RegExp)[] + include?: string | RegExp | (string | RegExp)[] + exclude?: string | RegExp | (string | RegExp)[] + removeUnusedLocalIdents: boolean + minimizerOptions: RawLightningCssMinimizerOptions +} + export interface RawLightningCssMinimizerRspackPluginOptions { test?: string | RegExp | (string | RegExp)[] include?: string | RegExp | (string | RegExp)[] @@ -1640,6 +2302,20 @@ export interface RawLightningCssPseudoClasses { focusWithin?: string } +export interface RawLightningCssPseudoClasses { + hover?: string + active?: string + focus?: string + focusVisible?: string + focusWithin?: string +} + +export interface RawLimitChunkCountPluginOptions { + chunkOverhead?: number + entryChunkMultiplicator?: number + maxChunks: number +} + export interface RawLimitChunkCountPluginOptions { chunkOverhead?: number entryChunkMultiplicator?: number @@ -1651,6 +2327,25 @@ export interface RawModuleArg { path: string } +export interface RawModuleArg { + module: string + path: string +} + +export interface RawModuleFilenameTemplateFnCtx { + identifier: string + shortIdentifier: string + resource: string + resourcePath: string + absoluteResourcePath: string + loaders: string + allLoaders: string + query: string + moduleId: string + hash: string + namespace: string +} + export interface RawModuleFilenameTemplateFnCtx { identifier: string shortIdentifier: string @@ -1671,6 +2366,19 @@ export interface RawModuleInfo { data: string } +export interface RawModuleInfo { + active: boolean + client: string + data: string +} + +export interface RawModuleOptions { + rules: Array + parser?: Record + generator?: Record + noParse?: string | RegExp | ((request: string) => boolean) | (string | RegExp | ((request: string) => boolean))[] +} + export interface RawModuleOptions { rules: Array parser?: Record @@ -1715,6 +2423,43 @@ export interface RawModuleRule { enforce?: 'pre' | 'post' } +export interface RawModuleRule { + /** + * A conditional match matching an absolute path + query + fragment. + * Note: + * This is a custom matching rule not initially designed by webpack. + * Only for single-threaded environment interoperation purpose. + */ + rspackResource?: RawRuleSetCondition + /** A condition matcher matching an absolute path. */ + test?: RawRuleSetCondition + include?: RawRuleSetCondition + exclude?: RawRuleSetCondition + /** A condition matcher matching an absolute path. */ + resource?: RawRuleSetCondition + /** A condition matcher against the resource query. */ + resourceQuery?: RawRuleSetCondition + resourceFragment?: RawRuleSetCondition + descriptionData?: Record + with?: Record + sideEffects?: boolean + use?: RawModuleRuleUse[] | ((arg: RawFuncUseCtx) => RawModuleRuleUse[]) + type?: string + layer?: string + parser?: RawParserOptions + generator?: RawGeneratorOptions + resolve?: RawResolveOptions + issuer?: RawRuleSetCondition + issuerLayer?: RawRuleSetCondition + dependency?: RawRuleSetCondition + scheme?: RawRuleSetCondition + mimetype?: RawRuleSetCondition + oneOf?: Array + rules?: Array + /** Specifies the category of the loader. No value means normal loader. */ + enforce?: 'pre' | 'post' +} + /** * `loader` is for both JS and Rust loaders. * `options` is @@ -1729,6 +2474,26 @@ export interface RawModuleRuleUse { options?: string } +/** + * `loader` is for both JS and Rust loaders. + * `options` is + * - a `None` on rust side and handled by js side `getOptions` when + * using with `loader`. + * - a `Some(string)` on rust side, deserialized by `serde_json::from_str` + * and passed to rust side loader in [get_builtin_loader] when using with + * `builtin_loader`. + */ +export interface RawModuleRuleUse { + loader: string + options?: string +} + +export interface RawNodeOption { + dirname: string + filename: string + global: string +} + export interface RawNodeOption { dirname: string filename: string @@ -1739,6 +2504,14 @@ export interface RawNonStandard { deepSelectorCombinator: boolean } +export interface RawNonStandard { + deepSelectorCombinator: boolean +} + +export interface RawOccurrenceChunkIdsPluginOptions { + prioritiseInitial?: boolean +} + export interface RawOccurrenceChunkIdsPluginOptions { prioritiseInitial?: boolean } @@ -1753,6 +2526,37 @@ export interface RawOptimizationOptions { concatenateModules: boolean } +export interface RawOptimizationOptions { + removeAvailableModules: boolean + sideEffects: string + usedExports: string + providedExports: boolean + innerGraph: boolean + mangleExports: string + concatenateModules: boolean +} + +export interface RawOptions { + mode?: undefined | 'production' | 'development' | 'none' + target: Array + context: string + output: RawOutputOptions + resolve: RawResolveOptions + resolveLoader: RawResolveOptions + module: RawModuleOptions + devtool: string + optimization: RawOptimizationOptions + stats: RawStatsOptions + snapshot: RawSnapshotOptions + cache: RawCacheOptions + experiments: RawExperiments + node?: RawNodeOption + profile: boolean + amd?: string + bail: boolean + __references: Record +} + export interface RawOptions { mode?: undefined | 'production' | 'development' | 'none' target: Array @@ -1820,6 +2624,61 @@ export interface RawOutputOptions { compareBeforeEmit: boolean } +export interface RawOutputOptions { + path: string + pathinfo: boolean | "verbose" + clean: boolean | JsCleanOptions + publicPath: "auto" | JsFilename + assetModuleFilename: JsFilename + wasmLoading: string + enabledWasmLoadingTypes: Array + webassemblyModuleFilename: string + filename: JsFilename + chunkFilename: JsFilename + crossOriginLoading: RawCrossOriginLoading + cssFilename: JsFilename + cssChunkFilename: JsFilename + hotUpdateMainFilename: string + hotUpdateChunkFilename: string + hotUpdateGlobal: string + uniqueName: string + chunkLoadingGlobal: string + library?: JsLibraryOptions + strictModuleErrorHandling: boolean + enabledLibraryTypes?: Array + globalObject: string + importFunctionName: string + importMetaName: string + iife: boolean + module: boolean + chunkLoading: string + chunkLoadTimeout: number + charset: boolean + enabledChunkLoadingTypes?: Array + trustedTypes?: RawTrustedTypes + sourceMapFilename: string + hashFunction: string + hashDigest: string + hashDigestLength: number + hashSalt?: string + asyncChunks: boolean + workerChunkLoading: string + workerWasmLoading: string + workerPublicPath: string + scriptType: "module" | "text/javascript" | "false" + environment: RawEnvironment + compareBeforeEmit: boolean +} + +export interface RawParserOptions { + type: "asset" | "css" | "css/auto" | "css/module" | "javascript" | "javascript/auto" | "javascript/dynamic" | "javascript/esm" + asset?: RawAssetParserOptions + css?: RawCssParserOptions + cssAuto?: RawCssAutoParserOptions + cssModule?: RawCssModuleParserOptions + javascript?: RawJavascriptParserOptions +} + export interface RawParserOptions { type: "asset" | "css" | "css/auto" | "css/module" | "javascript" | "javascript/auto" | "javascript/dynamic" | "javascript/esm" asset?: RawAssetParserOptions @@ -1835,6 +2694,21 @@ export interface RawPathData { url?: string } +export interface RawPathData { + filename?: string + contentHash?: string + url?: string +} + +export interface RawProgressPluginOptions { + prefix?: string + profile?: boolean + template?: string + tick?: string | Array + progressChars?: string + handler?: (percent: number, msg: string, items: string[]) => void +} + export interface RawProgressPluginOptions { prefix?: string profile?: boolean @@ -1855,6 +2729,21 @@ export interface RawProvideOptions { strictVersion?: boolean } +export interface RawProvideOptions { + key: string + shareKey: string + shareScope: string + version?: string | false | undefined + eager: boolean + singleton?: boolean + requiredVersion?: string | false | undefined + strictVersion?: boolean +} + +export interface RawRelated { + sourceMap?: string +} + export interface RawRelated { sourceMap?: string } @@ -1865,6 +2754,12 @@ export interface RawRemoteOptions { shareScope: string } +export interface RawRemoteOptions { + key: string + external: Array + shareScope: string +} + export interface RawResolveOptions { preferRelative?: boolean preferAbsolute?: boolean @@ -1925,6 +2820,19 @@ export interface RawRspackFuture { } +export interface RawRspackFuture { + +} + +export interface RawRuleSetCondition { + type: RawRuleSetConditionType + string?: string + regexp?: RegExp + logical?: Array + array?: Array + func?: (value: string) => boolean +} + export interface RawRuleSetCondition { type: RawRuleSetConditionType string?: string @@ -1942,6 +2850,20 @@ export declare enum RawRuleSetConditionType { func = 'func' } +export declare enum RawRuleSetConditionType { + string = 'string', + regexp = 'regexp', + logical = 'logical', + array = 'array', + func = 'func' +} + +export interface RawRuleSetLogicalConditions { + and?: Array + or?: Array + not?: RawRuleSetCondition +} + export interface RawRuleSetLogicalConditions { and?: Array or?: Array @@ -1952,6 +2874,14 @@ export interface RawRuntimeChunkNameFnCtx { name: string } +export interface RawRuntimeChunkNameFnCtx { + name: string +} + +export interface RawRuntimeChunkOptions { + name: string | ((entrypoint: { name: string }) => string) +} + export interface RawRuntimeChunkOptions { name: string | ((entrypoint: { name: string }) => string) } @@ -1963,6 +2893,17 @@ export interface RawSizeLimitsPluginOptions { maxEntrypointSize?: number } +export interface RawSizeLimitsPluginOptions { + assetFilter?: (assetFilename: string) => boolean + hints?: "error" | "warning" + maxAssetSize?: number + maxEntrypointSize?: number +} + +export interface RawSnapshotOptions { + +} + export interface RawSnapshotOptions { } @@ -1984,6 +2925,27 @@ export interface RawSourceMapDevToolPluginOptions { exclude?: string | RegExp | (string | RegExp)[] } +export interface RawSourceMapDevToolPluginOptions { + append?: (false | null) | string | Function + columns?: boolean + fallbackModuleFilenameTemplate?: string | ((info: RawModuleFilenameTemplateFnCtx) => string) + fileContext?: string + filename?: (false | null) | string + module?: boolean + moduleFilenameTemplate?: string | ((info: RawModuleFilenameTemplateFnCtx) => string) + namespace?: string + noSources?: boolean + publicPath?: string + sourceRoot?: string + test?: string | RegExp | (string | RegExp)[] + include?: string | RegExp | (string | RegExp)[] + exclude?: string | RegExp | (string | RegExp)[] +} + +export interface RawSplitChunkSizes { + sizes: Record +} + export interface RawSplitChunkSizes { sizes: Record } @@ -2009,6 +2971,31 @@ export interface RawSplitChunksOptions { maxInitialSize?: number | RawSplitChunkSizes } +export interface RawSplitChunksOptions { + fallbackCacheGroup?: RawFallbackCacheGroupOptions + name?: string | false | Function + cacheGroups?: Array + /** What kind of chunks should be selected. */ + chunks?: RegExp | 'async' | 'initial' | 'all' | Function + usedExports?: boolean + automaticNameDelimiter?: string + maxAsyncRequests?: number + maxInitialRequests?: number + defaultSizeTypes: Array + minChunks?: number + hidePathInfo?: boolean + minSize?: number | RawSplitChunkSizes + enforceSizeThreshold?: number + minRemainingSize?: number | RawSplitChunkSizes + maxSize?: number | RawSplitChunkSizes + maxAsyncSize?: number | RawSplitChunkSizes + maxInitialSize?: number | RawSplitChunkSizes +} + +export interface RawStatsOptions { + colors: boolean +} + export interface RawStatsOptions { colors: boolean } @@ -2018,6 +3005,19 @@ export interface RawStorageOptions { directory: string } +export interface RawStorageOptions { + type: "filesystem" + directory: string +} + +export interface RawSwcJsMinimizerOptions { + compress: any + mangle: any + format: any + module?: boolean + minify?: boolean +} + export interface RawSwcJsMinimizerOptions { compress: any mangle: any @@ -2034,6 +3034,19 @@ export interface RawSwcJsMinimizerRspackPluginOptions { minimizerOptions: RawSwcJsMinimizerOptions } +export interface RawSwcJsMinimizerRspackPluginOptions { + test?: string | RegExp | (string | RegExp)[] + include?: string | RegExp | (string | RegExp)[] + exclude?: string | RegExp | (string | RegExp)[] + extractComments?: RawExtractComments + minimizerOptions: RawSwcJsMinimizerOptions +} + +export interface RawToOptions { + context: string + absoluteFilename: string +} + export interface RawToOptions { context: string absoluteFilename: string @@ -2044,6 +3057,11 @@ export interface RawTrustedTypes { onPolicyCreationFailure?: string } +export interface RawTrustedTypes { + policyName?: string + onPolicyCreationFailure?: string +} + /** * Some code is modified based on * https://github.com/swc-project/swc/blob/d1d0607158ab40463d1b123fed52cc526eba8385/bindings/binding_core_node/src/util.rs#L29-L58 diff --git a/crates/node_binding/src/lib.rs b/crates/node_binding/src/lib.rs index 52c562e31ee..fb4a81931df 100644 --- a/crates/node_binding/src/lib.rs +++ b/crates/node_binding/src/lib.rs @@ -10,7 +10,6 @@ use std::sync::{Arc, Mutex}; use compiler::{Compiler, CompilerState, CompilerStateGuard}; use napi::bindgen_prelude::*; -use rspack_binding_options::BuiltinPlugin; use rspack_core::{Compilation, PluginExt}; use rspack_error::Diagnostic; use rspack_fs::IntermediateFileSystem; @@ -25,7 +24,6 @@ mod resolver_factory; pub use diagnostic::*; use plugins::*; use resolver_factory::*; -use rspack_binding_options::*; use rspack_binding_values::*; use rspack_tracing::chrome::FlushGuard; @@ -84,7 +82,7 @@ impl Rspack { compiler_path, compiler_options, plugins, - rspack_binding_options::buildtime_plugins::buildtime_plugins(), + rspack_binding_values::buildtime_plugins::buildtime_plugins(), Some(Arc::new(NodeFileSystem::new(output_filesystem).map_err( |e| Error::from_reason(format!("Failed to create writable filesystem: {e}",)), )?)), diff --git a/crates/rspack_binding_options/Cargo.toml b/crates/rspack_binding_options/Cargo.toml deleted file mode 100644 index b76a919960c..00000000000 --- a/crates/rspack_binding_options/Cargo.toml +++ /dev/null @@ -1,83 +0,0 @@ -[package] -description = "rspack binding options" -edition = "2021" -license = "MIT" -name = "rspack_binding_options" -repository = "https://github.com/web-infra-dev/rspack" -version = "0.2.0" -[features] -default = [] -plugin = ["rspack_loader_swc/plugin"] - -[package.metadata.cargo-shear] -ignored = ["tracing"] - -[dependencies] -async-trait = { workspace = true } -cow-utils = { workspace = true } -derive_more = { workspace = true, features = ["debug"] } -glob = { workspace = true } -napi = { workspace = true, features = ["async", "tokio_rt", "serde-json", "anyhow"] } -napi-derive = { workspace = true } -pollster = { workspace = true } -rspack_binding_values = { workspace = true } -rspack_cacheable = { workspace = true } -rspack_collections = { workspace = true } -rspack_core = { workspace = true } -rspack_error = { workspace = true } -rspack_hook = { workspace = true } -rspack_ids = { workspace = true } -rspack_loader_lightningcss = { workspace = true } -rspack_loader_preact_refresh = { workspace = true } -rspack_loader_react_refresh = { workspace = true } -rspack_loader_runner = { workspace = true } -rspack_loader_swc = { workspace = true } -rspack_loader_testing = { workspace = true } -rspack_napi = { workspace = true } -rspack_napi_macros = { workspace = true } -rspack_paths = { workspace = true } -rspack_plugin_asset = { workspace = true } -rspack_plugin_banner = { workspace = true } -rspack_plugin_context_replacement = { workspace = true } -rspack_plugin_copy = { workspace = true } -rspack_plugin_css = { workspace = true } -rspack_plugin_devtool = { workspace = true } -rspack_plugin_dll = { workspace = true } -rspack_plugin_dynamic_entry = { workspace = true } -rspack_plugin_ensure_chunk_conditions = { workspace = true } -rspack_plugin_entry = { workspace = true } -rspack_plugin_externals = { workspace = true } -rspack_plugin_extract_css = { workspace = true } -rspack_plugin_hmr = { workspace = true } -rspack_plugin_html = { workspace = true } -rspack_plugin_ignore = { workspace = true } -rspack_plugin_javascript = { workspace = true } -rspack_plugin_json = { workspace = true } -rspack_plugin_lazy_compilation = { workspace = true } -rspack_plugin_library = { workspace = true } -rspack_plugin_lightning_css_minimizer = { workspace = true } -rspack_plugin_limit_chunk_count = { workspace = true } -rspack_plugin_merge_duplicate_chunks = { workspace = true } -rspack_plugin_mf = { workspace = true } -rspack_plugin_no_emit_on_errors = { workspace = true } -rspack_plugin_progress = { workspace = true } -rspack_plugin_real_content_hash = { workspace = true } -rspack_plugin_remove_duplicate_modules = { workspace = true } -rspack_plugin_remove_empty_chunks = { workspace = true } -rspack_plugin_runtime = { workspace = true } -rspack_plugin_runtime_chunk = { workspace = true } -rspack_plugin_schemes = { workspace = true } -rspack_plugin_size_limits = { workspace = true } -rspack_plugin_split_chunks = { workspace = true } -rspack_plugin_swc_js_minimizer = { workspace = true } -rspack_plugin_warn_sensitive_module = { workspace = true } -rspack_plugin_wasm = { workspace = true } -rspack_plugin_web_worker_template = { workspace = true } -rspack_plugin_worker = { workspace = true } -rspack_regex = { workspace = true } -rustc-hash = { workspace = true } -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -swc_core = { workspace = true, default-features = false, features = ["ecma_transforms_react"] } -tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros", "test-util", "parking_lot"] } -tracing = { workspace = true } diff --git a/crates/rspack_binding_options/LICENSE b/crates/rspack_binding_options/LICENSE deleted file mode 100644 index 46310101ad8..00000000000 --- a/crates/rspack_binding_options/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2022-present Bytedance, Inc. and its affiliates. - - -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. diff --git a/crates/rspack_binding_options/src/lib.rs b/crates/rspack_binding_options/src/lib.rs deleted file mode 100644 index 3464fe5f86a..00000000000 --- a/crates/rspack_binding_options/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(try_blocks)] -#![feature(let_chains)] -mod options; -mod plugins; -pub use options::*; -pub use plugins::buildtime_plugins; -pub(crate) use plugins::*; diff --git a/crates/rspack_binding_values/Cargo.toml b/crates/rspack_binding_values/Cargo.toml index dfae126a299..33f7ac0c934 100644 --- a/crates/rspack_binding_values/Cargo.toml +++ b/crates/rspack_binding_values/Cargo.toml @@ -5,20 +5,80 @@ license = "MIT" name = "rspack_binding_values" repository = "https://github.com/web-infra-dev/rspack" version = "0.2.0" + +[features] +plugin = ["rspack_loader_swc/plugin"] + [dependencies] -cow-utils = { workspace = true } -futures = { workspace = true } -heck = { workspace = true } -napi = { workspace = true, features = ["async", "tokio_rt", "serde-json", "anyhow"] } -napi-derive = { workspace = true } -rspack_collections = { workspace = true } -rspack_core = { workspace = true } -rspack_error = { workspace = true } -rspack_napi = { workspace = true } -rspack_plugin_html = { workspace = true } -rspack_plugin_runtime = { workspace = true } -rspack_regex = { workspace = true } -rspack_util = { workspace = true } -rustc-hash = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } +async-trait = { workspace = true } +cow-utils = { workspace = true } +derive_more = { workspace = true, features = ["debug"] } +futures = { workspace = true } +glob = { workspace = true } +heck = { workspace = true } +napi = { workspace = true, features = ["async", "tokio_rt", "serde-json", "anyhow"] } +napi-derive = { workspace = true } +pollster = { workspace = true } +rspack_cacheable = { workspace = true } +rspack_collections = { workspace = true } +rspack_core = { workspace = true } +rspack_error = { workspace = true } +rspack_hook = { workspace = true } +rspack_ids = { workspace = true } +rspack_napi = { workspace = true } +rspack_napi_macros = { workspace = true } +rspack_paths = { workspace = true } +rspack_regex = { workspace = true } +rspack_util = { workspace = true } +rustc-hash = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +swc_core = { workspace = true, default-features = false, features = ["ecma_transforms_react"] } +tokio = { workspace = true, features = ["rt", "rt-multi-thread", "macros", "test-util", "parking_lot"] } +tracing = { workspace = true } + + +rspack_loader_lightningcss = { workspace = true } +rspack_loader_preact_refresh = { workspace = true } +rspack_loader_react_refresh = { workspace = true } +rspack_loader_runner = { workspace = true } +rspack_loader_swc = { workspace = true } +rspack_loader_testing = { workspace = true } +rspack_plugin_asset = { workspace = true } +rspack_plugin_banner = { workspace = true } +rspack_plugin_context_replacement = { workspace = true } +rspack_plugin_copy = { workspace = true } +rspack_plugin_css = { workspace = true } +rspack_plugin_devtool = { workspace = true } +rspack_plugin_dll = { workspace = true } +rspack_plugin_dynamic_entry = { workspace = true } +rspack_plugin_ensure_chunk_conditions = { workspace = true } +rspack_plugin_entry = { workspace = true } +rspack_plugin_externals = { workspace = true } +rspack_plugin_extract_css = { workspace = true } +rspack_plugin_hmr = { workspace = true } +rspack_plugin_html = { workspace = true } +rspack_plugin_ignore = { workspace = true } +rspack_plugin_javascript = { workspace = true } +rspack_plugin_json = { workspace = true } +rspack_plugin_lazy_compilation = { workspace = true } +rspack_plugin_library = { workspace = true } +rspack_plugin_lightning_css_minimizer = { workspace = true } +rspack_plugin_limit_chunk_count = { workspace = true } +rspack_plugin_merge_duplicate_chunks = { workspace = true } +rspack_plugin_mf = { workspace = true } +rspack_plugin_no_emit_on_errors = { workspace = true } +rspack_plugin_progress = { workspace = true } +rspack_plugin_real_content_hash = { workspace = true } +rspack_plugin_remove_duplicate_modules = { workspace = true } +rspack_plugin_remove_empty_chunks = { workspace = true } +rspack_plugin_runtime = { workspace = true } +rspack_plugin_runtime_chunk = { workspace = true } +rspack_plugin_schemes = { workspace = true } +rspack_plugin_size_limits = { workspace = true } +rspack_plugin_split_chunks = { workspace = true } +rspack_plugin_swc_js_minimizer = { workspace = true } +rspack_plugin_warn_sensitive_module = { workspace = true } +rspack_plugin_wasm = { workspace = true } +rspack_plugin_web_worker_template = { workspace = true } +rspack_plugin_worker = { workspace = true } diff --git a/crates/rspack_binding_values/src/lib.rs b/crates/rspack_binding_values/src/lib.rs index 53f3de249f4..1627411a8e4 100644 --- a/crates/rspack_binding_values/src/lib.rs +++ b/crates/rspack_binding_values/src/lib.rs @@ -1,4 +1,6 @@ +#![feature(let_chains)] #![feature(try_blocks)] + mod asset; mod asset_condition; mod chunk; @@ -19,6 +21,8 @@ mod module_graph; mod normal_module_factory; mod options; mod path_data; +mod plugins; +mod raw_options; mod resolver; mod resource_data; mod rspack_error; @@ -46,6 +50,9 @@ pub use module_graph::*; pub use normal_module_factory::*; pub use options::*; pub use path_data::*; +pub use plugins::buildtime_plugins; +pub(crate) use plugins::*; +pub use raw_options::*; pub use resolver::*; pub use resource_data::*; pub use rspack_error::*; diff --git a/crates/rspack_binding_options/src/plugins/buildtime_plugins.rs b/crates/rspack_binding_values/src/plugins/buildtime_plugins.rs similarity index 100% rename from crates/rspack_binding_options/src/plugins/buildtime_plugins.rs rename to crates/rspack_binding_values/src/plugins/buildtime_plugins.rs diff --git a/crates/rspack_binding_options/src/plugins/context_replacement.rs b/crates/rspack_binding_values/src/plugins/context_replacement.rs similarity index 100% rename from crates/rspack_binding_options/src/plugins/context_replacement.rs rename to crates/rspack_binding_values/src/plugins/context_replacement.rs diff --git a/crates/rspack_binding_options/src/plugins/js_loader/context.rs b/crates/rspack_binding_values/src/plugins/js_loader/context.rs similarity index 98% rename from crates/rspack_binding_options/src/plugins/js_loader/context.rs rename to crates/rspack_binding_values/src/plugins/js_loader/context.rs index 83da01720f6..bc9256cfda2 100644 --- a/crates/rspack_binding_options/src/plugins/js_loader/context.rs +++ b/crates/rspack_binding_values/src/plugins/js_loader/context.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use napi::bindgen_prelude::*; use napi_derive::napi; -use rspack_binding_values::{JsModuleWrapper, JsResourceData, JsRspackError}; +use crate::{JsModuleWrapper, JsResourceData, JsRspackError}; use rspack_core::{LoaderContext, RunnerContext}; use rspack_error::error; use rspack_loader_runner::{LoaderItem, State as LoaderState}; diff --git a/crates/rspack_binding_options/src/plugins/js_loader/mod.rs b/crates/rspack_binding_values/src/plugins/js_loader/mod.rs similarity index 100% rename from crates/rspack_binding_options/src/plugins/js_loader/mod.rs rename to crates/rspack_binding_values/src/plugins/js_loader/mod.rs diff --git a/crates/rspack_binding_options/src/plugins/js_loader/resolver.rs b/crates/rspack_binding_values/src/plugins/js_loader/resolver.rs similarity index 100% rename from crates/rspack_binding_options/src/plugins/js_loader/resolver.rs rename to crates/rspack_binding_values/src/plugins/js_loader/resolver.rs diff --git a/crates/rspack_binding_options/src/plugins/js_loader/scheduler.rs b/crates/rspack_binding_values/src/plugins/js_loader/scheduler.rs similarity index 100% rename from crates/rspack_binding_options/src/plugins/js_loader/scheduler.rs rename to crates/rspack_binding_values/src/plugins/js_loader/scheduler.rs diff --git a/crates/rspack_binding_options/src/plugins/mod.rs b/crates/rspack_binding_values/src/plugins/mod.rs similarity index 100% rename from crates/rspack_binding_options/src/plugins/mod.rs rename to crates/rspack_binding_values/src/plugins/mod.rs diff --git a/crates/rspack_binding_options/src/options/mod.rs b/crates/rspack_binding_values/src/raw_options/mod.rs similarity index 98% rename from crates/rspack_binding_options/src/options/mod.rs rename to crates/rspack_binding_values/src/raw_options/mod.rs index e2fb75b51e4..4991e966866 100644 --- a/crates/rspack_binding_options/src/options/mod.rs +++ b/crates/rspack_binding_values/src/raw_options/mod.rs @@ -33,7 +33,8 @@ pub use raw_output::*; pub use raw_snapshot::*; pub use raw_split_chunks::*; pub use raw_stats::*; -pub use rspack_binding_values::raw_resolve::*; + +pub use crate::raw_resolve::*; #[derive(Debug)] #[napi(object, object_to_js = false)] diff --git a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/mod.rs similarity index 99% rename from crates/rspack_binding_options/src/options/raw_builtins/mod.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/mod.rs index fc8c6a4a9ca..8511656fba0 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_builtins/mod.rs @@ -20,7 +20,7 @@ use napi_derive::napi; use raw_dll::{RawDllReferenceAgencyPluginOptions, RawFlagAllModulesAsUsedPluginOptions}; use raw_ids::RawOccurrenceChunkIdsPluginOptions; use raw_lightning_css_minimizer::RawLightningCssMinimizerRspackPluginOptions; -use rspack_binding_values::entry::JsEntryPluginOptions; +use crate::entry::JsEntryPluginOptions; use rspack_core::{BoxPlugin, Plugin, PluginExt}; use rspack_error::Result; use rspack_ids::{ diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_banner.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_banner.rs similarity index 96% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_banner.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_banner.rs index 3762fbb795d..9e8a5cf15a3 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_banner.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_banner.rs @@ -1,7 +1,7 @@ use derive_more::Debug; use napi::Either; use napi_derive::napi; -use rspack_binding_values::{into_asset_conditions, JsChunkWrapper, RawAssetConditions}; +use crate::{into_asset_conditions, JsChunkWrapper, RawAssetConditions}; use rspack_collections::DatabaseItem; use rspack_error::Result; use rspack_napi::threadsafe_function::ThreadsafeFunction; diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_bundle_info.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_bundle_info.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_bundle_info.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_bundle_info.rs diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_copy.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_copy.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_copy.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_copy.rs diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_css_extract.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_css_extract.rs similarity index 96% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_css_extract.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_css_extract.rs index 2a18caa3315..34a1b778c4e 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_css_extract.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_css_extract.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use napi_derive::napi; -use rspack_binding_values::JsFilename; +use crate::JsFilename; use rspack_plugin_extract_css::plugin::{CssExtractOptions, InsertType}; #[napi(object, object_to_js = false)] diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_dll.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_dll.rs similarity index 98% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_dll.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_dll.rs index 89f886bfe16..9a0727c8f6f 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_dll.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_dll.rs @@ -1,6 +1,6 @@ use napi::Either; use napi_derive::napi; -use rspack_binding_values::{JsBuildMeta, JsFilename}; +use crate::{JsBuildMeta, JsFilename}; use rspack_plugin_dll::{ DllEntryPluginOptions, DllManifest, DllManifestContent, DllManifestContentItem, DllManifestContentItemExports, DllReferenceAgencyPluginOptions, LibManifestPluginOptions, diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_html.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_html.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_html.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_html.rs diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_ids.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_ids.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_ids.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_ids.rs diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_ignore.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_ignore.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_ignore.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_ignore.rs diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_lazy_compilation.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_lazy_compilation.rs similarity index 98% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_lazy_compilation.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_lazy_compilation.rs index 7b7dcf0d05a..7dc6b482722 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_lazy_compilation.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_lazy_compilation.rs @@ -3,7 +3,7 @@ use napi::{ Either, }; use napi_derive::napi; -use rspack_binding_values::JsModuleWrapper; +use crate::JsModuleWrapper; use rspack_core::{CompilationId, ModuleIdentifier}; use rspack_napi::threadsafe_function::ThreadsafeFunction; use rspack_plugin_lazy_compilation::{ diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_lightning_css_minimizer.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_lightning_css_minimizer.rs similarity index 98% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_lightning_css_minimizer.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_lightning_css_minimizer.rs index 3f1a367f5ee..b22e240c991 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_lightning_css_minimizer.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_lightning_css_minimizer.rs @@ -1,5 +1,5 @@ use napi_derive::napi; -use rspack_binding_values::{into_asset_conditions, RawAssetConditions}; +use crate::{into_asset_conditions, RawAssetConditions}; use rspack_error::Result; use rspack_plugin_lightning_css_minimizer::{ Draft, MinimizerOptions, NonStandard, PluginOptions, PseudoClasses, diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_limit_chunk_count.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_limit_chunk_count.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_limit_chunk_count.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_limit_chunk_count.rs diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_mf.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_mf.rs similarity index 99% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_mf.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_mf.rs index f4e78225756..d9d7b2c4101 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_mf.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_mf.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use napi::Either; use napi_derive::napi; -use rspack_binding_values::{ +use crate::{ entry::{JsEntryRuntime, JsEntryRuntimeWrapper}, library::JsLibraryOptions, }; diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_progress.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_progress.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_progress.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_progress.rs diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_runtime_chunk.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_runtime_chunk.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_runtime_chunk.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_runtime_chunk.rs diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_size_limits.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_size_limits.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_size_limits.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_size_limits.rs diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_swc_js_minimizer.rs b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_swc_js_minimizer.rs similarity index 97% rename from crates/rspack_binding_options/src/options/raw_builtins/raw_swc_js_minimizer.rs rename to crates/rspack_binding_values/src/raw_options/raw_builtins/raw_swc_js_minimizer.rs index 87a8ed52916..7e7866b23f7 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_swc_js_minimizer.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_builtins/raw_swc_js_minimizer.rs @@ -1,6 +1,6 @@ use napi::Either; use napi_derive::napi; -use rspack_binding_values::{into_asset_conditions, RawAssetConditions}; +use crate::{into_asset_conditions, RawAssetConditions}; use rspack_error::{miette::IntoDiagnostic, Result}; use rspack_plugin_swc_js_minimizer::{ ExtractComments, MinimizerOptions, OptionWrapper, PluginOptions, diff --git a/crates/rspack_binding_options/src/options/raw_cache.rs b/crates/rspack_binding_values/src/raw_options/raw_cache.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_cache.rs rename to crates/rspack_binding_values/src/raw_options/raw_cache.rs diff --git a/crates/rspack_binding_options/src/options/raw_devtool.rs b/crates/rspack_binding_values/src/raw_options/raw_devtool.rs similarity index 98% rename from crates/rspack_binding_options/src/options/raw_devtool.rs rename to crates/rspack_binding_values/src/raw_options/raw_devtool.rs index d95c0cdb8d4..8204fada95d 100644 --- a/crates/rspack_binding_options/src/options/raw_devtool.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_devtool.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use napi::bindgen_prelude::{Either3, Null}; use napi::Either; use napi_derive::napi; -use rspack_binding_values::{into_asset_conditions, RawAssetConditions}; +use crate::{into_asset_conditions, RawAssetConditions}; use rspack_core::PathData; use rspack_napi::threadsafe_function::ThreadsafeFunction; use rspack_plugin_devtool::{ diff --git a/crates/rspack_binding_options/src/options/raw_dynamic_entry.rs b/crates/rspack_binding_values/src/raw_options/raw_dynamic_entry.rs similarity index 96% rename from crates/rspack_binding_options/src/options/raw_dynamic_entry.rs rename to crates/rspack_binding_values/src/raw_options/raw_dynamic_entry.rs index 7da0f93750f..21edfd3d186 100644 --- a/crates/rspack_binding_options/src/options/raw_dynamic_entry.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_dynamic_entry.rs @@ -1,5 +1,5 @@ use napi_derive::napi; -use rspack_binding_values::entry::JsEntryOptions; +use crate::entry::JsEntryOptions; use rspack_napi::threadsafe_function::ThreadsafeFunction; use rspack_plugin_dynamic_entry::{DynamicEntryPluginOptions, EntryDynamicResult}; diff --git a/crates/rspack_binding_options/src/options/raw_experiments/mod.rs b/crates/rspack_binding_values/src/raw_options/raw_experiments/mod.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_experiments/mod.rs rename to crates/rspack_binding_values/src/raw_options/raw_experiments/mod.rs diff --git a/crates/rspack_binding_options/src/options/raw_experiments/raw_cache/mod.rs b/crates/rspack_binding_values/src/raw_options/raw_experiments/raw_cache/mod.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_experiments/raw_cache/mod.rs rename to crates/rspack_binding_values/src/raw_options/raw_experiments/raw_cache/mod.rs diff --git a/crates/rspack_binding_options/src/options/raw_experiments/raw_cache/raw_snapshot.rs b/crates/rspack_binding_values/src/raw_options/raw_experiments/raw_cache/raw_snapshot.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_experiments/raw_cache/raw_snapshot.rs rename to crates/rspack_binding_values/src/raw_options/raw_experiments/raw_cache/raw_snapshot.rs diff --git a/crates/rspack_binding_options/src/options/raw_experiments/raw_cache/raw_storage.rs b/crates/rspack_binding_values/src/raw_options/raw_experiments/raw_cache/raw_storage.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_experiments/raw_cache/raw_storage.rs rename to crates/rspack_binding_values/src/raw_options/raw_experiments/raw_cache/raw_storage.rs diff --git a/crates/rspack_binding_options/src/options/raw_experiments/raw_incremental.rs b/crates/rspack_binding_values/src/raw_options/raw_experiments/raw_incremental.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_experiments/raw_incremental.rs rename to crates/rspack_binding_values/src/raw_options/raw_experiments/raw_incremental.rs diff --git a/crates/rspack_binding_options/src/options/raw_experiments/raw_rspack_future.rs b/crates/rspack_binding_values/src/raw_options/raw_experiments/raw_rspack_future.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_experiments/raw_rspack_future.rs rename to crates/rspack_binding_values/src/raw_options/raw_experiments/raw_rspack_future.rs diff --git a/crates/rspack_binding_options/src/options/raw_external.rs b/crates/rspack_binding_values/src/raw_options/raw_external.rs similarity index 99% rename from crates/rspack_binding_options/src/options/raw_external.rs rename to crates/rspack_binding_values/src/raw_options/raw_external.rs index 87a204229d5..bb35d530c0c 100644 --- a/crates/rspack_binding_options/src/options/raw_external.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_external.rs @@ -4,12 +4,13 @@ use std::sync::Arc; use napi::bindgen_prelude::Either4; use napi_derive::napi; -use rspack_binding_values::JsResolver; use rspack_core::{ExternalItem, ExternalItemFnResult, ExternalItemValue}; use rspack_core::{ExternalItemFnCtx, ResolveOptionsWithDependencyType, ResolverFactory}; use rspack_napi::threadsafe_function::ThreadsafeFunction; use rspack_regex::RspackRegex; +use crate::JsResolver; + #[napi(object)] pub struct RawHttpExternalsRspackPluginOptions { pub css: bool, diff --git a/crates/rspack_binding_options/src/options/raw_mode.rs b/crates/rspack_binding_values/src/raw_options/raw_mode.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_mode.rs rename to crates/rspack_binding_values/src/raw_options/raw_mode.rs diff --git a/crates/rspack_binding_options/src/options/raw_module/mod.rs b/crates/rspack_binding_values/src/raw_options/raw_module/mod.rs similarity index 99% rename from crates/rspack_binding_options/src/options/raw_module/mod.rs rename to crates/rspack_binding_values/src/raw_options/raw_module/mod.rs index 6044dbe6421..dc544b582a1 100644 --- a/crates/rspack_binding_options/src/options/raw_module/mod.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_module/mod.rs @@ -5,7 +5,7 @@ use derive_more::Debug; use napi::bindgen_prelude::{Buffer, Either3}; use napi::Either; use napi_derive::napi; -use rspack_binding_values::{JsFilename, JsModuleWrapper}; +use crate::{JsFilename, JsModuleWrapper}; use rspack_core::{ AssetGeneratorDataUrl, AssetGeneratorDataUrlFnCtx, AssetGeneratorDataUrlOptions, AssetGeneratorOptions, AssetInlineGeneratorOptions, AssetParserDataUrl, diff --git a/crates/rspack_binding_options/src/options/raw_node.rs b/crates/rspack_binding_values/src/raw_options/raw_node.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_node.rs rename to crates/rspack_binding_values/src/raw_options/raw_node.rs diff --git a/crates/rspack_binding_options/src/options/raw_optimization.rs b/crates/rspack_binding_values/src/raw_options/raw_optimization.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_optimization.rs rename to crates/rspack_binding_values/src/raw_options/raw_optimization.rs diff --git a/crates/rspack_binding_options/src/options/raw_output.rs b/crates/rspack_binding_values/src/raw_options/raw_output.rs similarity index 98% rename from crates/rspack_binding_options/src/options/raw_output.rs rename to crates/rspack_binding_values/src/raw_options/raw_output.rs index 5f4ba459363..3023d6a30dc 100644 --- a/crates/rspack_binding_options/src/options/raw_output.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_output.rs @@ -1,7 +1,7 @@ use napi::Either; use napi_derive::napi; -use rspack_binding_values::library::JsLibraryOptions; -use rspack_binding_values::{JsCleanOptions, JsFilename}; +use crate::library::JsLibraryOptions; +use crate::{JsCleanOptions, JsFilename}; use rspack_core::{ CleanOptions, CrossOriginLoading, Environment, OnPolicyCreationFailure, PathInfo, }; diff --git a/crates/rspack_binding_options/src/options/raw_snapshot.rs b/crates/rspack_binding_values/src/raw_options/raw_snapshot.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_snapshot.rs rename to crates/rspack_binding_values/src/raw_options/raw_snapshot.rs diff --git a/crates/rspack_binding_options/src/options/raw_split_chunks/mod.rs b/crates/rspack_binding_values/src/raw_options/raw_split_chunks/mod.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_split_chunks/mod.rs rename to crates/rspack_binding_values/src/raw_options/raw_split_chunks/mod.rs diff --git a/crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_cache_group_test.rs b/crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_cache_group_test.rs similarity index 96% rename from crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_cache_group_test.rs rename to crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_cache_group_test.rs index 792a27b5ad2..83b991b9981 100644 --- a/crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_cache_group_test.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_cache_group_test.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use napi::bindgen_prelude::Either3; use napi_derive::napi; -use rspack_binding_values::JsModuleWrapper; +use crate::JsModuleWrapper; use rspack_napi::threadsafe_function::ThreadsafeFunction; use rspack_plugin_split_chunks::{CacheGroupTest, CacheGroupTestFnCtx}; use rspack_regex::RspackRegex; diff --git a/crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_chunks.rs b/crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_chunks.rs similarity index 95% rename from crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_chunks.rs rename to crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_chunks.rs index 5b5285b9f10..f1450631fb3 100644 --- a/crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_chunks.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_chunks.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use napi::{bindgen_prelude::Either3, JsString}; -use rspack_binding_values::JsChunkWrapper; +use crate::JsChunkWrapper; use rspack_collections::DatabaseItem; use rspack_napi::string::JsStringExt; use rspack_napi::threadsafe_function::ThreadsafeFunction; diff --git a/crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_name.rs b/crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_name.rs similarity index 96% rename from crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_name.rs rename to crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_name.rs index 3a4948f9551..7e5613ea709 100644 --- a/crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_name.rs +++ b/crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_name.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use napi::bindgen_prelude::Either3; use napi_derive::napi; -use rspack_binding_values::{JsChunkWrapper, JsModuleWrapper}; +use crate::{JsChunkWrapper, JsModuleWrapper}; use rspack_collections::DatabaseItem; use rspack_napi::threadsafe_function::ThreadsafeFunction; use rspack_plugin_split_chunks::{ChunkNameGetter, ChunkNameGetterFnCtx}; diff --git a/crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_size.rs b/crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_size.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_split_chunks/raw_split_chunk_size.rs rename to crates/rspack_binding_values/src/raw_options/raw_split_chunks/raw_split_chunk_size.rs diff --git a/crates/rspack_binding_options/src/options/raw_stats.rs b/crates/rspack_binding_values/src/raw_options/raw_stats.rs similarity index 100% rename from crates/rspack_binding_options/src/options/raw_stats.rs rename to crates/rspack_binding_values/src/raw_options/raw_stats.rs diff --git a/crates/rspack_tracing/src/lib.rs b/crates/rspack_tracing/src/lib.rs index bbe799e4164..6f0017529d1 100644 --- a/crates/rspack_tracing/src/lib.rs +++ b/crates/rspack_tracing/src/lib.rs @@ -67,7 +67,7 @@ fn generate_common_layers( ("rspack_node", default_level), ("rspack_plugin_javascript", default_level), ("rspack_plugin_split_chunks", default_level), - ("rspack_binding_options", default_level), + ("rspack_binding_values", default_level), ]) .boxed(), ); diff --git a/tests/webpack-test/cases/loaders/cjs-loader-type/index.js b/tests/webpack-test/cases/loaders/cjs-loader-type/index.js index 876b8ca7369..0b232811d80 100644 --- a/tests/webpack-test/cases/loaders/cjs-loader-type/index.js +++ b/tests/webpack-test/cases/loaders/cjs-loader-type/index.js @@ -10,6 +10,6 @@ it("should pass 'commonjs' type to loader for .cjs", function () { // ORIGINAL WEBPACK COMMENT: TODO otherwise this test case cause segment fault // Turned on this as rspack checks extensions for loader type. // So this will not fall into dynamic import which causes segment fault. - // See: crates/rspack_binding_options/src/plugins/js_loader/resolver.rs + // See: crates/rspack_binding_values/src/plugins/js_loader/resolver.rs expect(require("esm/loader.cjs!")).toBe("commonjs"); });