Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Dynamic Source Map URL Generation Using Placeholders #1

Open
Alpine418 opened this issue Jan 13, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@Alpine418
Copy link

Alpine418 commented Jan 13, 2025

Feature Request: Support for Dynamic Source Map URL Generation Using Placeholders

Hi,

Thank you for creating terser-glob. It perfectly meets my needs for JavaScript minification across multiple files. However, I’ve encountered a limitation with source map handling that I’d like to propose as an enhancement.

Use Case

I’m working with an ESM project where main.js dynamically imports several chunk files. Each file is generated by Rollup with its corresponding source map. When using terser directly, it’s possible to define a custom sourceMap.url for each file. However, this flexibility is not currently available in terser-glob.

Feature Request

It would be highly beneficial if terser-glob supported dynamic source map URL generation by allowing placeholders, such as {file}, in the sourceMap.url configuration. This would make it possible to define file-specific source map URLs during batch minification.

Example Configuration

{
  "sourceMap": {
    "root": "../../../src",
    "url": "{file}.map"
  }
}

In this example, [file] would be replaced by the current file name being processed (e.g., main.js would result in main.js.map).
Benefits

  • Streamlines source map management for projects using dynamic imports or chunking.
  • Avoids the need for post-processing or custom scripting to rename source maps after minification.
  • Aligns terser-glob with the flexibility of terser for single-file workflows.

I believe this feature would significantly enhance the usability of terser-glob for modern JavaScript workflows.

Thanks for considering this enhancement and best regards!

@Alpine418 Alpine418 added the enhancement New feature or request label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant