Skip to content

Commit

Permalink
Merge branch 'main' into renovate/sass-loader-13.x
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored May 8, 2024
2 parents 8f9d795 + 274a5ef commit d5c8f98
Show file tree
Hide file tree
Showing 292 changed files with 4,913 additions and 3,197 deletions.
2 changes: 2 additions & 0 deletions .github/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
- "/^perf/"
"release: bug fix":
- "/^fix/"
"release: document":
- "/^docs/"
3 changes: 3 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ changelog:
- title: Bug Fixes 🐞
labels:
- "release: bug fix"
- title: Document Updates 📖
labels:
- "release: document"
- title: Other Changes
labels:
- "*"
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ jobs:
owner: ${{ github.repository_owner }}
repo: "rspack-ecosystem-benchmark"
workflow_file_name: "bench_rspack_commit.yml"
github_token: ${{ secrets.RSPACK_BOT_ACCESS_TOKEN }}
github_token: ${{ secrets.RSPACK_ACCESS_TOKEN }}
ref: "main"
client_payload: '{"commit_sha":"${{ github.sha }}"}'

Expand All @@ -333,7 +333,7 @@ jobs:
owner: ${{ github.repository_owner }}
repo: "rspack-ecosystem-ci"
workflow_file_name: "ecosystem-ci-from-commit.yml"
github_token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
github_token: ${{ secrets.RSPACK_ACCESS_TOKEN }}
ref: "main"
client_payload: '{"commitSHA":"${{ github.sha }}","repo":"web-infra-dev/rspack","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
- name: Upload Report
shell: bash
env:
API_TOKEN_GITHUB: ${{ secrets.RSPACK_REPORT_ACCESS_TOKEN }}
API_TOKEN_GITHUB: ${{ secrets.RSPACK_ACCESS_TOKEN }}
run: |
cache_dir="$HOME/.cache/diff_upload"
clone_dir="$cache_dir/${{ github.run_id }}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ecosystem-ci-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
env:
COMMENT: ${{ github.event.comment.body }}
with:
github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
github-token: ${{ secrets.RSPACK_ACCESS_TOKEN }}
result-encoding: string
script: |
const comment = process.env.COMMENT.trim()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/github-issue-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# This is a Personal Access Token and it needs to have the following permissions
# - "read:org": used to read the project's board
# - "write:org": used to assign issues to the project's board
PROJECT_TOKEN: ${{ secrets.PROJECT_TOKEN }}
PROJECT_TOKEN: ${{ secrets.RSPACK_ACCESS_TOKEN }}
# The number of the project which the issues will be synced to
# You can find this in https://github.com/orgs/@ORGANIZATION/projects/<NUMBER>
project: 12
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/release-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
steps:
- uses: actions/github-script@v7
with:
github-token: ${{ secrets.ECOSYSTEM_CI_ACCESS_TOKEN }}
github-token: ${{ secrets.RSPACK_ACCESS_TOKEN }}
script: |
const result = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ jobs:
echo "===================================="
pnpm api-extractor:ci
- name: Documentation coverage check
if: ${{ inputs.target == 'x86_64-unknown-linux-gnu' && !inputs.skipable }}
run: pnpm doc-coverage

### write the latest metric into branch gh-pages
### Note that, We can't merge this script, because this script only runs on main branch
- name: Update main branch test compatibility metric
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ out

# Nuxt.js build / generate output
.nuxt

# Dist files
dist
compiled
webpack-dist

