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

Append .map extension to output source map filename #302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

camerondubas
Copy link

Rather than replacing the .js extension with .map, this appends them so that source maps follow the some-file.js.map naming structure. This is already how .mjs files are handled since the replacing logic specifically targets .js so this change makes the output naming consistent across filetypes.

While not required, the source map spec lists the .js.map naming structure as a convention.

For context, the current naming came up as an issue when trying to upload source maps to Datadog, which requires the conventional naming.

@camerondubas
Copy link
Author

@rwjblue I'm not sure who to tag in order to get this reviewed. No reviewer was automatically added. Could you point me in the right direction? Thanks!

@notmessenger
Copy link

@rwjblue I'm not sure who to tag in order to get this reviewed. No reviewer was automatically added. Could you point me in the right direction? Thanks!

@rwjblue I have the same need for the same situation of uploading source maps to Datadog

@Chris-ScreenSteps
Copy link

Chris-ScreenSteps commented Apr 27, 2023

Anyone needing to rename ember-cli-build's minified sourcemap files from .map to .js.map after the build in order to work with datadog, etc, could create an in repo-addon (ember generate in-repo-addon rename-sourcemap-file), and use the postBuild hook in the addon's index.js file to do this:

'use strict';

// replace your-app-name with the name of your app in package.json, or the output .js filename if you have changed it from the default

module.exports = {
  name: require('./package').name,

  postBuild: function (results) {
    const fs = require('fs-extra');

    let foundFile = '';
    let copyFile = '';
    let file = null;
    let files = fs.readdirSync(results.directory + '/assets/');
    for (let i = 0, l = files.length; i < l; i++) {
      file = files[i];
      if (file.match(/your-app-name\.map$/) !== null) {
        foundFile = results.directory + '/assets/' + file;
        copyFile = results.directory + '/assets/' + file.replace(/\.map/, '.js.map');
        fs.copySync(foundFile, copyFile);
        fs.removeSync(foundFile);
        break;
      }
    }
  },
};

@camerondubas
Copy link
Author

@NullVoxPopuli any chance this could get looked at? Not sure who to tag, but I noticed you published the latest release.

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

Successfully merging this pull request may close these issues.

None yet

3 participants