DataDog / datadog-ci

Use Datadog from your CI.
https://datadoghq.com
Apache License 2.0
129 stars 55 forks source link

Allow users to specify js sourcemap file patterns in `datadog-ci sourcemaps upload` #1374

Open davidsauntson opened 4 months ago

davidsauntson commented 4 months ago

Feature request description

Our front-end build pipeline (rails, sprockets, webpack) produces map files with filenames like [name].js-[digest].map. This is also true of an out-of-the-box installation of a rails app created with rails new -j webpack.

These filenames aren't seen as valid map files by the getMatchingSourcemapFiles() method in upload.ts.

Solution

Add an optional glob argument to getMatchingSourcemapFiles() that is used to get the sourcemap files from the given folder. The glob pattern can be passed in from the command line for users whose frontend pipeline creates sourcemap files with a different filename.

e.g.

const getMatchingSourcemapFiles = async (fileGlobPattern = '**/*.js.map') => {
    const sourcemapFiles = glob.sync(buildPath(this.basePath, fileGlobPattern));

    ...
}

Additional context

Another option is to loosen up the existing glob pattern with something that will always match the current one, so it's backwards compatible (e.g. **/*.js*.map)

I'd be happy to prepare a PR for this.

Command

sourcemaps