Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: pass compiler_path to rust Compiler #8665

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export declare class RawExternalItemFnCtx {
}

export declare class Rspack {
constructor(options: RawOptions, builtinPlugins: Array<BuiltinPlugin>, registerJsTaps: RegisterJsTaps, outputFilesystem: ThreadsafeNodeFS, intermediateFilesystem: ThreadsafeNodeFS, resolverFactoryReference: JsResolverFactory)
constructor(compilerPath: string, options: RawOptions, builtinPlugins: Array<BuiltinPlugin>, registerJsTaps: RegisterJsTaps, outputFilesystem: ThreadsafeNodeFS, intermediateFilesystem: ThreadsafeNodeFS, resolverFactoryReference: JsResolverFactory)
setNonSkippableRegisters(kinds: Array<RegisterJsTapKind>): void
/** Build with the given option passed to the constructor */
build(callback: (err: null | Error) => void): void
Expand Down
3 changes: 3 additions & 0 deletions crates/node_binding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ pub struct Rspack {

#[napi]
impl Rspack {
#[allow(clippy::too_many_arguments)]
#[napi(constructor)]
pub fn new(
env: Env,
compiler_path: String,
options: RawOptions,
builtin_plugins: Vec<BuiltinPlugin>,
register_js_taps: RegisterJsTaps,
Expand Down Expand Up @@ -68,6 +70,7 @@ impl Rspack {
let loader_resolver_factory = (*resolver_factory_reference)
.get_loader_resolver_factory(compiler_options.resolve_loader.clone());
let rspack = rspack_core::Compiler::new(
compiler_path,
compiler_options,
plugins,
rspack_binding_options::buildtime_plugins::buildtime_plugins(),
Expand Down
3 changes: 3 additions & 0 deletions crates/rspack_core/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct CompilerHooks {

#[derive(Debug)]
pub struct Compiler {
pub compiler_path: String,
pub options: Arc<CompilerOptions>,
pub output_filesystem: Box<dyn WritableFileSystem>,
pub intermediate_filesystem: Box<dyn WritableFileSystem>,
Expand All @@ -72,6 +73,7 @@ impl Compiler {
#[instrument(skip_all)]
#[allow(clippy::too_many_arguments)]
pub fn new(
compiler_path: String,
options: CompilerOptions,
plugins: Vec<BoxPlugin>,
buildtime_plugins: Vec<BoxPlugin>,
Expand Down Expand Up @@ -116,6 +118,7 @@ impl Compiler {
intermediate_filesystem.unwrap_or_else(|| Box::new(NativeFileSystem {}));

Self {
compiler_path,
options: options.clone(),
compilation: Compilation::new(
options,
Expand Down
1 change: 1 addition & 0 deletions packages/rspack/src/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,7 @@ class Compiler {
};

this.#instance = new instanceBinding.Rspack(
this.compilerPath,
rawOptions,
this.#builtinPlugins,
this.#registers,
Expand Down
Loading