Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ahabhgk committed Jan 3, 2024
1 parent 140cfe0 commit d61fe9c
Show file tree
Hide file tree
Showing 40 changed files with 325 additions and 1,054 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pnpm-lock.yaml
/crates/rspack_plugin_banner @web-infra-dev/rspack-dx
/crates/rspack_plugin_copy @web-infra-dev/rspack-dx
/crates/rspack_plugin_css @web-infra-dev/rspack-ux
/crates/rspack_plugin_dev_friendly_split_chunks @web-infra-dev/rspack-ux
/crates/rspack_plugin_devtool @web-infra-dev/rspack-dx
/crates/rspack_plugin_entry @web-infra-dev/rspack-dx
/crates/rspack_plugin_externals @web-infra-dev/rspack-dx
Expand Down
14 changes: 0 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions crates/node_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,15 +610,7 @@ export interface RawBannerPluginOptions {

export interface RawBuiltins {
css?: RawCssPluginConfig
presetEnv?: RawPresetEnv
treeShaking: string
react: RawReactOptions
decorator?: RawDecoratorOptions
noEmitAssets: boolean
emotion?: string
devFriendlySplitChunks: boolean
pluginImport?: Array<RawPluginImportConfig>
relay?: RawRelayConfig
}

export interface RawCacheGroupOptions {
Expand Down Expand Up @@ -734,11 +726,6 @@ export interface RawCssPluginConfig {
modules: RawCssModulesConfig
}

export interface RawDecoratorOptions {
legacy: boolean
emitMetadata: boolean
}

export interface RawEntryOptions {
name?: string
runtime?: string
Expand Down Expand Up @@ -1061,12 +1048,6 @@ export interface RawPluginImportConfig {
ignoreStyleComponent?: Array<string>
}

export interface RawPresetEnv {
targets: Array<string>
mode?: 'usage' | 'entry'
coreJs?: string
}

export interface RawProgressPluginOptions {
prefix: string
profile: boolean
Expand Down
83 changes: 41 additions & 42 deletions crates/rspack_binding_options/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,47 @@ repository = "https://github.com/web-infra-dev/rspack"
version = "0.1.0"

[dependencies]
rspack_binding_macros = { path = "../rspack_binding_macros" }
rspack_binding_values = { path = "../rspack_binding_values" }
rspack_core = { path = "../rspack_core" }
rspack_error = { path = "../rspack_error" }
rspack_identifier = { path = "../rspack_identifier" }
rspack_ids = { path = "../rspack_ids" }
rspack_loader_react_refresh = { path = "../rspack_loader_react_refresh" }
rspack_loader_runner = { path = "../rspack_loader_runner" }
rspack_loader_swc = { path = "../rspack_loader_swc" }
rspack_napi_shared = { path = "../rspack_napi_shared" }
rspack_plugin_asset = { path = "../rspack_plugin_asset" }
rspack_plugin_banner = { path = "../rspack_plugin_banner" }
rspack_plugin_copy = { path = "../rspack_plugin_copy" }
rspack_plugin_css = { path = "../rspack_plugin_css" }
rspack_plugin_dev_friendly_split_chunks = { path = "../rspack_plugin_dev_friendly_split_chunks" }
rspack_plugin_devtool = { path = "../rspack_plugin_devtool" }
rspack_plugin_ensure_chunk_conditions = { path = "../rspack_plugin_ensure_chunk_conditions" }
rspack_plugin_entry = { path = "../rspack_plugin_entry" }
rspack_plugin_externals = { path = "../rspack_plugin_externals" }
rspack_plugin_hmr = { path = "../rspack_plugin_hmr" }
rspack_plugin_html = { path = "../rspack_plugin_html" }
rspack_plugin_javascript = { path = "../rspack_plugin_javascript" }
rspack_plugin_json = { path = "../rspack_plugin_json" }
rspack_plugin_library = { path = "../rspack_plugin_library" }
rspack_plugin_limit_chunk_count = { path = "../rspack_plugin_limit_chunk_count" }
rspack_plugin_merge_duplicate_chunks = { path = "../rspack_plugin_merge_duplicate_chunks" }
rspack_plugin_mf = { path = "../rspack_plugin_mf" }
rspack_plugin_progress = { path = "../rspack_plugin_progress" }
rspack_plugin_real_content_hash = { path = "../rspack_plugin_real_content_hash" }
rspack_plugin_remove_empty_chunks = { path = "../rspack_plugin_remove_empty_chunks" }
rspack_plugin_runtime = { path = "../rspack_plugin_runtime" }
rspack_plugin_schemes = { path = "../rspack_plugin_schemes" }
rspack_plugin_split_chunks = { path = "../rspack_plugin_split_chunks" }
rspack_plugin_split_chunks_new = { path = "../rspack_plugin_split_chunks_new" }
rspack_plugin_swc_css_minimizer = { path = "../rspack_plugin_swc_css_minimizer" }
rspack_plugin_swc_js_minimizer = { path = "../rspack_plugin_swc_js_minimizer" }
rspack_plugin_warn_sensitive_module = { path = "../rspack_plugin_warn_sensitive_module" }
rspack_plugin_wasm = { path = "../rspack_plugin_wasm" }
rspack_plugin_web_worker_template = { path = "../rspack_plugin_web_worker_template" }
rspack_plugin_worker = { path = "../rspack_plugin_worker" }
rspack_regex = { path = "../rspack_regex" }
rspack_swc_visitors = { path = "../rspack_swc_visitors" }
rspack_binding_macros = { path = "../rspack_binding_macros" }
rspack_binding_values = { path = "../rspack_binding_values" }
rspack_core = { path = "../rspack_core" }
rspack_error = { path = "../rspack_error" }
rspack_identifier = { path = "../rspack_identifier" }
rspack_ids = { path = "../rspack_ids" }
rspack_loader_react_refresh = { path = "../rspack_loader_react_refresh" }
rspack_loader_runner = { path = "../rspack_loader_runner" }
rspack_loader_swc = { path = "../rspack_loader_swc" }
rspack_napi_shared = { path = "../rspack_napi_shared" }
rspack_plugin_asset = { path = "../rspack_plugin_asset" }
rspack_plugin_banner = { path = "../rspack_plugin_banner" }
rspack_plugin_copy = { path = "../rspack_plugin_copy" }
rspack_plugin_css = { path = "../rspack_plugin_css" }
rspack_plugin_devtool = { path = "../rspack_plugin_devtool" }
rspack_plugin_ensure_chunk_conditions = { path = "../rspack_plugin_ensure_chunk_conditions" }
rspack_plugin_entry = { path = "../rspack_plugin_entry" }
rspack_plugin_externals = { path = "../rspack_plugin_externals" }
rspack_plugin_hmr = { path = "../rspack_plugin_hmr" }
rspack_plugin_html = { path = "../rspack_plugin_html" }
rspack_plugin_javascript = { path = "../rspack_plugin_javascript" }
rspack_plugin_json = { path = "../rspack_plugin_json" }
rspack_plugin_library = { path = "../rspack_plugin_library" }
rspack_plugin_limit_chunk_count = { path = "../rspack_plugin_limit_chunk_count" }
rspack_plugin_merge_duplicate_chunks = { path = "../rspack_plugin_merge_duplicate_chunks" }
rspack_plugin_mf = { path = "../rspack_plugin_mf" }
rspack_plugin_progress = { path = "../rspack_plugin_progress" }
rspack_plugin_real_content_hash = { path = "../rspack_plugin_real_content_hash" }
rspack_plugin_remove_empty_chunks = { path = "../rspack_plugin_remove_empty_chunks" }
rspack_plugin_runtime = { path = "../rspack_plugin_runtime" }
rspack_plugin_schemes = { path = "../rspack_plugin_schemes" }
rspack_plugin_split_chunks = { path = "../rspack_plugin_split_chunks" }
rspack_plugin_split_chunks_new = { path = "../rspack_plugin_split_chunks_new" }
rspack_plugin_swc_css_minimizer = { path = "../rspack_plugin_swc_css_minimizer" }
rspack_plugin_swc_js_minimizer = { path = "../rspack_plugin_swc_js_minimizer" }
rspack_plugin_warn_sensitive_module = { path = "../rspack_plugin_warn_sensitive_module" }
rspack_plugin_wasm = { path = "../rspack_plugin_wasm" }
rspack_plugin_web_worker_template = { path = "../rspack_plugin_web_worker_template" }
rspack_plugin_worker = { path = "../rspack_plugin_worker" }
rspack_regex = { path = "../rspack_regex" }
rspack_swc_visitors = { path = "../rspack_swc_visitors" }

anyhow = { workspace = true, features = ["backtrace"] }
async-trait = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
use std::{path::PathBuf, str::FromStr};

use napi_derive::napi;
use rspack_core::{Builtins, DecoratorOptions, PluginExt, PresetEnv};
use rspack_error::internal_error;
use rspack_core::{Builtins, PluginExt};
use rspack_plugin_css::{
plugin::{CssConfig, LocalIdentName, LocalsConvention, ModulesConfig},
CssPlugin,
};
use rspack_plugin_dev_friendly_split_chunks::DevFriendlySplitChunksPlugin;
use rspack_swc_visitors::{
CustomTransform, ImportOptions, ReactOptions, RelayLanguageConfig, RelayOptions, StyleConfig,
};
use serde::{Deserialize, Serialize};

#[derive(Deserialize, Debug, Serialize, Default, Clone)]
#[serde(rename_all = "camelCase")]
#[napi(object)]
pub struct RawDecoratorOptions {
pub legacy: bool,
pub emit_metadata: bool,
}

impl From<RawDecoratorOptions> for DecoratorOptions {
fn from(value: RawDecoratorOptions) -> Self {
Self {
legacy: value.legacy,
emit_metadata: value.emit_metadata,
}
}
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
#[napi(object)]
Expand Down Expand Up @@ -98,30 +79,6 @@ impl From<RawPluginImportConfig> for ImportOptions {
}
}

#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
#[napi(object)]
pub struct RawPresetEnv {
pub targets: Vec<String>,
#[napi(ts_type = "'usage' | 'entry'")]
pub mode: Option<String>,
pub core_js: Option<String>,
}

impl From<RawPresetEnv> for PresetEnv {
fn from(raw_preset_env: RawPresetEnv) -> Self {
Self {
targets: raw_preset_env.targets,
mode: raw_preset_env.mode.and_then(|mode| match mode.as_str() {
"usage" => Some(swc_core::ecma::preset_env::Mode::Usage),
"entry" => Some(swc_core::ecma::preset_env::Mode::Entry),
_ => None,
}),
core_js: raw_preset_env.core_js,
}
}
}

use swc_core::ecma::transforms::react::Runtime;

#[derive(Deserialize, Debug, Serialize, Default, Clone)]
Expand Down Expand Up @@ -222,15 +179,7 @@ impl TryFrom<RawCssModulesConfig> for ModulesConfig {
#[napi(object)]
pub struct RawBuiltins {
pub css: Option<RawCssPluginConfig>,
pub preset_env: Option<RawPresetEnv>,
pub tree_shaking: String,
pub react: RawReactOptions,
pub decorator: Option<RawDecoratorOptions>,
pub no_emit_assets: bool,
pub emotion: Option<String>,
pub dev_friendly_split_chunks: bool,
pub plugin_import: Option<Vec<RawPluginImportConfig>>,
pub relay: Option<RawRelayConfig>,
}

impl RawBuiltins {
Expand All @@ -241,27 +190,11 @@ impl RawBuiltins {
};
plugins.push(CssPlugin::new(options).boxed());
}
if self.dev_friendly_split_chunks {
plugins.push(DevFriendlySplitChunksPlugin::new().boxed());
}

Ok(Builtins {
define: Default::default(),
provide: Default::default(),
preset_env: self.preset_env.map(Into::into),
tree_shaking: self.tree_shaking.into(),
react: self.react.into(),
decorator: self.decorator.map(|i| i.into()),
no_emit_assets: self.no_emit_assets,
emotion: self
.emotion
.map(|i| serde_json::from_str(&i))
.transpose()
.map_err(|e| internal_error!(e.to_string()))?,
plugin_import: self
.plugin_import
.map(|plugin_imports| plugin_imports.into_iter().map(Into::into).collect()),
relay: self.relay.map(Into::into),
})
}
}
73 changes: 36 additions & 37 deletions crates/rspack_binding_values/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,42 @@ repository = "https://github.com/web-infra-dev/rspack"
version = "0.1.0"

[dependencies]
rspack_binding_macros = { path = "../rspack_binding_macros" }
rspack_core = { path = "../rspack_core" }
rspack_error = { path = "../rspack_error" }
rspack_identifier = { path = "../rspack_identifier" }
rspack_ids = { path = "../rspack_ids" }
rspack_loader_react_refresh = { path = "../rspack_loader_react_refresh" }
rspack_loader_runner = { path = "../rspack_loader_runner" }
rspack_loader_swc = { path = "../rspack_loader_swc" }
rspack_napi_shared = { path = "../rspack_napi_shared" }
rspack_plugin_asset = { path = "../rspack_plugin_asset" }
rspack_plugin_banner = { path = "../rspack_plugin_banner" }
rspack_plugin_copy = { path = "../rspack_plugin_copy" }
rspack_plugin_css = { path = "../rspack_plugin_css" }
rspack_plugin_dev_friendly_split_chunks = { path = "../rspack_plugin_dev_friendly_split_chunks" }
rspack_plugin_devtool = { path = "../rspack_plugin_devtool" }
rspack_plugin_ensure_chunk_conditions = { path = "../rspack_plugin_ensure_chunk_conditions" }
rspack_plugin_entry = { path = "../rspack_plugin_entry" }
rspack_plugin_externals = { path = "../rspack_plugin_externals" }
rspack_plugin_hmr = { path = "../rspack_plugin_hmr" }
rspack_plugin_html = { path = "../rspack_plugin_html" }
rspack_plugin_javascript = { path = "../rspack_plugin_javascript" }
rspack_plugin_json = { path = "../rspack_plugin_json" }
rspack_plugin_library = { path = "../rspack_plugin_library" }
rspack_plugin_progress = { path = "../rspack_plugin_progress" }
rspack_plugin_real_content_hash = { path = "../rspack_plugin_real_content_hash" }
rspack_plugin_remove_empty_chunks = { path = "../rspack_plugin_remove_empty_chunks" }
rspack_plugin_runtime = { path = "../rspack_plugin_runtime" }
rspack_plugin_schemes = { path = "../rspack_plugin_schemes" }
rspack_plugin_split_chunks = { path = "../rspack_plugin_split_chunks" }
rspack_plugin_split_chunks_new = { path = "../rspack_plugin_split_chunks_new" }
rspack_plugin_swc_css_minimizer = { path = "../rspack_plugin_swc_css_minimizer" }
rspack_plugin_swc_js_minimizer = { path = "../rspack_plugin_swc_js_minimizer" }
rspack_plugin_wasm = { path = "../rspack_plugin_wasm" }
rspack_plugin_worker = { path = "../rspack_plugin_worker" }
rspack_regex = { path = "../rspack_regex" }
rspack_swc_visitors = { path = "../rspack_swc_visitors" }
rspack_util = { path = "../rspack_util" }
rspack_binding_macros = { path = "../rspack_binding_macros" }
rspack_core = { path = "../rspack_core" }
rspack_error = { path = "../rspack_error" }
rspack_identifier = { path = "../rspack_identifier" }
rspack_ids = { path = "../rspack_ids" }
rspack_loader_react_refresh = { path = "../rspack_loader_react_refresh" }
rspack_loader_runner = { path = "../rspack_loader_runner" }
rspack_loader_swc = { path = "../rspack_loader_swc" }
rspack_napi_shared = { path = "../rspack_napi_shared" }
rspack_plugin_asset = { path = "../rspack_plugin_asset" }
rspack_plugin_banner = { path = "../rspack_plugin_banner" }
rspack_plugin_copy = { path = "../rspack_plugin_copy" }
rspack_plugin_css = { path = "../rspack_plugin_css" }
rspack_plugin_devtool = { path = "../rspack_plugin_devtool" }
rspack_plugin_ensure_chunk_conditions = { path = "../rspack_plugin_ensure_chunk_conditions" }
rspack_plugin_entry = { path = "../rspack_plugin_entry" }
rspack_plugin_externals = { path = "../rspack_plugin_externals" }
rspack_plugin_hmr = { path = "../rspack_plugin_hmr" }
rspack_plugin_html = { path = "../rspack_plugin_html" }
rspack_plugin_javascript = { path = "../rspack_plugin_javascript" }
rspack_plugin_json = { path = "../rspack_plugin_json" }
rspack_plugin_library = { path = "../rspack_plugin_library" }
rspack_plugin_progress = { path = "../rspack_plugin_progress" }
rspack_plugin_real_content_hash = { path = "../rspack_plugin_real_content_hash" }
rspack_plugin_remove_empty_chunks = { path = "../rspack_plugin_remove_empty_chunks" }
rspack_plugin_runtime = { path = "../rspack_plugin_runtime" }
rspack_plugin_schemes = { path = "../rspack_plugin_schemes" }
rspack_plugin_split_chunks = { path = "../rspack_plugin_split_chunks" }
rspack_plugin_split_chunks_new = { path = "../rspack_plugin_split_chunks_new" }
rspack_plugin_swc_css_minimizer = { path = "../rspack_plugin_swc_css_minimizer" }
rspack_plugin_swc_js_minimizer = { path = "../rspack_plugin_swc_js_minimizer" }
rspack_plugin_wasm = { path = "../rspack_plugin_wasm" }
rspack_plugin_worker = { path = "../rspack_plugin_worker" }
rspack_regex = { path = "../rspack_regex" }
rspack_swc_visitors = { path = "../rspack_swc_visitors" }
rspack_util = { path = "../rspack_util" }

anyhow = { workspace = true, features = ["backtrace"] }
async-trait = { workspace = true }
Expand Down
8 changes: 3 additions & 5 deletions crates/rspack_core/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,9 @@ where
return self.compilation.done(self.plugin_driver.clone()).await;
}

if !self.compilation.options.builtins.no_emit_assets {
let start = logger.time("emitAssets");
self.emit_assets().await?;
logger.time_end(start);
}
let start = logger.time("emitAssets");
self.emit_assets().await?;
logger.time_end(start);

let start = logger.time("done hook");
self.compilation.done(self.plugin_driver.clone()).await?;
Expand Down
Loading

0 comments on commit d61fe9c

Please sign in to comment.