# Gatsby files
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/node_binding/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rspack/binding",
"version": "0.6.3",
"version": "0.6.4",
"license": "MIT",
"description": "Node binding for rspack",
"main": "binding.js",
Expand Down
2 changes: 2 additions & 0 deletions crates/rspack_binding_options/src/options/raw_builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ impl BuiltinPlugin {
plugins.push(
SourceMapDevToolModuleOptionsPlugin::new(SourceMapDevToolModuleOptionsPluginOptions {
module: options.module,
cheap: !options.columns,
})
.boxed(),
);
Expand All @@ -366,6 +367,7 @@ impl BuiltinPlugin {
plugins.push(
SourceMapDevToolModuleOptionsPlugin::new(SourceMapDevToolModuleOptionsPluginOptions {
module: options.module,
cheap: !options.columns,
})
.boxed(),
);
Expand Down
13 changes: 0 additions & 13 deletions crates/rspack_binding_values/src/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,6 @@ impl JsCompilation {
original_module_context: Option<String>,
callback: JsFunction,
) -> Result<()> {
let options = self.0.options.clone();
let plugin_driver = self.0.plugin_driver.clone();
let resolver_factory = self.0.resolver_factory.clone();
let loader_resolver_factory = self.0.loader_resolver_factory.clone();
let cache = self.0.cache.clone();
let dependency_factories = self.0.dependency_factories.clone();

callbackify(env, callback, async {
let module_executor = self
.0
Expand All @@ -478,12 +471,6 @@ impl JsCompilation {
.expect("should have module executor");
let result = module_executor
.import_module(
options,
plugin_driver,
resolver_factory,
loader_resolver_factory,
cache,
dependency_factories,
request,
public_path,
base_uri,
Expand Down
18 changes: 11 additions & 7 deletions crates/rspack_core/src/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,13 @@ impl Compilation {

#[instrument(name = "compilation:make", skip_all)]
pub async fn make(&mut self, mut params: Vec<MakeParam>) -> Result<()> {
// run module_executor
if let Some(module_executor) = &mut self.module_executor {
let mut module_executor = std::mem::take(module_executor);
module_executor.hook_before_make(self, &params).await;
self.module_executor = Some(module_executor);
}

let make_failed_module =
MakeParam::ForceBuildModules(std::mem::take(&mut self.make_failed_module));
let make_failed_dependencies =
Expand Down Expand Up @@ -1042,13 +1049,10 @@ impl Compilation {
logger.time_end(start);

// sync assets to compilation from module_executor
let assets = self
.module_executor
.as_mut()
.map(|module_executor| std::mem::take(&mut module_executor.assets))
.unwrap_or_default();
for (filename, asset) in assets {
self.emit_asset(filename, asset)
if let Some(module_executor) = &mut self.module_executor {
let mut module_executor = std::mem::take(module_executor);
module_executor.hook_before_process_assets(self).await;
self.module_executor = Some(module_executor);
}

let start = logger.time("process assets");
Expand Down
10 changes: 7 additions & 3 deletions crates/rspack_core/src/compiler/hmr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use rspack_sources::Source;
use rustc_hash::FxHashSet as HashSet;

use super::MakeParam;
use crate::{fast_set, get_chunk_from_ukey, ChunkKind, Compilation, Compiler, RuntimeSpec};
use crate::{
fast_set, get_chunk_from_ukey, ChunkKind, Compilation, Compiler, ModuleExecutor, RuntimeSpec,
};

impl<T> Compiler<T>
where
Expand Down Expand Up @@ -73,8 +75,7 @@ where
self.loader_resolver_factory.clone(),
Some(records),
self.cache.clone(),
// reuse module executor
std::mem::take(&mut self.compilation.module_executor),
Some(ModuleExecutor::default()),
);

if let Some(state) = self.options.get_incremental_rebuild_make_state() {
Expand Down Expand Up @@ -118,6 +119,9 @@ where
new_compilation.code_splitting_cache =
std::mem::take(&mut self.compilation.code_splitting_cache);

// reuse module executor
new_compilation.module_executor = std::mem::take(&mut self.compilation.module_executor);

new_compilation.has_module_import_export_change = false;
}

Expand Down
37 changes: 24 additions & 13 deletions crates/rspack_core/src/compiler/make/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod cutout;
mod repair;
pub mod repair;

use std::{hash::BuildHasherDefault, path::PathBuf};

Expand All @@ -19,16 +19,16 @@ use crate::{
#[derive(Debug, Default)]
pub struct MakeArtifact {
module_graph_partial: ModuleGraphPartial,
make_failed_dependencies: HashSet<BuildDependency>,
make_failed_module: HashSet<ModuleIdentifier>,
diagnostics: Vec<Diagnostic>,
pub make_failed_dependencies: HashSet<BuildDependency>,
pub make_failed_module: HashSet<ModuleIdentifier>,
pub diagnostics: Vec<Diagnostic>,

entry_module_identifiers: IdentifierSet,
optimize_analyze_result_map: IdentifierMap<OptimizeAnalyzeResult>,
file_dependencies: IndexSet<PathBuf, BuildHasherDefault<FxHasher>>,
context_dependencies: IndexSet<PathBuf, BuildHasherDefault<FxHasher>>,
missing_dependencies: IndexSet<PathBuf, BuildHasherDefault<FxHasher>>,
build_dependencies: IndexSet<PathBuf, BuildHasherDefault<FxHasher>>,
pub file_dependencies: IndexSet<PathBuf, BuildHasherDefault<FxHasher>>,
pub context_dependencies: IndexSet<PathBuf, BuildHasherDefault<FxHasher>>,
pub missing_dependencies: IndexSet<PathBuf, BuildHasherDefault<FxHasher>>,
pub build_dependencies: IndexSet<PathBuf, BuildHasherDefault<FxHasher>>,

has_module_graph_change: bool,
}
Expand Down Expand Up @@ -76,7 +76,7 @@ impl MakeArtifact {
}
}

#[derive(Debug)]
#[derive(Debug, Clone)]
pub enum MakeParam {
ModifiedFiles(HashSet<PathBuf>),
DeletedFiles(HashSet<PathBuf>),
Expand All @@ -99,10 +99,8 @@ pub async fn update_module_graph(
let mut artifact = MakeArtifact::default();
compilation.swap_make_artifact(&mut artifact);
artifact.move_data_from_compilation(compilation);
let mut cutout = Cutout::default();
let build_dependencies = cutout.cutout_artifact(&mut artifact, params);
artifact = repair(compilation, artifact, build_dependencies)?;
cutout.fix_artifact(&mut artifact);

artifact = update_module_graph_with_artifact(compilation, artifact, params).await?;

// Avoid to introduce too much overhead,
// until we find a better way to align with webpack hmr behavior
Expand Down Expand Up @@ -149,3 +147,16 @@ pub async fn update_module_graph(
compilation.swap_make_artifact(&mut artifact);
Ok(())
}

pub async fn update_module_graph_with_artifact(
compilation: &Compilation,
mut artifact: MakeArtifact,
params: Vec<MakeParam>,
) -> Result<MakeArtifact> {
let mut cutout = Cutout::default();
let build_dependencies = cutout.cutout_artifact(&mut artifact, params);
artifact = repair(compilation, artifact, build_dependencies)?;
cutout.fix_artifact(&mut artifact);

Ok(artifact)
}
2 changes: 1 addition & 1 deletion crates/rspack_core/src/compiler/make/repair/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Task<MakeTaskContext> for BuildTask {
resolver_factory: resolver_factory.clone(),
module: module.identifier(),
module_context: module.as_normal_module().and_then(|m| m.get_context()),
module_source_map_kind: module.get_source_map_kind().clone(),
module_source_map_kind: *module.get_source_map_kind(),
plugin_driver: plugin_driver.clone(),
cache: cache.clone(),
},
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_core/src/compiler/make/repair/factorize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub struct ExportsInfoRelated {
}

#[derive(Debug)]
struct FactorizeResultTask {
pub struct FactorizeResultTask {
// pub dependency: DependencyId,
pub original_module_identifier: Option<ModuleIdentifier>,
/// Result will be available if [crate::ModuleFactory::create] returns `Ok`.
Expand Down
Loading

0 comments on commit d5c8f98

Please sign in to comment.