Skip to content

Conversation

@Timeless0911
Copy link
Contributor

@Timeless0911 Timeless0911 commented Apr 10, 2025

Summary

In composeAutoExtensionConfig fuction, we should only return config about output.filename.js instead of whole output.filename object to avoid being merged into an array which Rsbuild will throw an error, see #911 (comment).

BTW, just record this scene in this PR that Rslib support setting function for output.filename.js and it will take effect in actual output. But we can not get correct js extension when we redirect js path in bundleless mode and will fallback to the default js extension (related to autoExtension config) which may not be consistent with the actual output.

Eg.

// config
output: {
  filename: {
    js: () => {
      return '[name].mjs';
    },
  },
},

// source
import { foo } from './foo';

// output
import * as __WEBPACK_EXTERNAL_MODULE__foo_js_fdf5aa2d__ from "./foo.js";

The actual output is foo.mjs but we can not get it and redirect to foo.js as a fallback.

So if users want to set function for output.filename.js, the [ext] should better be equal to the default js extension (related to autoExtension config).

Related Links

fix: #911

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@netlify
Copy link

netlify bot commented Apr 10, 2025

Deploy Preview for rslib ready!

Name Link
🔨 Latest commit aafcdd4
🔍 Latest deploy log https://app.netlify.com/sites/rslib/deploys/67f7754f02268400084f4a2c
😎 Deploy Preview https://deploy-preview-912--rslib.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Timeless0911 Timeless0911 merged commit b7c29fc into main Apr 10, 2025
16 checks passed
@Timeless0911 Timeless0911 deleted the fix/fuction-filename branch April 10, 2025 07:59
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]: output.filename does not allow setting filename dynamically using a function

3 participants