Skip to content

Conversation

underfin
Copy link
Contributor

@underfin underfin commented Jan 21, 2025

Description

The assetFilenames is used at ecosystem-ci for nuxt, the pr is intended to support it, relate to nuxt/nuxt#30654.

The emitFile is sync method, but call assetFilenames function is async, if using block_on for async emitFile always hang at call assetFilenames function, because the js side emitFile is not finished. So here calculate the assetFilenames at js side to avoid the issue.

close #3253.

@underfin underfin marked this pull request as draft January 21, 2025 14:47
Copy link
Contributor

github-actions bot commented Jan 21, 2025

Benchmarks Rust

group                                                               pr                                     target
-----                                                               --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol                     1.00     73.4±1.49ms        ? ?/sec    1.00     73.1±0.72ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify              1.01     96.1±2.36ms        ? ?/sec    1.00     94.8±1.66ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-minify-sourcemap    1.06    113.1±3.00ms        ? ?/sec    1.00    107.1±1.95ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap           1.01     82.9±1.20ms        ? ?/sec    1.00     82.4±2.38ms        ? ?/sec
bundle/bundle@rome-ts                                               1.00    122.0±0.94ms        ? ?/sec    1.05    128.2±2.56ms        ? ?/sec
bundle/bundle@rome-ts-minify                                        1.02    207.5±3.84ms        ? ?/sec    1.00    203.5±2.75ms        ? ?/sec
bundle/bundle@rome-ts-minify-sourcemap                              1.03    247.2±3.55ms        ? ?/sec    1.00    240.2±3.06ms        ? ?/sec
bundle/bundle@rome-ts-sourcemap                                     1.02    137.4±3.83ms        ? ?/sec    1.00    135.2±1.41ms        ? ?/sec
bundle/bundle@threejs                                               1.00     41.3±2.28ms        ? ?/sec    1.01     41.8±2.15ms        ? ?/sec
bundle/bundle@threejs-minify                                        1.09    103.2±3.67ms        ? ?/sec    1.00     94.9±0.66ms        ? ?/sec
bundle/bundle@threejs-minify-sourcemap                              1.00    112.3±1.67ms        ? ?/sec    1.00    112.6±0.74ms        ? ?/sec
bundle/bundle@threejs-sourcemap                                     1.01     52.0±1.27ms        ? ?/sec    1.00     51.4±0.44ms        ? ?/sec
bundle/bundle@threejs10x                                            1.00    428.9±5.03ms        ? ?/sec    1.00    430.5±6.05ms        ? ?/sec
bundle/bundle@threejs10x-minify                                     1.00   1079.8±9.25ms        ? ?/sec    1.00   1081.6±7.97ms        ? ?/sec
bundle/bundle@threejs10x-minify-sourcemap                           1.01  1257.2±23.90ms        ? ?/sec    1.00  1244.7±10.05ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                                  1.00    493.1±3.96ms        ? ?/sec    1.01    497.2±3.86ms        ? ?/sec
remapping/remapping                                                 1.23     26.6±0.29ms        ? ?/sec    1.00     21.6±0.14ms        ? ?/sec
remapping/render-chunk-remapping                                    1.00     62.7±0.28ms        ? ?/sec    1.12     70.3±6.36ms        ? ?/sec
scan/scan@rome-ts                                                   1.05    101.2±1.51ms        ? ?/sec    1.00     96.5±1.29ms        ? ?/sec
scan/scan@threejs                                                   1.00     31.1±0.95ms        ? ?/sec    1.03     32.0±0.97ms        ? ?/sec
scan/scan@threejs10x                                                1.04    327.9±4.81ms        ? ?/sec    1.00    315.4±2.57ms        ? ?/sec

@underfin underfin marked this pull request as ready for review January 22, 2025 09:04
@underfin underfin enabled auto-merge January 22, 2025 09:11
@underfin underfin requested a review from hyf0 January 23, 2025 05:51
@underfin underfin added this pull request to the merge queue Jan 23, 2025
Merged via the queue into main with commit 242f007 Jan 23, 2025
24 checks passed
@underfin underfin deleted the asset-filenames-fn branch January 23, 2025 06:42
pub fn value(&self, fn_asset_filename: Option<String>) -> String {
match self {
Self::String(value) => value.clone(),
Self::Fn(_) => fn_asset_filename.expect("AssetFilenamesOutputOption Fn should has value"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assetFileNames should allow value.

Test code:

assetFileNames: (asset) => {
      if (
            typeof asset.source === 'string' &&
            asset.source === 'emitted.txt'
            asset.source === 'emitted' &&
            asset.type === 'asset'
      ) {
            return '1-[name].[ext]'
      }
      return '[name].[ext]'
}

Nuxt code:
(chunk) => withoutLeadingSlash(join(nuxt.options.app.buildAssetsDir, `${sanitizeFilePath(filename$1(chunk.name))}.[hash].[ext]`))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: allow functions as values for assetFileNames
3 participants