Skip to content

Should avoid generating inline sourcemaps for unchanged *.js files #108

@rwjblue

Description

@rwjblue

When ember-template-imports gets added all .js files end up including new inline sourcemaps.

Quick summary:

  1. ember-template-imports adds a custom preprocessor for .js files here
  2. that preprocessor (from here) calls preprocessEmbeddedTemplates
  3. that uses magic-string to process specific template-literals
  4. it uses magic-string for all .js files, it ends up including sourcemaps for every .js file regardless if there were any templates in it

Tldr; we should change

https://github.com/ember-template-imports/ember-template-imports/blob/72f11d2f145bc20e1912339475ef17023fa4722f/src/preprocess-embedded-templates.ts#L257-L268

to something like:

const hasChanges = template !== output;
if (includeSourceMaps && hasChanges) {
   const { dir, name } = path.parse(relativePath); 
  
   const map = s.generateMap({ 
     file: `${dir}/${name}.js`, 
     source: relativePath, 
     includeContent: true, 
     hires: true, 
   }); 
  
   output += `\n//# sourceMappingURL=${map.toUrl()}`; 
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions