Skip to content

Conversation

@ahabhgk
Copy link
Contributor

@ahabhgk ahabhgk commented May 12, 2023

Related issue (if exists)

closes #3071

Summary

🤖 Generated by Copilot at 2a2a499

This pull request adds support for filename templates and immutable assets to the rspack compiler and its plugins. It introduces the PathData type and the get_path_with_info method to the Compilation struct, and updates the node binding and the plugin API to use them. It also simplifies some code, fixes a bug in the HMR plugin, and removes some unused types and imports.

Walkthrough

🤖 Generated by Copilot at 2a2a499

  • Add the immutable field to the AssetInfo and JsAssetInfo structs, and implement the logic for copying and setting it (link, link, link, link, link)
  • Add the get_path, get_path_with_info, get_asset_path, and get_asset_path_with_info methods to the Compilation struct, and implement the logic for generating asset paths and filenames based on templates and data (link)
  • Add the PathData struct and its methods to the js_values module, and expose it to the node binding (link, link, link)
  • Add the get_asset_path and get_path methods to the JsCompilation struct, and implement the wrappers for the corresponding methods in the Compilation struct (link, link)
  • Add the BASE_PLACEHOLDER, QUERY_PLACEHOLDER, FRAGMENT_PLACEHOLDER, RUNTIME_PLACEHOLDER, and URL_PLACEHOLDER constants to the output.rs file, and implement the logic for replacing them in the filename templates (link, link)
  • Replace the FilenameRenderOptions struct with the PathData struct in the output.rs file, and modify the render, render_with_chunk, and render_with_chunk_and_file methods of the Filename struct accordingly (link, link)
  • Modify the name_for_filename_template method of the Chunk struct to return an Option<&str> instead of an Option<String> (link)
  • Modify the emit_asset method of the Compilation struct to split the filename by the query string, and only use the filename part for the asset path (link)
  • Modify the emit_hot_update method of the HmrPlugin struct to use the correct chunk ukey to get the chunk from the compilation (link)
  • Modify the new and render_manifest methods of the RenderManifestEntry struct to use the PathData struct instead of the AssetInfo and FilenameRenderOptions structs, and to pass the asset info directly (link, link)
  • Modify the codegen method of the AssetParserAndGenerator struct to use the PathData struct instead of the FilenameRenderOptions struct, and to call the get_asset_path_with_info method of the Compilation struct instead of the render method of the Filename struct (link)
  • Modify the render_manifest method of the AssetParserAndGenerator struct to pass the asset info directly to the RenderManifestEntry::new method (link)
  • Modify the copy method of the CopyPlugin struct to use the PathData struct instead of the FilenameRenderOptions struct, and to call the get_asset_path method of the Compilation struct instead of the render method of the Filename struct (link)
  • Modify the parse method of the CssParserAndGenerator struct to use the Path type from the std crate instead of the sugar_path crate, and to pass the filename as a Path reference to the ModulesTransformConfig struct (link)
  • Modify the render_manifest method of the CssPlugin struct to use the PathData struct instead of the FilenameRenderOptions struct, and to call the get_path_with_info method of the Compilation struct instead of the render_with_chunk method of the Filename struct (link, link)
  • Modify the render method of the LocalIdentName struct to use the PathData struct instead of the FilenameRenderOptions struct, and to pass the path data to the render method of the Filename struct (link)
  • Modify the LocalIdentNameRenderOptions struct to use the PathData struct instead of the FilenameRenderOptions struct, and to use references instead of owned values (link)
  • Modify the ModulesTransformConfig struct and its new_name_for method to use the Path type instead of the name, path, and ext fields, and to pass the filename as a Path reference to the render method of the LocalIdentName struct (link)
  • Modify the render_manifest method of the DevtoolPlugin struct to use the PathData struct instead of the FilenameRenderOptions struct, and to call the get_path_with_info method of the Compilation struct instead of the render_with_chunk_and_file method of the Filename struct (link)
  • Modify the codegen method of the HtmlPlugin struct to use the PathData struct instead of the FilenameRenderOptions struct, and to call the get_path_with_info method of the Compilation struct instead of the render method of the Filename struct (link)
  • Modify the render_manifest method of the JsPlugin struct to use the PathData struct instead of the FilenameRenderOptions struct, and to call the get_path_with_info method of the Compilation struct instead of the render_with_chunk method of the Filename struct (link)
  • Modify the render method of the AmdLibraryPlugin struct to use the PathData struct instead of the FilenameRenderOptions struct, and to call the get_path method of the Compilation struct instead of the render_with_chunk method of the Filename struct (link)

@ahabhgk ahabhgk linked an issue May 12, 2023 that may be closed by this pull request
hyf0
hyf0 previously approved these changes May 12, 2023
@ahabhgk ahabhgk linked an issue May 12, 2023 that may be closed by this pull request
h-a-n-a
h-a-n-a previously approved these changes May 12, 2023
@ahabhgk ahabhgk dismissed stale reviews from h-a-n-a and hyf0 via 1eabd49 May 12, 2023 12:55
@ahabhgk ahabhgk requested review from h-a-n-a and hyf0 May 12, 2023 12:57
hyf0
hyf0 previously approved these changes May 12, 2023
underfin
underfin previously approved these changes May 15, 2023
@underfin underfin added the to be discussed Rspack team would discuss these issues per week label May 15, 2023
@hyf0 hyf0 added the team The issue/pr is created by the member of Rspack. label May 16, 2023
@ahabhgk ahabhgk enabled auto-merge May 17, 2023 05:42
@ahabhgk ahabhgk added this pull request to the merge queue May 17, 2023
Merged via the queue into main with commit 5d3eb98 May 17, 2023
@ahabhgk ahabhgk deleted the refactor-path branch May 17, 2023 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team The issue/pr is created by the member of Rspack. to be discussed Rspack team would discuss these issues per week

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: compilation getPath related methods

5 participants